From ee681b72ce89539e5764ed59e5dfea4fab04d48c Mon Sep 17 00:00:00 2001 From: David Vacca Date: Thu, 2 May 2019 17:30:41 -0700 Subject: [PATCH] React sync for revisions 8e25ed2...ec6691a MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This sync includes the following changes: - **[ec6691a68](https://github.com/facebook/react/commit/ec6691a68 )**: Event API: remove isTargetDirectlyWithinEventComponent (#15546) //// - **[a6e30001f](https://github.com/facebook/react/commit/a6e30001f )**: Delete duplicate Focus.js (#15540) //// - **[f7993d547](https://github.com/facebook/react/commit/f7993d547 )**: Delete duplicate Hover.js (#15539) //// - **[c8ee10037](https://github.com/facebook/react/commit/c8ee10037 )**: Delete duplicate Swipe.js (#15541) //// - **[494716c9b](https://github.com/facebook/react/commit/494716c9b )**: Delete duplicate Drag.js (#15537) //// - **[377846fef](https://github.com/facebook/react/commit/377846fef )**: Delete duplicate Press.js (#15538) //// - **[379515e83](https://github.com/facebook/react/commit/379515e83 )**: Follow up to 15535 (#15536) //// - **[bd88982fb](https://github.com/facebook/react/commit/bd88982fb )**: Event API: use `capture` for all event listeners using experimental responder system (#15526) //// - **[72ca3c60e](https://github.com/facebook/react/commit/72ca3c60e )**: Bump scheduler version to 0.14.0 (#15395) //// - **[7882c41f6](https://github.com/facebook/react/commit/7882c41f6 )**: Use lowercase entry points for event modules (#15535) //// - **[43c4e5f34](https://github.com/facebook/react/commit/43c4e5f34 )**: Add method for forcing a lower framerate //// - **[1b752f191](https://github.com/facebook/react/commit/1b752f191 )**: Fixed potential interaction tracing leak in Suspense thennable memoization (#15531) //// - **[12e5a13cf](https://github.com/facebook/react/commit/12e5a13cf )**: [React Native] Inline calls to FabricUIManager in shared code (#15490) //// - **[2cca18728](https://github.com/facebook/react/commit/2cca18728 )**: React Events: add onFocusVisibleChange to Focus (#15516) //// - **[cc5a49379](https://github.com/facebook/react/commit/cc5a49379 )**: React Events: FocusScope tweaks and docs (#15515) //// - **[796c67a25](https://github.com/facebook/react/commit/796c67a25 )**: Event API: responder event types should not re-register on EventComponent update (#15514) //// - **[c4d1dcb53](https://github.com/facebook/react/commit/c4d1dcb53 )**: React Events: core API documentation followup (#15506) //// - **[41ef1961c](https://github.com/facebook/react/commit/41ef1961c )**: Update TopLevelEventTypes.js (#15511) //// - **[7a482af5d](https://github.com/facebook/react/commit/7a482af5d )**: Event API: Fix bug where Press root events were not being cleared (#15507) //// - **[a14e24efa](https://github.com/facebook/react/commit/a14e24efa )**: React Events: core API documentation (#15505) //// - **[8658611b6](https://github.com/facebook/react/commit/8658611b6 )**: Event API: ensure event keys are unique + add validation (#15501) //// - **[d9839740e](https://github.com/facebook/react/commit/d9839740e )**: React events: remove unused types (#15503) //// - **[0b3431170](https://github.com/facebook/react/commit/0b3431170 )**: React events: fix press end event dispatching (#15500) //// - **[d1f667acc](https://github.com/facebook/react/commit/d1f667acc )**: Event API: follow up fixes for FocusScope + context changes (#15496) //// - **[c530639dd](https://github.com/facebook/react/commit/c530639dd )**: Minor code structure adjustments to the bundles.js file (#15079) //// - **[ed36df46c](https://github.com/facebook/react/commit/ed36df46c )**: add --watch mode to "yarn build" (#15116) //// - **[793ef9b85](https://github.com/facebook/react/commit/793ef9b85 )**: test(eslint-plugin-react-hooks): add coverage for unused custom hook (#15130) //// - **[d61da9387](https://github.com/facebook/react/commit/d61da9387 )**: test(accumulate): add test suite for accumulate function (#15159) //// - **[a187e9b5e](https://github.com/facebook/react/commit/a187e9b5e )**: React Native: Allow Views to be nested inside of Text (#15464) //// - **[f85aadefc](https://github.com/facebook/react/commit/f85aadefc )**: ADD: disablePictureInPicture attribute for HTML5 videos (#15334) //// - **[1eb2b892d](https://github.com/facebook/react/commit/1eb2b892d )**: give `canUseDOM` with a possibility to be a constant (#14194) //// - **[de26d6dd3](https://github.com/facebook/react/commit/de26d6dd3 )**: typo fix (#15493) //// - **[64e3da286](https://github.com/facebook/react/commit/64e3da286 )**: Event API: Add `FocusScope` surface (#15487) //// - **[3f058debc](https://github.com/facebook/react/commit/3f058debc )**: Event API: various bug fixes (#15485) //// - **[fb28e9048](https://github.com/facebook/react/commit/fb28e9048 )**: Add missing word to code comment for clarity (#15443) //// - **[fa2fa3564](https://github.com/facebook/react/commit/fa2fa3564 )**: Experimental event API: adds context.isTargetDirectlyWithinEventComponent (#15481) //// - **[d3af2f2a5](https://github.com/facebook/react/commit/d3af2f2a5 )**: Experimental Event API: add event component mount phase callback (#15480) //// - **[ce126fbb2](https://github.com/facebook/react/commit/ce126fbb2 )**: Fix priority inference of next level of work (#15478) //// - **[71c8759ce](https://github.com/facebook/react/commit/71c8759ce )**: Measure callback timeout relative to current time (#15479) //// - **[9c6ff136c](https://github.com/facebook/react/commit/9c6ff136c )**: Remove timeout from performance flamegraph (#15477) //// - **[299a2714c](https://github.com/facebook/react/commit/299a2714c )**: Use stricter equality check (#15474) //// - **[017d6f14b](https://github.com/facebook/react/commit/017d6f14b )**: Experimental Event API: add `rootEventTypes` support to event responders (#15475) //// - **[784ebd8fa](https://github.com/facebook/react/commit/784ebd8fa )**: Experimental event API: rework the propagation system for event components (#15462) //// - **[587676900](https://github.com/facebook/react/commit/587676900 )**: React events: initial implementation of disabled prop (#15458) //// - **[59c7aef91](https://github.com/facebook/react/commit/59c7aef91 )**: React events: add a test for focusable descendants (#15457) //// - **[0a8da3391](https://github.com/facebook/react/commit/0a8da3391 )**: React events: README update types and remove stopPropagation prop (#15456) //// - **[d584fcdc6](https://github.com/facebook/react/commit/d584fcdc6 )**: React events: use passive events where possible (#15454) //// - **[051513bfa](https://github.com/facebook/react/commit/051513bfa )**: React Events: consolidate logic for Press event component (#15451) //// - **[cdfce1ad2](https://github.com/facebook/react/commit/cdfce1ad2 )**: React events: consolidate logic of Hover event component (#15450) //// - **[5857c89da](https://github.com/facebook/react/commit/5857c89da )**: React events: extract common helper functions (#15449) //// - **[0b50fb29f](https://github.com/facebook/react/commit/0b50fb29f )**: Include rootEventTypes in DOMEventResponderSystem stopPropagation tests (#15433) //// - **[1ae409d2c](https://github.com/facebook/react/commit/1ae409d2c )**: React events: fix nested Hover components error (#15428) //// - **[c73ab39c1](https://github.com/facebook/react/commit/c73ab39c1 )**: React events: make nested Focus work as expected (#15421) //// - **[4221565e1](https://github.com/facebook/react/commit/4221565e1 )**: Cancel pending commit before starting on root //// - **[9ebe1768a](https://github.com/facebook/react/commit/9ebe1768a )**: Experimental Event API: Redesign event responder propagation (#15408) //// - **[a30e7d992](https://github.com/facebook/react/commit/a30e7d992 )**: act() tests - Reuse and properly unmount containers (#14974) //// - **[8cf963c6c](https://github.com/facebook/react/commit/8cf963c6c )**: React events: ignore device buttons that aren't for primary interactions (#15402) //// - **[38bd570d4](https://github.com/facebook/react/commit/38bd570d4 )**: Stop tracking bundle sizes (#15404) //// - **[3438e5ce8](https://github.com/facebook/react/commit/3438e5ce8 )**: Experimental Event API: Add Hover onUnmount support (#15394) //// - **[805e7f873](https://github.com/facebook/react/commit/805e7f873 )**: React events: add unmounting to Focus (#15396) //// - **[543353a04](https://github.com/facebook/react/commit/543353a04 )**: Experimental Event API: Remove "listener" from event objects (#15391) //// - **[9055e31e5](https://github.com/facebook/react/commit/9055e31e5 )**: Replace old Fiber Scheduler with new one (#15387) //// - **[4e59d4f5d](https://github.com/facebook/react/commit/4e59d4f5d )**: React events: add onHoverMove support (#15388) //// - **[de7590327](https://github.com/facebook/react/commit/de7590327 )**: Fix CI (#15393) //// - **[687e4fb6f](https://github.com/facebook/react/commit/687e4fb6f )**: Bump scheduler version to 0.14.0 //// - **[45473c94c](https://github.com/facebook/react/commit/45473c94c )**: React events: Press event fixes (#15386) //// - **[9672cf621](https://github.com/facebook/react/commit/9672cf621 )**: Experimental Event API: adds `stopPropagation` by default to Press (#15384) //// - **[a9eff329c](https://github.com/facebook/react/commit/a9eff329c )**: Remove TouchHitTarget SSR logic to prevent issues with mouse events (#15381) //// - **[c9841001b](https://github.com/facebook/react/commit/c9841001b )**: Experimental Event API: preventDefault handling for anchors (#15383) //// - **[c25c59c80](https://github.com/facebook/react/commit/c25c59c80 )**: Apply the Just Noticeable Difference to suspense timeouts (#15367) //// - **[3e2e930d6](https://github.com/facebook/react/commit/3e2e930d6 )**: Fixes a Flow type merge conflict (#15378) //// - **[7fc91f17c](https://github.com/facebook/react/commit/7fc91f17c )**: React events: add onPressMove and pressRetentionOffset to Press (#15374) //// - **[dd9cef9fc](https://github.com/facebook/react/commit/dd9cef9fc )**: Experimental Event API: Add targets and responder utility method for finding targets (#15372) //// - **[c64b33003](https://github.com/facebook/react/commit/c64b33003 )**: Move EventTypes to ReactTypes (#15364) //// - **[4c78ac0b9](https://github.com/facebook/react/commit/4c78ac0b9 )**: Track Event Time as the Start Time for Suspense (#15358) //// - **[875d05d55](https://github.com/facebook/react/commit/875d05d55 )**: Include full error messages in React Native build (#15363) //// - **[1b2159acc](https://github.com/facebook/react/commit/1b2159acc )**: [React Native] measure calls will now call FabricUIManager (#15324) //// - **[c7a959982](https://github.com/facebook/react/commit/c7a959982 )**: [React Native] Add tests to paper renderer for measure, measureLayout (#15323) //// - **[aece8119c](https://github.com/facebook/react/commit/aece8119c )**: Refactor EventComponent logic + add onOwnershipChange callback (#15354) //// - **[183d1f42e](https://github.com/facebook/react/commit/183d1f42e )**: Fix: Measure expiration times relative to module initialization (#15357) //// - **[b4bc33a58](https://github.com/facebook/react/commit/b4bc33a58 )**: Fix areHookInputsEqual method warning params order (#15345) //<砖家>// - **[29fb5862f](https://github.com/facebook/react/commit/29fb5862f )**: Move EventComponent state creation to complete phase + tests (#15352) //// - **[745baf2e0](https://github.com/facebook/react/commit/745baf2e0 )**: Provide new jsx transform target for reactjs/rfcs#107 (#15141) //// - **[81a61b1d1](https://github.com/facebook/react/commit/81a61b1d1 )**: React events: add delay props to Press module (#15340) //// - **[4064ea9fa](https://github.com/facebook/react/commit/4064ea9fa )**: Experimental event API: Support EventComponent onUnmount responder callback (#15335) //// - **[4fbbae8af](https://github.com/facebook/react/commit/4fbbae8af )**: Add full TouchHitTarget hit slop (experimental event API) to ReactDOM (#15308) //// - **[958b6173f](https://github.com/facebook/react/commit/958b6173f )**: Add delay props to Hover event module (#15325) //// - **[c3cc936da](https://github.com/facebook/react/commit/c3cc936da )**: Add Hover,Focus,Press docs to REAMDE (#15328) //// - **[49595e921](https://github.com/facebook/react/commit/49595e921 )**: [New Scheduler] Fix: Suspending an expired update (#15326) //// - **[b93a8a9bb](https://github.com/facebook/react/commit/b93a8a9bb )**: Experimental event API: refactor responder modules for lifecycle inclusion (#15322) //// - **[937d262f5](https://github.com/facebook/react/commit/937d262f5 )**: React events: keyboard press, types, tests (#15314) //// - **[7a2dc4853](https://github.com/facebook/react/commit/7a2dc4853 )**: Allow DevTools to toggle Suspense fallbacks (#15232) //// - **[43b1f74c8](https://github.com/facebook/react/commit/43b1f74c8 )**: Alternate fix for #14198 //// - **[41aa345d2](https://github.com/facebook/react/commit/41aa345d2 )**: Fix a crash in Suspense with findDOMNode //// - **[6d0effad7](https://github.com/facebook/react/commit/6d0effad7 )**: Expose extra internals in FB build of react-dom/unstable-new-scheduler (#15311) //// - **[3a44ccefe](https://github.com/facebook/react/commit/3a44ccefe )**: Fix feature flags react-dom/unstable-new-scheduler (#15309) //// - **[92a1d8fea](https://github.com/facebook/react/commit/92a1d8fea )**: mark react-events as private so we publish script skips it for now (#15307) //// - **[e5c59359c](https://github.com/facebook/react/commit/e5c59359c )**: Prevent bundling of Node polyfills when importing TestUtils/TestRenderer (#15305) //// - **[73187239a](https://github.com/facebook/react/commit/73187239a )**: writing unit tests in experimental event Drag API (#15297) //// - **[89064fe68](https://github.com/facebook/react/commit/89064fe68 )**: Adds displayName to EventComponent and EventTarget (#15268) //// - **[fc6a9f1a1](https://github.com/facebook/react/commit/fc6a9f1a1 )**: Add test for async event dispatching (#15300) //// - **[38fa84088](https://github.com/facebook/react/commit/38fa84088 )**: Experiemental event API - wrap async dispatched events (#15299) //// - **[4d5cb64aa](https://github.com/facebook/react/commit/4d5cb64aa )**: Rewrite ReactFiberScheduler for better integration with Scheduler package (#15151) //// - **[aed0e1c30](https://github.com/facebook/react/commit/aed0e1c30 )**: await act(async () => ...) (#14853) //// - **[4c75881ee](https://github.com/facebook/react/commit/4c75881ee )**: Remove maxDuration from tests (#15272) //// - **[9307932fe](https://github.com/facebook/react/commit/9307932fe )**: Refactor event object creation for the experimental event API (#15295) //// - **[6a1e6b2f7](https://github.com/facebook/react/commit/6a1e6b2f7 )**: Experimental event API: loosen EventTarget constraints and warnings (#15292) //// - **[f243deab8](https://github.com/facebook/react/commit/f243deab8 )**: Add tests for Press responder event module (#15290) //// - **[296c4393d](https://github.com/facebook/react/commit/296c4393d )**: Add Press event prop types and fix a check in Safari (#15288) //// - **[4482fdded](https://github.com/facebook/react/commit/4482fdded )**: Fix host context issues around EventComponents and EventTargets (#15284) //// - **[5ef0d1d29](https://github.com/facebook/react/commit/5ef0d1d29 )**: Rename hover props in experimental event API and write unit tests (#15283) //// - **[9444a5472](https://github.com/facebook/react/commit/9444a5472 )**: Warn on nested EventTragets in experimental event API (#15287) //// - **[7f1f5ddc3](https://github.com/facebook/react/commit/7f1f5ddc3 )**: Rename press props in experimental event API (#15263) //// - **[2e02469fa](https://github.com/facebook/react/commit/2e02469fa )**: ReactNative's ref.measureLayout now takes a ref (#15126) //// - **[1b94fd215](https://github.com/facebook/react/commit/1b94fd215 )**: Make setNativeProps a no-op with Fabric renderer (#15094) //// - **[08055a625](https://github.com/facebook/react/commit/08055a625 )**: Fix Press module in experimental event API (#15262) //// - **[f4625f518](https://github.com/facebook/react/commit/f4625f518 )**: Fix on(Long)PressChange events in experimental press event API (#15256) //// - **[a41b21770](https://github.com/facebook/react/commit/a41b21770 )**: Add additional event API responder surfaces (#15248) //// - **[700f17be6](https://github.com/facebook/react/commit/700f17be6 )**: Fix longpress in experimental Press event module (#15246) //// - **[5d336df70](https://github.com/facebook/react/commit/5d336df70 )**: Allow for null targetFiber for root event handling (#15247) //// - **[c6f3524df](https://github.com/facebook/react/commit/c6f3524df )**: Adds React event component and React event target support to SSR renderer (#15242) //// - **[c7a2dce50](https://github.com/facebook/react/commit/c7a2dce50 )**: Disable JS urls at build level for www (#15230) //// - **[fb6b50871](https://github.com/facebook/react/commit/fb6b50871 )**: Update versions for 16.8.6 //// - **[1cfd25668](https://github.com/facebook/react/commit/1cfd25668 )**: Fix circular module imports causing file size increase (#15231) //// - **[669cafb36](https://github.com/facebook/react/commit/669cafb36 )**: Adds experimental event component responder surfaces (#15228) //// - **[d8cb10f11](https://github.com/facebook/react/commit/d8cb10f11 )**: Enabled warnAboutDeprecatedLifecycles flag by default (#15186) //// - **[80f8b0d51](https://github.com/facebook/react/commit/80f8b0d51 )**: Add part of the event responder system for experimental event API (#15179) //// - **[5c2b2c085](https://github.com/facebook/react/commit/5c2b2c085 )**: Warn about async infinite useEffect loop (#15180) //// - **[8e9a013c0](https://github.com/facebook/react/commit/8e9a013c0 )**: Release 16.8.5 //// - **[f33e5790b](https://github.com/facebook/react/commit/f33e5790b )**: eslint-plugin-react-hooks@1.6.0 //// - **[b1cccd1ed](https://github.com/facebook/react/commit/b1cccd1ed )**: Warn about setState directly in dep-less useEffect (#15184) //// - **[78f2775ed](https://github.com/facebook/react/commit/78f2775ed )**: Flip event passive logic on passiveBrowserEventsSupported (#15190) //// - **[f161ee2eb](https://github.com/facebook/react/commit/f161ee2eb )**: React.warn() and React.error() (#15170) //// - **[78968bb3d](https://github.com/facebook/react/commit/78968bb3d )**: Validate useEffect without deps too (#15183) //// - **[4b8e1641b](https://github.com/facebook/react/commit/4b8e1641b )**: Fork performWork instead of using boolean flag (#15169) //// - **[56035dac6](https://github.com/facebook/react/commit/56035dac6 )**: unstable_Profiler -> Profiler (#15172) //// - **[31518135c](https://github.com/facebook/react/commit/31518135c )**: Strengthen nested update counter test coverage (#15166) //// - **[66f280c87](https://github.com/facebook/react/commit/66f280c87 )**: Add internal logic for listening to event responders (#15168) //// - **[b1a56abd6](https://github.com/facebook/react/commit/b1a56abd6 )**: Fork ReactFiberScheduler with feature flag //// - **[45f571736](https://github.com/facebook/react/commit/45f571736 )**: ReactFiberScheduler -> ReactFiberScheduler.old //// - **[c05b4b81f](https://github.com/facebook/react/commit/c05b4b81f )**: Link to useLayoutEffect gist in a warning (#15158) //// - **[061d6ce3c](https://github.com/facebook/react/commit/061d6ce3c )**: fix(react-dom): access iframe contentWindow instead of contentDocument (#15099) //// - **[b83e01cad](https://github.com/facebook/react/commit/b83e01cad )**: Adds more scaffolding for experimental event API (#15112) //// - **[daeda44d8](https://github.com/facebook/react/commit/daeda44d8 )**: Follow up to 15150 (#15152) //// - **[acd65db5b](https://github.com/facebook/react/commit/acd65db5b )**: Deprecate module pattern (factory) components (#15145) //// - **[55cc921c5](https://github.com/facebook/react/commit/55cc921c5 )**: Adds react-events package for internal testing (#15150) //// - **[7ad738630](https://github.com/facebook/react/commit/7ad738630 )**: Improve warning for invalid class contextType (#15142) //// - **[1e3364e76](https://github.com/facebook/react/commit/1e3364e76 )**: Test that we don't suspend when disabling yielding (#15143) //// - **[42c3c967d](https://github.com/facebook/react/commit/42c3c967d )**: Compile invariant directly to throw expressions (#15071) //// - **[df7b87d25](https://github.com/facebook/react/commit/df7b87d25 )**: Warn for Context.Consumer with contextType (#14831) //// - **[2b93d686e](https://github.com/facebook/react/commit/2b93d686e )**: Add more info to invalid hook call error message (#15139) //// - **[d926936f0](https://github.com/facebook/react/commit/d926936f0 )**: Eager bailout optimization should always compare to latest reducer (#15124) //// - **[4162f6026](https://github.com/facebook/react/commit/4162f6026 )**: Add feature flag to disable yielding (#15119) //// - **[8d60bd4dc](https://github.com/facebook/react/commit/8d60bd4dc )**: [Shallow] Implement setState for Hooks and remount on type change (#15120) //// - **[035e4cffb](https://github.com/facebook/react/commit/035e4cffb )**: Change passive checker to use defineProperty (#15121) //// - **[b283d75c1](https://github.com/facebook/react/commit/b283d75c1 )**: Support React.memo in ReactShallowRenderer (#14816) //// - **[f0621fe23](https://github.com/facebook/react/commit/f0621fe23 )**: Use same example code for async effect warning (#15118) //// - **[52c870c8d](https://github.com/facebook/react/commit/52c870c8d )**: Fix shallow renderer not allowing hooks in forwardRef render functions (#15100) //// - **[f1ff4348c](https://github.com/facebook/react/commit/f1ff4348c )**: Don't suggest a function as its own dep (#15115) //// - **[371bbf36b](https://github.com/facebook/react/commit/371bbf36b )**: Add infrastructure for passive/non-passive event support for future API exploration (#15036) //// - **[ab5fe174c](https://github.com/facebook/react/commit/ab5fe174c )**: Don't set the first option as selected in select tag with `size` attribute (#14242) //// - **[935f60083](https://github.com/facebook/react/commit/935f60083 )**: eslint-plugin-react-hooks@1.5.1 //// - **[0c03a4743](https://github.com/facebook/react/commit/0c03a4743 )**: Adds experimental event API scaffolding (#15108) //// - **[1204c7897](https://github.com/facebook/react/commit/1204c7897 )**: [eslint] Wording tweaks (#15078) //// - **[9d77a317b](https://github.com/facebook/react/commit/9d77a317b )**: Improve async useEffect warning (#15104) //// - **[103378b1e](https://github.com/facebook/react/commit/103378b1e )**: Warn for javascript: URLs in DOM sinks (#15047) //// - **[5d0c3c6c7](https://github.com/facebook/react/commit/5d0c3c6c7 )**: [Partial Hydration] Render client-only content at normal priority (#15061) //// - **[6a4a261ee](https://github.com/facebook/react/commit/6a4a261ee )**: Test suspended children are hidden before layout in persistent mode (#15030) //// - **[bc8bd24c1](https://github.com/facebook/react/commit/bc8bd24c1 )**: Run persistent mode tests in CI (#15029) //// - **[3f4852fa5](https://github.com/facebook/react/commit/3f4852fa5 )**: Run Placeholder tests in persistent mode, too (#15013) //// - **[d0289c7e3](https://github.com/facebook/react/commit/d0289c7e3 )**: eslint-plugin-react-hooks@1.5.0 //// - **[03ad9c73e](https://github.com/facebook/react/commit/03ad9c73e )**: [ESLint] Tweak setState updater message and add useEffect(async) warning (#15055) //// - **[eb6247a9a](https://github.com/facebook/react/commit/eb6247a9a )**: More concise messages (#15053) //// - **[197703ecc](https://github.com/facebook/react/commit/197703ecc )**: [ESLint] Add more hints to lint messages (#15046) //// - **[6d2666bab](https://github.com/facebook/react/commit/6d2666bab )**: Fix ESLint rule crash (#15044) //// - **[9b7e1d138](https://github.com/facebook/react/commit/9b7e1d138 )**: [ESLint] Suggest moving inside a Hook or useCallback when bare function is a dependency (#15026) //// - **[1e3b6192b](https://github.com/facebook/react/commit/1e3b6192b )**: Import Scheduler directly, not via host config (#14984) //// - **[5d49dafac](https://github.com/facebook/react/commit/5d49dafac )**: Enforce deps array in useMemo and useCallback (#15025) //// - **[a9aa24ed8](https://github.com/facebook/react/commit/a9aa24ed8 )**: 16.8.4 and changelog //// - **[fa5d4ee43](https://github.com/facebook/react/commit/fa5d4ee43 )**: [ESLint] Treat functions that don't capture anything as static (#14996) //// - **[fd557d453](https://github.com/facebook/react/commit/fd557d453 )**: Warn on mount when deps are not an array (#15018) //// - **[ce45ca9ba](https://github.com/facebook/react/commit/ce45ca9ba )**: Prettier //// - **[757a70b25](https://github.com/facebook/react/commit/757a70b25 )**: ReactNoop.yield -> Scheduler.yieldValue (#15008) //// - **[9d756d903](https://github.com/facebook/react/commit/9d756d903 )**: Revert #14756 changes to ReactFiberScheduler (#14992) //// - **[f16442a10](https://github.com/facebook/react/commit/f16442a10 )**: eslint-plugin-react-hooks@1.4.0 //// - **[e1e45fb36](https://github.com/facebook/react/commit/e1e45fb36 )**: [ESLint] Suggest to destructure props when they are only used as members (#14993) //// - **[59ef28437](https://github.com/facebook/react/commit/59ef28437 )**: Warn about dependencies outside of render scope (#14990) //// - **[df7b4768c](https://github.com/facebook/react/commit/df7b4768c )**: [ESLint] Deduplicate suggested dependencies (#14982) //// - **[02404d793](https://github.com/facebook/react/commit/02404d793 )**: Avoid dynamic dispatch for scheduler calls (#14968) //// - **[bb2939ccc](https://github.com/facebook/react/commit/bb2939ccc )**: Support editable useState hooks in DevTools (#14906) //// - **[69060e1da](https://github.com/facebook/react/commit/69060e1da )**: Swap expect(ReactNoop) for expect(Scheduler) (#14971) //// - **[ccb2a8a44](https://github.com/facebook/react/commit/ccb2a8a44 )**: Replace test renderer's fake Scheduler implementation with mock build (#14970) //// - **[53e787b45](https://github.com/facebook/react/commit/53e787b45 )**: Replace noop's fake Scheduler implementation with mock Scheduler build (#14969) //// - **[3ada82b74](https://github.com/facebook/react/commit/3ada82b74 )**: Allow extraneous effect dependencies (#14967) //// - **[00748c53e](https://github.com/facebook/react/commit/00748c53e )**: Add new mock build of Scheduler with flush, yield API (#14964) //// - **[4186952a6](https://github.com/facebook/react/commit/4186952a6 )**: Fixed incompatibility between react-debug-tools and useContext() (#14940) //// - **[0b8efb229](https://github.com/facebook/react/commit/0b8efb229 )**: Allow omitting constant primitive deps (#14959) //// Changelog: [General][Changed] - React sync for revisions 8e25ed2...ec6691a Follow steps in the [React Native test plan](https://our.intern.facebook.com/intern/dex/react/test-workflows-react-native/). Reviewed By: shergin Differential Revision: D15171103 fbshipit-source-id: d16b54dfd575b3a1fa38e6a132633f42c715b4fd --- Libraries/Renderer/REVISION | 2 +- Libraries/Renderer/oss/ReactFabric-dev.js | 9972 +++++++++-------- Libraries/Renderer/oss/ReactFabric-prod.js | 5184 +++++---- .../Renderer/oss/ReactFabric-profiling.js | 5434 +++++---- .../Renderer/oss/ReactNativeRenderer-dev.js | 9868 ++++++++-------- .../Renderer/oss/ReactNativeRenderer-prod.js | 5177 +++++---- .../oss/ReactNativeRenderer-profiling.js | 5767 +++++----- Libraries/Renderer/shims/ReactNativeTypes.js | 4 +- Libraries/Renderer/shims/ReactTypes.js | 113 +- package.json | 6 +- yarn.lock | 38 +- 11 files changed, 21106 insertions(+), 20459 deletions(-) diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index b51f74404..7a8c0a1ac 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -8e25ed20bd27d126f670d04680db85209f779056 \ No newline at end of file +ec6691a68716bc59291746fc62f374a56fb435c9 \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index 3dbff8b08..5ea69a29f 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -26,10 +26,20 @@ var deepFreezeAndThrowOnMutationInDev = require("deepFreezeAndThrowOnMutationInD var TextInputState = require("TextInputState"); var FabricUIManager = require("FabricUIManager"); var checkPropTypes = require("prop-types/checkPropTypes"); +var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); -var scheduler = require("scheduler"); var ExceptionsManager = require("ExceptionsManager"); +// Do not require this module directly! Use a normal error constructor with +// template literal strings. The messages will be converted to ReactError during +// build, and in production they will be minified. + +function ReactError(message) { + var error = new Error(message); + error.name = "Invariant Violation"; + return error; +} + /** * Use invariant() to assert state which your program assumes to be true. * @@ -41,39 +51,237 @@ var ExceptionsManager = require("ExceptionsManager"); * will remain to ensure logic does not differ in production. */ -var validateFormat = function() {}; +/** + * Injectable ordering of event plugins. + */ +var eventPluginOrder = null; -{ - validateFormat = function(format) { - if (format === undefined) { - throw new Error("invariant requires an error message argument"); +/** + * Injectable mapping from names to event plugin modules. + */ +var namesToPlugins = {}; + +/** + * Recomputes the plugin list using the injected plugins and plugin ordering. + * + * @private + */ +function recomputePluginOrdering() { + if (!eventPluginOrder) { + // Wait until an `eventPluginOrder` is injected. + return; + } + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName]; + var pluginIndex = eventPluginOrder.indexOf(pluginName); + (function() { + if (!(pluginIndex > -1)) { + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." + ); + } + })(); + if (plugins[pluginIndex]) { + continue; } - }; + (function() { + if (!pluginModule.extractEvents) { + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); + } + })(); + plugins[pluginIndex] = pluginModule; + var publishedEvents = pluginModule.eventTypes; + for (var eventName in publishedEvents) { + (function() { + if ( + !publishEventForPlugin( + publishedEvents[eventName], + pluginModule, + eventName + ) + ) { + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); + } + })(); + } + } } -function invariant(condition, format, a, b, c, d, e, f) { - validateFormat(format); - - if (!condition) { - var error = void 0; - if (format === undefined) { - error = new Error( - "Minified exception occurred; use the non-minified dev environment " + - "for the full error message and additional helpful warnings." +/** + * Publishes an event so that it can be dispatched by the supplied plugin. + * + * @param {object} dispatchConfig Dispatch configuration for the event. + * @param {object} PluginModule Plugin publishing the event. + * @return {boolean} True if the event was successfully published. + * @private + */ +function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { + (function() { + if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName + + "`." ); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - error.name = "Invariant Violation"; } + })(); + eventNameDispatchConfigs[eventName] = dispatchConfig; - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + if (phasedRegistrationNames) { + for (var phaseName in phasedRegistrationNames) { + if (phasedRegistrationNames.hasOwnProperty(phaseName)) { + var phasedRegistrationName = phasedRegistrationNames[phaseName]; + publishRegistrationName( + phasedRegistrationName, + pluginModule, + eventName + ); + } + } + return true; + } else if (dispatchConfig.registrationName) { + publishRegistrationName( + dispatchConfig.registrationName, + pluginModule, + eventName + ); + return true; + } + return false; +} + +/** + * Publishes a registration name that is used to identify dispatched events. + * + * @param {string} registrationName Registration name to add. + * @param {object} PluginModule Plugin publishing the event. + * @private + */ +function publishRegistrationName(registrationName, pluginModule, eventName) { + (function() { + if (!!registrationNameModules[registrationName]) { + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); + } + })(); + registrationNameModules[registrationName] = pluginModule; + registrationNameDependencies[registrationName] = + pluginModule.eventTypes[eventName].dependencies; + + { + var lowerCasedName = registrationName.toLowerCase(); + } +} + +/** + * Registers plugins so that they can extract and dispatch events. + * + * @see {EventPluginHub} + */ + +/** + * Ordered list of injected plugins. + */ +var plugins = []; + +/** + * Mapping from event name to dispatch config + */ +var eventNameDispatchConfigs = {}; + +/** + * Mapping from registration name to plugin module + */ +var registrationNameModules = {}; + +/** + * Mapping from registration name to event name + */ +var registrationNameDependencies = {}; + +/** + * Mapping from lowercase registration names to the properly cased version, + * used to warn in the case of missing event handlers. Available + * only in true. + * @type {Object} + */ + +// Trust the developer to only use possibleRegistrationNames in true + +/** + * Injects an ordering of plugins (by plugin name). This allows the ordering + * to be decoupled from injection of the actual plugins so that ordering is + * always deterministic regardless of packaging, on-the-fly injection, etc. + * + * @param {array} InjectedEventPluginOrder + * @internal + * @see {EventPluginHub.injection.injectEventPluginOrder} + */ +function injectEventPluginOrder(injectedEventPluginOrder) { + (function() { + if (!!eventPluginOrder) { + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); + } + })(); + // Clone the ordering so it cannot be dynamically mutated. + eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); + recomputePluginOrdering(); +} + +/** + * Injects plugins to be used by `EventPluginHub`. The plugin names must be + * in the ordering injected by `injectEventPluginOrder`. + * + * Plugins can be injected as part of page initialization or on-the-fly. + * + * @param {object} injectedNamesToPlugins Map from names to plugin modules. + * @internal + * @see {EventPluginHub.injection.injectEventPluginsByName} + */ +function injectEventPluginsByName(injectedNamesToPlugins) { + var isOrderingDirty = false; + for (var pluginName in injectedNamesToPlugins) { + if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { + continue; + } + var pluginModule = injectedNamesToPlugins[pluginName]; + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + (function() { + if (!!namesToPlugins[pluginName]) { + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + } + })(); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = true; + } + } + if (isOrderingDirty) { + recomputePluginOrdering(); } } @@ -141,16 +349,13 @@ var invokeGuardedCallbackImpl = function( // when we call document.createEvent(). However this can cause confusing // errors: https://github.com/facebookincubator/create-react-app/issues/3482 // So we preemptively throw with a better message instead. - invariant( - typeof document !== "undefined", - "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." - ); + (function() { + if (!(typeof document !== "undefined")) { + throw ReactError( + "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." + ); + } + })(); var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We @@ -373,221 +578,13 @@ function clearCaughtError() { caughtError = null; return error; } else { - invariant( - false, - "clearCaughtError was called but no error was captured. This error " + - "is likely caused by a bug in React. Please file an issue." - ); - } -} - -/** - * Injectable ordering of event plugins. - */ -var eventPluginOrder = null; - -/** - * Injectable mapping from names to event plugin modules. - */ -var namesToPlugins = {}; - -/** - * Recomputes the plugin list using the injected plugins and plugin ordering. - * - * @private - */ -function recomputePluginOrdering() { - if (!eventPluginOrder) { - // Wait until an `eventPluginOrder` is injected. - return; - } - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName]; - var pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - pluginIndex > -1, - "EventPluginRegistry: Cannot inject event plugins that do not exist in " + - "the plugin ordering, `%s`.", - pluginName - ); - if (plugins[pluginIndex]) { - continue; - } - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` " + - "method, but `%s` does not.", - pluginName - ); - plugins[pluginIndex] = pluginModule; - var publishedEvents = pluginModule.eventTypes; - for (var eventName in publishedEvents) { - invariant( - publishEventForPlugin( - publishedEvents[eventName], - pluginModule, - eventName - ), - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); - } - } -} - -/** - * Publishes an event so that it can be dispatched by the supplied plugin. - * - * @param {object} dispatchConfig Dispatch configuration for the event. - * @param {object} PluginModule Plugin publishing the event. - * @return {boolean} True if the event was successfully published. - * @private - */ -function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName), - "EventPluginHub: More than one plugin attempted to publish the same " + - "event name, `%s`.", - eventName - ); - eventNameDispatchConfigs[eventName] = dispatchConfig; - - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - if (phasedRegistrationNames) { - for (var phaseName in phasedRegistrationNames) { - if (phasedRegistrationNames.hasOwnProperty(phaseName)) { - var phasedRegistrationName = phasedRegistrationNames[phaseName]; - publishRegistrationName( - phasedRegistrationName, - pluginModule, - eventName + (function() { + { + throw ReactError( + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); } - } - return true; - } else if (dispatchConfig.registrationName) { - publishRegistrationName( - dispatchConfig.registrationName, - pluginModule, - eventName - ); - return true; - } - return false; -} - -/** - * Publishes a registration name that is used to identify dispatched events. - * - * @param {string} registrationName Registration name to add. - * @param {object} PluginModule Plugin publishing the event. - * @private - */ -function publishRegistrationName(registrationName, pluginModule, eventName) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same " + - "registration name, `%s`.", - registrationName - ); - registrationNameModules[registrationName] = pluginModule; - registrationNameDependencies[registrationName] = - pluginModule.eventTypes[eventName].dependencies; - - { - var lowerCasedName = registrationName.toLowerCase(); - } -} - -/** - * Registers plugins so that they can extract and dispatch events. - * - * @see {EventPluginHub} - */ - -/** - * Ordered list of injected plugins. - */ -var plugins = []; - -/** - * Mapping from event name to dispatch config - */ -var eventNameDispatchConfigs = {}; - -/** - * Mapping from registration name to plugin module - */ -var registrationNameModules = {}; - -/** - * Mapping from registration name to event name - */ -var registrationNameDependencies = {}; - -/** - * Mapping from lowercase registration names to the properly cased version, - * used to warn in the case of missing event handlers. Available - * only in true. - * @type {Object} - */ - -// Trust the developer to only use possibleRegistrationNames in true - -/** - * Injects an ordering of plugins (by plugin name). This allows the ordering - * to be decoupled from injection of the actual plugins so that ordering is - * always deterministic regardless of packaging, on-the-fly injection, etc. - * - * @param {array} InjectedEventPluginOrder - * @internal - * @see {EventPluginHub.injection.injectEventPluginOrder} - */ -function injectEventPluginOrder(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than " + - "once. You are likely trying to load more than one copy of React." - ); - // Clone the ordering so it cannot be dynamically mutated. - eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); - recomputePluginOrdering(); -} - -/** - * Injects plugins to be used by `EventPluginHub`. The plugin names must be - * in the ordering injected by `injectEventPluginOrder`. - * - * Plugins can be injected as part of page initialization or on-the-fly. - * - * @param {object} injectedNamesToPlugins Map from names to plugin modules. - * @internal - * @see {EventPluginHub.injection.injectEventPluginsByName} - */ -function injectEventPluginsByName(injectedNamesToPlugins) { - var isOrderingDirty = false; - for (var pluginName in injectedNamesToPlugins) { - if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { - continue; - } - var pluginModule = injectedNamesToPlugins[pluginName]; - if ( - !namesToPlugins.hasOwnProperty(pluginName) || - namesToPlugins[pluginName] !== pluginModule - ) { - invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins " + - "using the same name, `%s`.", - pluginName - ); - namesToPlugins[pluginName] = pluginModule; - isOrderingDirty = true; - } - } - if (isOrderingDirty) { - recomputePluginOrdering(); + })(); } } @@ -796,10 +793,11 @@ function executeDirectDispatch(event) { } var dispatchListener = event._dispatchListeners; var dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + (function() { + if (!!Array.isArray(dispatchListener)) { + throw ReactError("executeDirectDispatch(...): Invalid `event`."); + } + })(); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -832,10 +830,13 @@ function hasDispatches(event) { */ function accumulateInto(current, next) { - invariant( - next != null, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + (function() { + if (!(next != null)) { + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + } + })(); if (current == null) { return next; @@ -902,6 +903,32 @@ var executeDispatchesAndReleaseTopLevel = function(e) { return executeDispatchesAndRelease(e); }; +function runEventsInBatch(events) { + if (events !== null) { + eventQueue = accumulateInto(eventQueue, events); + } + + // Set `eventQueue` to null before processing it so that we can tell if more + // events get enqueued while processing. + var processingEventQueue = eventQueue; + eventQueue = null; + + if (!processingEventQueue) { + return; + } + + forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); + (function() { + if (!!eventQueue) { + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + } + })(); + // This would be a good time to rethrow if any of the event handlers threw. + rethrowCaughtError(); +} + function isInteractive(tag) { return ( tag === "button" || @@ -992,12 +1019,17 @@ function getListener(inst, registrationName) { if (shouldPreventMouseEvent(registrationName, inst.type, props)) { return null; } - invariant( - !listener || typeof listener === "function", - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + (function() { + if (!(!listener || typeof listener === "function")) { + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } + })(); return listener; } @@ -1008,7 +1040,7 @@ function getListener(inst, registrationName) { * @return {*} An accumulation of synthetic events. * @internal */ -function extractEvents( +function extractPluginEvents( topLevelType, targetInst, nativeEvent, @@ -1033,37 +1065,13 @@ function extractEvents( return events; } -function runEventsInBatch(events) { - if (events !== null) { - eventQueue = accumulateInto(eventQueue, events); - } - - // Set `eventQueue` to null before processing it so that we can tell if more - // events get enqueued while processing. - var processingEventQueue = eventQueue; - eventQueue = null; - - if (!processingEventQueue) { - return; - } - - forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing " + - "an event queue. Support for this has not yet been implemented." - ); - // This would be a good time to rethrow if any of the event handlers threw. - rethrowCaughtError(); -} - -function runExtractedEventsInBatch( +function runExtractedPluginEventsInBatch( topLevelType, targetInst, nativeEvent, nativeEventTarget ) { - var events = extractEvents( + var events = extractPluginEvents( topLevelType, targetInst, nativeEvent, @@ -1091,6 +1099,8 @@ var SimpleMemoComponent = 15; var LazyComponent = 16; var IncompleteClassComponent = 17; var DehydratedSuspenseComponent = 18; +var EventComponent = 19; +var EventTarget = 20; function getParent(inst) { do { @@ -1609,10 +1619,13 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { function releasePooledEvent(event) { var EventConstructor = this; - invariant( - event instanceof EventConstructor, - "Trying to release an event instance into a pool of a different type." - ); + (function() { + if (!(event instanceof EventConstructor)) { + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); + } + })(); event.destructor(); if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { EventConstructor.eventPool.push(event); @@ -1719,7 +1732,11 @@ function resetTouchRecord(touchRecord, touch) { function getTouchIdentifier(_ref) { var identifier = _ref.identifier; - invariant(identifier != null, "Touch object is missing identifier."); + (function() { + if (!(identifier != null)) { + throw ReactError("Touch object is missing identifier."); + } + })(); { !(identifier <= MAX_TOUCH_BANK) ? warningWithoutStack$1( @@ -1847,10 +1864,13 @@ var ResponderTouchHistoryStore = { * @return {*|array<*>} An accumulation of items. */ function accumulate(current, next) { - invariant( - next != null, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + (function() { + if (!(next != null)) { + throw ReactError( + "accumulate(...): Accumulated items must not be null or undefined." + ); + } + })(); if (current == null) { return next; @@ -2462,11 +2482,13 @@ var ReactNativeBridgeEventPlugin = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType]; var directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + (function() { + if (!(bubbleDispatchConfig || directDispatchConfig)) { + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); + } + })(); var event = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -2516,7 +2538,11 @@ function getInstanceFromInstance(instanceHandle) { function getTagFromInstance(inst) { var tag = inst.stateNode.canonical._nativeTag; - invariant(tag, "All native instances should have a tag."); + (function() { + if (!tag) { + throw ReactError("All native instances should have a tag."); + } + })(); return tag; } @@ -2605,6 +2631,17 @@ var REACT_FORWARD_REF_TYPE = hasSymbol var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_EVENT_COMPONENT_TYPE = hasSymbol + ? Symbol.for("react.event_component") + : 0xead5; +var REACT_EVENT_TARGET_TYPE = hasSymbol + ? Symbol.for("react.event_target") + : 0xead6; + +// React event targets +var REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol + ? Symbol.for("react.event_target.touch_hit") + : 0xead7; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2630,6 +2667,22 @@ function refineResolvedLazyComponent(lazyComponent) { return lazyComponent._status === Resolved ? lazyComponent._result : null; } +var debugRenderPhaseSideEffects = false; +var debugRenderPhaseSideEffectsForStrictMode = false; +var enableUserTimingAPI = true; +var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; +var warnAboutDeprecatedLifecycles = true; +var enableProfilerTimer = true; +var enableSchedulerTracing = true; +var enableSuspenseServerRenderer = false; + +var disableYielding = false; + +var warnAboutDeprecatedSetNativeProps = false; +var enableEventAPI = false; + +// Only used in www builds. + function getWrappedName(outerType, innerType, wrapperName) { var functionName = innerType.displayName || innerType.name || ""; return ( @@ -2688,6 +2741,29 @@ function getComponentName(type) { if (resolvedThenable) { return getComponentName(resolvedThenable); } + break; + } + case REACT_EVENT_COMPONENT_TYPE: { + if (enableEventAPI) { + var eventComponent = type; + var displayName = eventComponent.displayName; + if (displayName !== undefined) { + return displayName; + } + } + break; + } + case REACT_EVENT_TARGET_TYPE: { + if (enableEventAPI) { + var eventTarget = type; + if (eventTarget.type === REACT_EVENT_TARGET_TOUCH_HIT) { + return "TouchHitTarget"; + } + var _displayName = eventTarget.displayName; + if (_displayName !== undefined) { + return _displayName; + } + } } } } @@ -2787,10 +2863,11 @@ function isMounted(component) { } function assertIsMounted(fiber) { - invariant( - isFiberMountedImpl(fiber) === MOUNTED, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(isFiberMountedImpl(fiber) === MOUNTED)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } function findCurrentFiberUsingSlowPath(fiber) { @@ -2798,10 +2875,11 @@ function findCurrentFiberUsingSlowPath(fiber) { if (!alternate) { // If there is no alternate, then we only need to check if it is mounted. var state = isFiberMountedImpl(fiber); - invariant( - state !== UNMOUNTED, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(state !== UNMOUNTED)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); if (state === MOUNTING) { return null; } @@ -2814,11 +2892,24 @@ function findCurrentFiberUsingSlowPath(fiber) { var b = alternate; while (true) { var parentA = a.return; - var parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) { + if (parentA === null) { // We're at the root. break; } + var parentB = parentA.alternate; + if (parentB === null) { + // There is no alternate. This is an unusual case. Currently, it only + // happens when a Suspense component is hidden. An extra fragment fiber + // is inserted in between the Suspense fiber and its children. Skip + // over this extra fragment fiber and proceed to the next parent. + var nextParent = parentA.return; + if (nextParent !== null) { + a = b = nextParent; + continue; + } + // If there's no parent, we're at the root. + break; + } // If both copies of the parent fiber point to the same child, we can // assume that the child is current. This happens when we bailout on low @@ -2840,7 +2931,11 @@ function findCurrentFiberUsingSlowPath(fiber) { } // We should never have an alternate for any mounting node. So the only // way this could possibly happen is if this was unmounted, if at all. - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } if (a.return !== b.return) { @@ -2891,26 +2986,31 @@ function findCurrentFiberUsingSlowPath(fiber) { } _child = _child.sibling; } - invariant( - didFindChild, - "Child was not found in either parent set. This indicates a bug " + - "in React related to the return pointer. Please file an issue." - ); + (function() { + if (!didFindChild) { + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); + } + })(); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(a.alternate === b)) { + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // If the root is not a host container, we're in a disconnected tree. I.e. // unmounted. - invariant( - a.tag === HostRoot, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(a.tag === HostRoot)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); if (a.stateNode.current === a) { // We've determined that A is the current branch. return fiber; @@ -3457,66 +3557,6 @@ function diff(prevProps, nextProps, validAttributes) { ); } -var hasNativePerformanceNow = - typeof performance === "object" && typeof performance.now === "function"; - -var now$1 = hasNativePerformanceNow - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }; - -var scheduledCallback = null; -var frameDeadline = 0; - -function setTimeoutCallback() { - // TODO (bvaughn) Hard-coded 5ms unblocks initial async testing. - // React API probably changing to boolean rather than time remaining. - // Longer-term plan is to rewrite this using shared memory, - // And just return the value of the bit as the boolean. - frameDeadline = now$1() + 5; - - var callback = scheduledCallback; - scheduledCallback = null; - if (callback !== null) { - callback(); - } -} - -// RN has a poor polyfill for requestIdleCallback so we aren't using it. -// This implementation is only intended for short-term use anyway. -// We also don't implement cancel functionality b'c Fiber doesn't currently need it. -function scheduleDeferredCallback$1(callback, options) { - // We assume only one callback is scheduled at a time b'c that's how Fiber works. - scheduledCallback = callback; - var timeoutId = setTimeout(setTimeoutCallback, 1); - return timeoutId; // Timeouts are always numbers on RN -} - -function cancelDeferredCallback$1(callbackID) { - scheduledCallback = null; - clearTimeout(callbackID); // Timeouts are always numbers on RN -} - -function shouldYield$1() { - return frameDeadline <= now$1(); -} - -var debugRenderPhaseSideEffects = false; -var debugRenderPhaseSideEffectsForStrictMode = false; -var enableUserTimingAPI = true; -var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; -var warnAboutDeprecatedLifecycles = false; -var enableProfilerTimer = true; -var enableSchedulerTracing = true; -var enableSuspenseServerRenderer = false; - -var warnAboutDeprecatedSetNativeProps = false; - -// Only used in www builds. - // Use to restore controlled state after a change event has fired. var restoreImpl = null; @@ -3531,11 +3571,13 @@ function restoreStateOfTarget(target) { // Unmounted return; } - invariant( - typeof restoreImpl === "function", - "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." - ); + (function() { + if (!(typeof restoreImpl === "function")) { + throw ReactError( + "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." + ); + } + })(); var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); restoreImpl(internalInstance.stateNode, internalInstance.type, props); } @@ -3612,7 +3654,7 @@ function setBatchingImplementation( function dispatchEvent(target, topLevelType, nativeEvent) { var targetFiber = target; batchedUpdates(function() { - runExtractedEventsInBatch( + runExtractedPluginEventsInBatch( topLevelType, targetFiber, nativeEvent, @@ -3627,12 +3669,13 @@ function dispatchEvent(target, topLevelType, nativeEvent) { // can re-export everything from this module. function shim() { - invariant( - false, - "The current renderer does not support mutation. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + (function() { + { + throw ReactError( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // Mutation (when unsupported) @@ -3656,12 +3699,13 @@ var unhideTextInstance = shim; // can re-export everything from this module. function shim$1() { - invariant( - false, - "The current renderer does not support hydration. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + (function() { + { + throw ReactError( + "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // Hydration (when unsupported) @@ -3717,12 +3761,18 @@ if (FabricUIManager.registerEventHandler) { */ var ReactFabricHostComponent = (function() { - function ReactFabricHostComponent(tag, viewConfig, props) { + function ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ) { _classCallCheck(this, ReactFabricHostComponent); this._nativeTag = tag; this.viewConfig = viewConfig; this.currentProps = props; + this._internalInstanceHandle = internalInstanceHandle; } ReactFabricHostComponent.prototype.blur = function blur() { @@ -3733,30 +3783,42 @@ var ReactFabricHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; - ReactFabricHostComponent.prototype.measure = function measure(callback) { - UIManager.measure( - this._nativeTag, + ReactFabricHostComponent.prototype.measure = function measure$$1(callback) { + FabricUIManager.measure( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; - ReactFabricHostComponent.prototype.measureInWindow = function measureInWindow( + ReactFabricHostComponent.prototype.measureInWindow = function measureInWindow$$1( callback ) { - UIManager.measureInWindow( - this._nativeTag, + FabricUIManager.measureInWindow( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; - ReactFabricHostComponent.prototype.measureLayout = function measureLayout( + ReactFabricHostComponent.prototype.measureLayout = function measureLayout$$1( relativeToNativeNode, onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - this._nativeTag, - relativeToNativeNode, + if ( + typeof relativeToNativeNode === "number" || + !(relativeToNativeNode instanceof ReactFabricHostComponent) + ) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a ref to a native component." + ); + + return; + } + + FabricUIManager.measureLayout( + this._internalInstanceHandle.stateNode.node, + relativeToNativeNode._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); @@ -3765,31 +3827,12 @@ var ReactFabricHostComponent = (function() { ReactFabricHostComponent.prototype.setNativeProps = function setNativeProps( nativeProps ) { - { - if (warnAboutDeprecatedSetNativeProps) { - warningWithoutStack$1( - false, - "Warning: Calling ref.setNativeProps(nativeProps) " + - "is deprecated and will be removed in a future release. " + - "Use the setNativeProps export from the react-native package instead." + - "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" - ); - } - warnForStyleProps(nativeProps, this.viewConfig.validAttributes); - } + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); - var updatePayload = create(nativeProps, this.viewConfig.validAttributes); - - // Avoid the overhead of bridge calls if there's no update. - // This is an expensive no-op for Android, and causes an unnecessary - // view invalidation for certain components (eg RCTTextInput) on iOS. - if (updatePayload != null) { - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - updatePayload - ); - } + return; }; return ReactFabricHostComponent; @@ -3819,11 +3862,6 @@ function createInstance( } } - invariant( - type !== "RCTView" || !hostContext.isInAParentText, - "Nesting of within is not currently supported." - ); - var updatePayload = create(props, viewConfig.validAttributes); var node = FabricUIManager.createNode( @@ -3834,7 +3872,12 @@ function createInstance( internalInstanceHandle // internalInstanceHandle ); - var component = new ReactFabricHostComponent(tag, viewConfig, props); + var component = new ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ); return { node: node, @@ -3848,10 +3891,13 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - invariant( - hostContext.isInAParentText, - "Text strings must be rendered within a component." - ); + (function() { + if (!hostContext.isInAParentText) { + throw ReactError( + "Text strings must be rendered within a component." + ); + } + })(); var tag = nextReactTag; nextReactTag += 2; @@ -3899,6 +3945,16 @@ function getChildHostContext(parentHostContext, type, rootContainerInstance) { } } +function getChildHostContextForEventComponent(parentHostContext) { + // TODO: add getChildHostContextForEventComponent implementation + return parentHostContext; +} + +function getChildHostContextForEventTarget(parentHostContext, type) { + // TODO: add getChildHostContextForEventTarget implementation + return parentHostContext; +} + function getPublicInstance(instance) { return instance.canonical; } @@ -3944,16 +4000,10 @@ function shouldSetTextContent(type, props) { // The Fabric renderer is secondary to the existing React Native renderer. var isPrimaryRenderer = false; -var now$$1 = now$1; -var scheduleDeferredCallback$$1 = scheduleDeferredCallback$1; -var cancelDeferredCallback$$1 = cancelDeferredCallback$1; -var shouldYield$$1 = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; var noTimeout = -1; -var schedulePassiveEffects = scheduleDeferredCallback$$1; -var cancelPassiveEffects = cancelDeferredCallback$$1; // ------------------- // Persistence @@ -4008,26 +4058,7 @@ function cloneHiddenInstance(instance, type, props, internalInstanceHandle) { }; } -function cloneUnhiddenInstance(instance, type, props, internalInstanceHandle) { - var viewConfig = instance.canonical.viewConfig; - var node = instance.node; - var updatePayload = diff( - Object.assign({}, props, { style: [props.style, { display: "none" }] }), - props, - viewConfig.validAttributes - ); - return { - node: FabricUIManager.cloneNodeWithNewProps(node, updatePayload), - canonical: instance.canonical - }; -} - -function createHiddenTextInstance( - text, - rootContainerInstance, - hostContext, - internalInstanceHandle -) { +function cloneHiddenTextInstance(instance, text, internalInstanceHandle) { throw new Error("Not yet implemented."); } @@ -4043,6 +4074,35 @@ function finalizeContainerChildren(container, newChildren) { FabricUIManager.completeRoot(container, newChildren); } +function mountEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function updateEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function unmountEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function getEventTargetChildElement(type, props) { + throw new Error("Not yet implemented."); +} + +function handleEventTarget( + type, + props, + rootContainerInstance, + internalInstanceHandle +) { + throw new Error("Not yet implemented."); +} + +function commitEventTarget(type, props, instance, parentInstance) { + throw new Error("Not yet implemented."); +} + var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -4356,15 +4416,15 @@ function startRequestCallbackTimer() { } } -function stopRequestCallbackTimer(didExpire, expirationTime) { +function stopRequestCallbackTimer(didExpire) { if (enableUserTimingAPI) { if (supportsUserTiming) { isWaitingForCallback = false; - var warning = didExpire ? "React was blocked by main thread" : null; + var warning = didExpire + ? "Update expired; will flush synchronously" + : null; endMark( - "(Waiting for async callback... will force flush in " + - expirationTime + - " ms)", + "(Waiting for async callback...)", "(Waiting for async callback...)", warning ); @@ -4666,25 +4726,6 @@ function push(cursor, value, fiber) { cursor.current = value; } -function checkThatStackIsEmpty() { - { - if (index !== -1) { - warningWithoutStack$1( - false, - "Expected an empty stack. Something was not reset properly." - ); - } - } -} - -function resetStackAfterFatalErrorInDev() { - { - index = -1; - valueStack.length = 0; - fiberStack.length = 0; - } -} - var warnedAboutMissingGetChildContext = void 0; { @@ -4789,11 +4830,13 @@ function popTopLevelContextObject(fiber) { } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(contextStackCursor.current === emptyContextObject)) { + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); @@ -4835,12 +4878,16 @@ function processChildContext(fiber, type, parentContext) { setCurrentPhase(null); } for (var contextKey in childContext) { - invariant( - contextKey in childContextTypes, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + (function() { + if (!(contextKey in childContextTypes)) { + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); + } + })(); } { var name = getComponentName(type) || "Unknown"; @@ -4885,11 +4932,13 @@ function pushContextProvider(workInProgress) { function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!instance) { + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); if (didChange) { // Merge parent and own context. @@ -4918,11 +4967,13 @@ function invalidateContextProvider(workInProgress, type, didChange) { function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere - invariant( - isFiberMounted(fiber) && fiber.tag === ClassComponent, - "Expected subtree parent to be a mounted class component. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var node = fiber; do { @@ -4939,11 +4990,13 @@ function findCurrentUnmaskedContext(fiber) { } node = node.return; } while (node !== null); - invariant( - false, - "Found unexpected detached subtree parent. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var onCommitFiberRoot = null; @@ -5031,14 +5084,198 @@ function onCommitUnmount(fiber) { // Max 31 bit integer. The max integer size in V8 for 32-bit systems. // Math.pow(2, 30) - 1 // 0b111111111111111111111111111111 -var maxSigned31BitInt = 1073741823; +var MAX_SIGNED_31_BIT_INT = 1073741823; + +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority; +var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback; +var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback; +var Scheduler_shouldYield = Scheduler.unstable_shouldYield; +var Scheduler_now = Scheduler.unstable_now; +var Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel; +var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority; +var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; +var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority; +var Scheduler_LowPriority = Scheduler.unstable_LowPriority; +var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; + +if (enableSchedulerTracing) { + // Provide explicit error message when production+profiling bundle of e.g. + // react-dom is used with production (non-profiling) bundle of + // scheduler/tracing + (function() { + if ( + !( + tracing.__interactionsRef != null && + tracing.__interactionsRef.current != null + ) + ) { + throw ReactError( + "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 http://fb.me/react-profiling" + ); + } + })(); +} + +var fakeCallbackNode = {}; + +// Except for NoPriority, these correspond to Scheduler priorities. We use +// ascending numbers so we can compare them like numbers. They start at 90 to +// avoid clashing with Scheduler's priorities. +var ImmediatePriority = 99; +var UserBlockingPriority = 98; +var NormalPriority = 97; +var LowPriority = 96; +var IdlePriority = 95; +// NoPriority is the absence of priority. Also React-only. + +var shouldYield = disableYielding + ? function() { + return false; + } // Never yield when `disableYielding` is on + : Scheduler_shouldYield; + +var immediateQueue = null; +var immediateQueueCallbackNode = null; +var isFlushingImmediate = false; +var initialTimeMs = Scheduler_now(); + +// If the initial timestamp is reasonably small, use Scheduler's `now` directly. +// This will be the case for modern browsers that support `performance.now`. In +// older browsers, Scheduler falls back to `Date.now`, which returns a Unix +// timestamp. In that case, subtract the module initialization time to simulate +// the behavior of performance.now and keep our times small enough to fit +// within 32 bits. +// TODO: Consider lifting this into Scheduler. +var now = + initialTimeMs < 10000 + ? Scheduler_now + : function() { + return Scheduler_now() - initialTimeMs; + }; + +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return ImmediatePriority; + case Scheduler_UserBlockingPriority: + return UserBlockingPriority; + case Scheduler_NormalPriority: + return NormalPriority; + case Scheduler_LowPriority: + return LowPriority; + case Scheduler_IdlePriority: + return IdlePriority; + default: + (function() { + { + throw ReactError("Unknown priority level."); + } + })(); + } +} + +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case ImmediatePriority: + return Scheduler_ImmediatePriority; + case UserBlockingPriority: + return Scheduler_UserBlockingPriority; + case NormalPriority: + return Scheduler_NormalPriority; + case LowPriority: + return Scheduler_LowPriority; + case IdlePriority: + return Scheduler_IdlePriority; + default: + (function() { + { + throw ReactError("Unknown priority level."); + } + })(); + } +} + +function runWithPriority(reactPriorityLevel, fn) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(priorityLevel, fn); +} + +function scheduleCallback(reactPriorityLevel, callback, options) { + if (reactPriorityLevel === ImmediatePriority) { + // Push this callback into an internal queue. We'll flush these either in + // the next tick, or earlier if something calls `flushImmediateQueue`. + if (immediateQueue === null) { + immediateQueue = [callback]; + // Flush the queue in the next tick, at the earliest. + immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueueImpl + ); + } else { + // Push onto existing queue. Don't need to schedule a callback because + // we already scheduled one when we created the queue. + immediateQueue.push(callback); + } + return fakeCallbackNode; + } + // Otherwise pass through to Scheduler. + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(priorityLevel, callback, options); +} + +function cancelCallback(callbackNode) { + if (callbackNode !== fakeCallbackNode) { + Scheduler_cancelCallback(callbackNode); + } +} + +function flushImmediateQueue() { + if (immediateQueueCallbackNode !== null) { + Scheduler_cancelCallback(immediateQueueCallbackNode); + } + flushImmediateQueueImpl(); +} + +function flushImmediateQueueImpl() { + if (!isFlushingImmediate && immediateQueue !== null) { + // Prevent re-entrancy. + isFlushingImmediate = true; + var i = 0; + try { + var _isSync = true; + for (; i < immediateQueue.length; i++) { + var callback = immediateQueue[i]; + do { + callback = callback(_isSync); + } while (callback !== null); + } + immediateQueue = null; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (immediateQueue !== null) { + immediateQueue = immediateQueue.slice(i + 1); + } + // Resume flushing in the next tick + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueue + ); + throw error; + } finally { + isFlushingImmediate = false; + } + } +} var NoWork = 0; var Never = 1; -var Sync = maxSigned31BitInt; +var Sync = MAX_SIGNED_31_BIT_INT; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; +var MAGIC_NUMBER_OFFSET = MAX_SIGNED_31_BIT_INT - 1; // 1 unit of expiration time represents 10ms. function msToExpirationTime(ms) { @@ -5064,6 +5301,8 @@ function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { ); } +// TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update +// the names to reflect. var LOW_PRIORITY_EXPIRATION = 5000; var LOW_PRIORITY_BATCH_SIZE = 250; @@ -5075,6 +5314,12 @@ function computeAsyncExpiration(currentTime) { ); } +// Same as computeAsyncExpiration but without the bucketing logic. This is +// used to compute timestamps instead of actual expiration times. +function computeAsyncExpirationNoBucket(currentTime) { + return currentTime - LOW_PRIORITY_EXPIRATION / UNIT_SIZE; +} + // We intentionally set a higher expiration time for interactive updates in // dev than in production. // @@ -5097,6 +5342,31 @@ function computeInteractiveExpiration(currentTime) { ); } +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (expirationTime === Sync) { + return ImmediatePriority; + } + if (expirationTime === Never) { + return IdlePriority; + } + var msUntil = + expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime); + if (msUntil <= 0) { + return ImmediatePriority; + } + if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { + return UserBlockingPriority; + } + if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { + return NormalPriority; + } + + // TODO: Handle LowPriority + + // Assume anything lower has idle priority + return IdlePriority; +} + var NoContext = 0; var ConcurrentMode = 1; var StrictMode = 2; @@ -5198,6 +5468,7 @@ function FiberNode(tag, pendingProps, key, mode) { this._debugSource = null; this._debugOwner = null; this._debugIsCurrentlyTiming = false; + this._debugHookTypes = null; if (!hasBadMapPolyfill && typeof Object.preventExtensions === "function") { Object.preventExtensions(this); } @@ -5274,6 +5545,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { workInProgress._debugID = current._debugID; workInProgress._debugSource = current._debugSource; workInProgress._debugOwner = current._debugOwner; + workInProgress._debugHookTypes = current._debugHookTypes; } workInProgress.alternate = current; @@ -5401,6 +5673,28 @@ function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; + case REACT_EVENT_COMPONENT_TYPE: + if (enableEventAPI) { + return createFiberFromEventComponent( + type, + pendingProps, + mode, + expirationTime, + key + ); + } + break; + case REACT_EVENT_TARGET_TYPE: + if (enableEventAPI) { + return createFiberFromEventTarget( + type, + pendingProps, + mode, + expirationTime, + key + ); + } + break; } } var info = ""; @@ -5421,14 +5715,16 @@ function createFiberFromTypeAndProps( info += "\n\nCheck the render method of `" + ownerName + "`."; } } - invariant( - false, - "Element type is invalid: expected a string (for built-in " + - "components) or a class/function (for composite components) " + - "but got: %s.%s", - type == null ? type : typeof type, - info - ); + (function() { + { + throw ReactError( + "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 + ); + } + })(); } } } @@ -5470,6 +5766,38 @@ function createFiberFromFragment(elements, mode, expirationTime, key) { return fiber; } +function createFiberFromEventComponent( + eventComponent, + pendingProps, + mode, + expirationTime, + key +) { + var fiber = createFiber(EventComponent, pendingProps, key, mode); + fiber.elementType = eventComponent; + fiber.type = eventComponent; + fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromEventTarget( + eventTarget, + pendingProps, + mode, + expirationTime, + key +) { + var fiber = createFiber(EventTarget, pendingProps, key, mode); + fiber.elementType = eventTarget; + fiber.type = eventTarget; + fiber.expirationTime = expirationTime; + // Store latest props + fiber.stateNode = { + props: pendingProps + }; + return fiber; +} + function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { { if ( @@ -5592,6 +5920,7 @@ function assignFiberPropertiesInDEV(target, source) { target._debugSource = source._debugSource; target._debugOwner = source._debugOwner; target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; + target._debugHookTypes = source._debugHookTypes; return target; } @@ -5608,81 +5937,131 @@ function assignFiberPropertiesInDEV(target, source) { // The types are defined separately within this file to ensure they stay in sync. // (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.) +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pendingChildren = null; + this.pingCache = null; + this.pendingCommitExpirationTime = NoWork; + this.finishedWork = null; + this.timeoutHandle = noTimeout; + this.context = null; + this.pendingContext = null; + this.hydrate = hydrate; + this.firstBatch = null; + this.callbackNode = null; + this.callbackExpirationTime = NoWork; + this.firstPendingTime = NoWork; + this.lastPendingTime = NoWork; + this.pingTime = NoWork; + + if (enableSchedulerTracing) { + this.interactionThreadID = tracing.unstable_getThreadID(); + this.memoizedInteractions = new Set(); + this.pendingInteractionMap = new Map(); + } +} + function createFiberRoot(containerInfo, isConcurrent, hydrate) { + var root = new FiberRootNode(containerInfo, hydrate); + // Cyclic construction. This cheats the type system right now because // stateNode is any. var uninitializedFiber = createHostRootFiber(isConcurrent); - - var root = void 0; - if (enableSchedulerTracing) { - root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, - - pingCache: null, - - didError: false, - - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null, - - interactionThreadID: tracing.unstable_getThreadID(), - memoizedInteractions: new Set(), - pendingInteractionMap: new Map() - }; - } else { - root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - - pingCache: null, - - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, - - didError: false, - - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null - }; - } - + root.current = uninitializedFiber; uninitializedFiber.stateNode = root; - // The reason for the way the Flow types are structured in this file, - // Is to avoid needing :any casts everywhere interaction tracing fields are used. - // Unfortunately that requires an :any cast for non-interaction tracing capable builds. - // $FlowFixMe Remove this :any cast and replace it with something better. return root; } +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = warningWithoutStack$1; + +{ + warning = function(condition, format) { + if (condition) { + return; + } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + // eslint-disable-next-line react-internal/warning-and-invariant-args + + for ( + var _len = arguments.length, + args = Array(_len > 2 ? _len - 2 : 0), + _key = 2; + _key < _len; + _key++ + ) { + args[_key - 2] = arguments[_key]; + } + + warningWithoutStack$1.apply( + undefined, + [false, format + "%s"].concat(args, [stack]) + ); + }; +} + +var warning$1 = warning; + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + return ( + (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare + ); +} + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Performs equality by iterating through keys on an object and returning false + * when any key has values which are not strictly equal between the arguments. + * Returns true when the values of all keys are strictly equal. + */ +function shallowEqual(objA, objB) { + if (is(objA, objB)) { + return true; + } + + if ( + typeof objA !== "object" || + objA === null || + typeof objB !== "object" || + objB === null + ) { + return false; + } + + var keysA = Object.keys(objA); + var keysB = Object.keys(objB); + + if (keysA.length !== keysB.length) { + return false; + } + + // Test for A's keys different from B. + for (var i = 0; i < keysA.length; i++) { + if ( + !hasOwnProperty.call(objB, keysA[i]) || + !is(objA[keysA[i]], objB[keysA[i]]) + ) { + return false; + } + } + + return true; +} + /** * Forked from fbjs/warning: * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js @@ -6082,349 +6461,6 @@ var ReactStrictModeWarnings = { }; } -// This lets us hook into Fiber to debug what it's doing. -// See https://github.com/facebook/react/pull/8033. -// This is not part of the public API, not even for React DevTools. -// You may only inject a debugTool if you work on React Fiber itself. -var ReactFiberInstrumentation = { - debugTool: null -}; - -var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; - -// TODO: Offscreen updates should never suspend. However, a promise that -// suspended inside an offscreen subtree should be able to ping at the priority -// of the outer render. - -function markPendingPriorityLevel(root, expirationTime) { - // If there's a gap between completing a failed root and retrying it, - // additional updates may be scheduled. Clear `didError`, in case the update - // is sufficient to fix the error. - root.didError = false; - - // Update the latest and earliest pending times - var earliestPendingTime = root.earliestPendingTime; - if (earliestPendingTime === NoWork) { - // No other pending updates. - root.earliestPendingTime = root.latestPendingTime = expirationTime; - } else { - if (earliestPendingTime < expirationTime) { - // This is the earliest pending update. - root.earliestPendingTime = expirationTime; - } else { - var latestPendingTime = root.latestPendingTime; - if (latestPendingTime > expirationTime) { - // This is the latest pending update - root.latestPendingTime = expirationTime; - } - } - } - findNextExpirationTimeToWorkOn(expirationTime, root); -} - -function markCommittedPriorityLevels(root, earliestRemainingTime) { - root.didError = false; - - if (earliestRemainingTime === NoWork) { - // Fast path. There's no remaining work. Clear everything. - root.earliestPendingTime = NoWork; - root.latestPendingTime = NoWork; - root.earliestSuspendedTime = NoWork; - root.latestSuspendedTime = NoWork; - root.latestPingedTime = NoWork; - findNextExpirationTimeToWorkOn(NoWork, root); - return; - } - - if (earliestRemainingTime < root.latestPingedTime) { - root.latestPingedTime = NoWork; - } - - // Let's see if the previous latest known pending level was just flushed. - var latestPendingTime = root.latestPendingTime; - if (latestPendingTime !== NoWork) { - if (latestPendingTime > earliestRemainingTime) { - // We've flushed all the known pending levels. - root.earliestPendingTime = root.latestPendingTime = NoWork; - } else { - var earliestPendingTime = root.earliestPendingTime; - if (earliestPendingTime > earliestRemainingTime) { - // We've flushed the earliest known pending level. Set this to the - // latest pending time. - root.earliestPendingTime = root.latestPendingTime; - } - } - } - - // Now let's handle the earliest remaining level in the whole tree. We need to - // decide whether to treat it as a pending level or as suspended. Check - // it falls within the range of known suspended levels. - - var earliestSuspendedTime = root.earliestSuspendedTime; - if (earliestSuspendedTime === NoWork) { - // There's no suspended work. Treat the earliest remaining level as a - // pending level. - markPendingPriorityLevel(root, earliestRemainingTime); - findNextExpirationTimeToWorkOn(NoWork, root); - return; - } - - var latestSuspendedTime = root.latestSuspendedTime; - if (earliestRemainingTime < latestSuspendedTime) { - // The earliest remaining level is later than all the suspended work. That - // means we've flushed all the suspended work. - root.earliestSuspendedTime = NoWork; - root.latestSuspendedTime = NoWork; - root.latestPingedTime = NoWork; - - // There's no suspended work. Treat the earliest remaining level as a - // pending level. - markPendingPriorityLevel(root, earliestRemainingTime); - findNextExpirationTimeToWorkOn(NoWork, root); - return; - } - - if (earliestRemainingTime > earliestSuspendedTime) { - // The earliest remaining time is earlier than all the suspended work. - // Treat it as a pending update. - markPendingPriorityLevel(root, earliestRemainingTime); - findNextExpirationTimeToWorkOn(NoWork, root); - return; - } - - // The earliest remaining time falls within the range of known suspended - // levels. We should treat this as suspended work. - findNextExpirationTimeToWorkOn(NoWork, root); -} - -function hasLowerPriorityWork(root, erroredExpirationTime) { - var latestPendingTime = root.latestPendingTime; - var latestSuspendedTime = root.latestSuspendedTime; - var latestPingedTime = root.latestPingedTime; - return ( - (latestPendingTime !== NoWork && - latestPendingTime < erroredExpirationTime) || - (latestSuspendedTime !== NoWork && - latestSuspendedTime < erroredExpirationTime) || - (latestPingedTime !== NoWork && latestPingedTime < erroredExpirationTime) - ); -} - -function isPriorityLevelSuspended(root, expirationTime) { - var earliestSuspendedTime = root.earliestSuspendedTime; - var latestSuspendedTime = root.latestSuspendedTime; - return ( - earliestSuspendedTime !== NoWork && - expirationTime <= earliestSuspendedTime && - expirationTime >= latestSuspendedTime - ); -} - -function markSuspendedPriorityLevel(root, suspendedTime) { - root.didError = false; - clearPing(root, suspendedTime); - - // First, check the known pending levels and update them if needed. - var earliestPendingTime = root.earliestPendingTime; - var latestPendingTime = root.latestPendingTime; - if (earliestPendingTime === suspendedTime) { - if (latestPendingTime === suspendedTime) { - // Both known pending levels were suspended. Clear them. - root.earliestPendingTime = root.latestPendingTime = NoWork; - } else { - // The earliest pending level was suspended. Clear by setting it to the - // latest pending level. - root.earliestPendingTime = latestPendingTime; - } - } else if (latestPendingTime === suspendedTime) { - // The latest pending level was suspended. Clear by setting it to the - // latest pending level. - root.latestPendingTime = earliestPendingTime; - } - - // Finally, update the known suspended levels. - var earliestSuspendedTime = root.earliestSuspendedTime; - var latestSuspendedTime = root.latestSuspendedTime; - if (earliestSuspendedTime === NoWork) { - // No other suspended levels. - root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime; - } else { - if (earliestSuspendedTime < suspendedTime) { - // This is the earliest suspended level. - root.earliestSuspendedTime = suspendedTime; - } else if (latestSuspendedTime > suspendedTime) { - // This is the latest suspended level - root.latestSuspendedTime = suspendedTime; - } - } - - findNextExpirationTimeToWorkOn(suspendedTime, root); -} - -function markPingedPriorityLevel(root, pingedTime) { - root.didError = false; - - // TODO: When we add back resuming, we need to ensure the progressed work - // is thrown out and not reused during the restarted render. One way to - // invalidate the progressed work is to restart at expirationTime + 1. - var latestPingedTime = root.latestPingedTime; - if (latestPingedTime === NoWork || latestPingedTime > pingedTime) { - root.latestPingedTime = pingedTime; - } - findNextExpirationTimeToWorkOn(pingedTime, root); -} - -function clearPing(root, completedTime) { - var latestPingedTime = root.latestPingedTime; - if (latestPingedTime >= completedTime) { - root.latestPingedTime = NoWork; - } -} - -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestExpirationTime = renderExpirationTime; - - var earliestPendingTime = root.earliestPendingTime; - var earliestSuspendedTime = root.earliestSuspendedTime; - if (earliestPendingTime > earliestExpirationTime) { - earliestExpirationTime = earliestPendingTime; - } - if (earliestSuspendedTime > earliestExpirationTime) { - earliestExpirationTime = earliestSuspendedTime; - } - return earliestExpirationTime; -} - -function didExpireAtExpirationTime(root, currentTime) { - var expirationTime = root.expirationTime; - if (expirationTime !== NoWork && currentTime <= expirationTime) { - // The root has expired. Flush all work up to the current time. - root.nextExpirationTimeToWorkOn = currentTime; - } -} - -function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { - var earliestSuspendedTime = root.earliestSuspendedTime; - var latestSuspendedTime = root.latestSuspendedTime; - var earliestPendingTime = root.earliestPendingTime; - var latestPingedTime = root.latestPingedTime; - - // Work on the earliest pending time. Failing that, work on the latest - // pinged time. - var nextExpirationTimeToWorkOn = - earliestPendingTime !== NoWork ? earliestPendingTime : latestPingedTime; - - // If there is no pending or pinged work, check if there's suspended work - // that's lower priority than what we just completed. - if ( - nextExpirationTimeToWorkOn === NoWork && - (completedExpirationTime === NoWork || - latestSuspendedTime < completedExpirationTime) - ) { - // The lowest priority suspended work is the work most likely to be - // committed next. Let's start rendering it again, so that if it times out, - // it's ready to commit. - nextExpirationTimeToWorkOn = latestSuspendedTime; - } - - var expirationTime = nextExpirationTimeToWorkOn; - if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) { - // Expire using the earliest known expiration time. - expirationTime = earliestSuspendedTime; - } - - root.nextExpirationTimeToWorkOn = nextExpirationTimeToWorkOn; - root.expirationTime = expirationTime; -} - -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - undefined, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ -function is(x, y) { - return ( - (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare - ); -} - -var hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Performs equality by iterating through keys on an object and returning false - * when any key has values which are not strictly equal between the arguments. - * Returns true when the values of all keys are strictly equal. - */ -function shallowEqual(objA, objB) { - if (is(objA, objB)) { - return true; - } - - if ( - typeof objA !== "object" || - objA === null || - typeof objB !== "object" || - objB === null - ) { - return false; - } - - var keysA = Object.keys(objA); - var keysB = Object.keys(objB); - - if (keysA.length !== keysB.length) { - return false; - } - - // Test for A's keys different from B. - for (var i = 0; i < keysA.length; i++) { - if ( - !hasOwnProperty.call(objB, keysA[i]) || - !is(objA[keysA[i]], objB[keysA[i]]) - ) { - return false; - } - } - - return true; -} - function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { // Resolve default props. Taken from ReactElement @@ -6499,6 +6535,912 @@ function readLazyComponentType(lazyComponent) { } } +var valueCursor = createCursor(null); + +var rendererSigil = void 0; +{ + // Use this to detect multiple renderers using the same context + rendererSigil = {}; +} + +var currentlyRenderingFiber = null; +var lastContextDependency = null; +var lastContextWithAllBitsObserved = null; + +var isDisallowedContextReadInDEV = false; + +function resetContextDependences() { + // This is called right before React yields execution, to ensure `readContext` + // cannot be called outside the render phase. + currentlyRenderingFiber = null; + lastContextDependency = null; + lastContextWithAllBitsObserved = null; + { + isDisallowedContextReadInDEV = false; + } +} + +function enterDisallowedContextReadInDEV() { + { + isDisallowedContextReadInDEV = true; + } +} + +function exitDisallowedContextReadInDEV() { + { + isDisallowedContextReadInDEV = false; + } +} + +function pushProvider(providerFiber, nextValue) { + var context = providerFiber.type._context; + + if (isPrimaryRenderer) { + push(valueCursor, context._currentValue, providerFiber); + + context._currentValue = nextValue; + { + !( + context._currentRenderer === undefined || + context._currentRenderer === null || + context._currentRenderer === rendererSigil + ) + ? warningWithoutStack$1( + false, + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ) + : void 0; + context._currentRenderer = rendererSigil; + } + } else { + push(valueCursor, context._currentValue2, providerFiber); + + context._currentValue2 = nextValue; + { + !( + context._currentRenderer2 === undefined || + context._currentRenderer2 === null || + context._currentRenderer2 === rendererSigil + ) + ? warningWithoutStack$1( + false, + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ) + : void 0; + context._currentRenderer2 = rendererSigil; + } + } +} + +function popProvider(providerFiber) { + var currentValue = valueCursor.current; + + pop(valueCursor, providerFiber); + + var context = providerFiber.type._context; + if (isPrimaryRenderer) { + context._currentValue = currentValue; + } else { + context._currentValue2 = currentValue; + } +} + +function calculateChangedBits(context, newValue, oldValue) { + if (is(oldValue, newValue)) { + // No change + return 0; + } else { + var changedBits = + typeof context._calculateChangedBits === "function" + ? context._calculateChangedBits(oldValue, newValue) + : MAX_SIGNED_31_BIT_INT; + + { + !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) + ? warning$1( + false, + "calculateChangedBits: Expected the return value to be a " + + "31-bit integer. Instead received: %s", + changedBits + ) + : void 0; + } + return changedBits | 0; + } +} + +function scheduleWorkOnParentPath(parent, renderExpirationTime) { + // Update the child expiration time of all the ancestors, including + // the alternates. + var node = parent; + while (node !== null) { + var alternate = node.alternate; + if (node.childExpirationTime < renderExpirationTime) { + node.childExpirationTime = renderExpirationTime; + if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; + } + } else if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; + } else { + // Neither alternate was updated, which means the rest of the + // ancestor path already has sufficient priority. + break; + } + node = node.return; + } +} + +function propagateContextChange( + workInProgress, + context, + changedBits, + renderExpirationTime +) { + var fiber = workInProgress.child; + if (fiber !== null) { + // Set the return pointer of the child to the work-in-progress fiber. + fiber.return = workInProgress; + } + while (fiber !== null) { + var nextFiber = void 0; + + // Visit this fiber. + var list = fiber.contextDependencies; + if (list !== null) { + nextFiber = fiber.child; + + var dependency = list.first; + while (dependency !== null) { + // Check if the context matches. + if ( + dependency.context === context && + (dependency.observedBits & changedBits) !== 0 + ) { + // Match! Schedule an update on this fiber. + + if (fiber.tag === ClassComponent) { + // Schedule a force update on the work-in-progress. + var update = createUpdate(renderExpirationTime); + update.tag = ForceUpdate; + // TODO: Because we don't have a work-in-progress, this will add the + // update to the current fiber, too, which means it will persist even if + // this render is thrown away. Since it's a race condition, not sure it's + // worth fixing. + enqueueUpdate(fiber, update); + } + + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; + } + var alternate = fiber.alternate; + if ( + alternate !== null && + alternate.expirationTime < renderExpirationTime + ) { + alternate.expirationTime = renderExpirationTime; + } + + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); + + // Mark the expiration time on the list, too. + if (list.expirationTime < renderExpirationTime) { + list.expirationTime = renderExpirationTime; + } + + // Since we already found a match, we can stop traversing the + // dependency list. + break; + } + dependency = dependency.next; + } + } else if (fiber.tag === ContextProvider) { + // Don't scan deeper if this is a matching provider + nextFiber = fiber.type === workInProgress.type ? null : fiber.child; + } else if ( + enableSuspenseServerRenderer && + fiber.tag === DehydratedSuspenseComponent + ) { + // If a dehydrated suspense component is in this subtree, we don't know + // if it will have any context consumers in it. The best we can do is + // mark it as having updates on its children. + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; + } + var _alternate = fiber.alternate; + if ( + _alternate !== null && + _alternate.expirationTime < renderExpirationTime + ) { + _alternate.expirationTime = renderExpirationTime; + } + // This is intentionally passing this fiber as the parent + // because we want to schedule this fiber as having work + // on its children. We'll use the childExpirationTime on + // this fiber to indicate that a context has changed. + scheduleWorkOnParentPath(fiber, renderExpirationTime); + nextFiber = fiber.sibling; + } else { + // Traverse down. + nextFiber = fiber.child; + } + + if (nextFiber !== null) { + // Set the return pointer of the child to the work-in-progress fiber. + nextFiber.return = fiber; + } else { + // No child. Traverse to next sibling. + nextFiber = fiber; + while (nextFiber !== null) { + if (nextFiber === workInProgress) { + // We're back to the root of this subtree. Exit. + nextFiber = null; + break; + } + var sibling = nextFiber.sibling; + if (sibling !== null) { + // Set the return pointer of the sibling to the work-in-progress fiber. + sibling.return = nextFiber.return; + nextFiber = sibling; + break; + } + // No more siblings. Traverse up. + nextFiber = nextFiber.return; + } + } + fiber = nextFiber; + } +} + +function prepareToReadContext(workInProgress, renderExpirationTime) { + currentlyRenderingFiber = workInProgress; + lastContextDependency = null; + lastContextWithAllBitsObserved = null; + + var currentDependencies = workInProgress.contextDependencies; + if ( + currentDependencies !== null && + currentDependencies.expirationTime >= renderExpirationTime + ) { + // Context list has a pending update. Mark that this fiber performed work. + markWorkInProgressReceivedUpdate(); + } + + // Reset the work-in-progress list + workInProgress.contextDependencies = null; +} + +function readContext(context, observedBits) { + { + // This warning would fire if you read context inside a Hook like useMemo. + // Unlike the class check below, it's not enforced in production for perf. + !!isDisallowedContextReadInDEV + ? warning$1( + false, + "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()." + ) + : void 0; + } + + if (lastContextWithAllBitsObserved === context) { + // Nothing to do. We already observe everything in this context. + } else if (observedBits === false || observedBits === 0) { + // Do not observe any updates. + } else { + var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types. + if ( + typeof observedBits !== "number" || + observedBits === MAX_SIGNED_31_BIT_INT + ) { + // Observe all updates. + lastContextWithAllBitsObserved = context; + resolvedObservedBits = MAX_SIGNED_31_BIT_INT; + } else { + resolvedObservedBits = observedBits; + } + + var contextItem = { + context: context, + observedBits: resolvedObservedBits, + next: null + }; + + if (lastContextDependency === null) { + (function() { + if (!(currentlyRenderingFiber !== null)) { + throw ReactError( + "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()." + ); + } + })(); + + // This is the first dependency for this component. Create a new list. + lastContextDependency = contextItem; + currentlyRenderingFiber.contextDependencies = { + first: contextItem, + expirationTime: NoWork + }; + } else { + // Append a new context item. + lastContextDependency = lastContextDependency.next = contextItem; + } + } + return isPrimaryRenderer ? context._currentValue : context._currentValue2; +} + +// UpdateQueue is a linked list of prioritized updates. +// +// Like fibers, update queues come in pairs: a current queue, which represents +// the visible state of the screen, and a work-in-progress queue, which can be +// mutated and processed asynchronously before it is committed — a form of +// double buffering. If a work-in-progress render is discarded before finishing, +// we create a new work-in-progress by cloning the current queue. +// +// Both queues share a persistent, singly-linked list structure. To schedule an +// update, we append it to the end of both queues. Each queue maintains a +// pointer to first update in the persistent list that hasn't been processed. +// The work-in-progress pointer always has a position equal to or greater than +// the current queue, since we always work on that one. The current queue's +// pointer is only updated during the commit phase, when we swap in the +// work-in-progress. +// +// For example: +// +// Current pointer: A - B - C - D - E - F +// Work-in-progress pointer: D - E - F +// ^ +// The work-in-progress queue has +// processed more updates than current. +// +// The reason we append to both queues is because otherwise we might drop +// updates without ever processing them. For example, if we only add updates to +// the work-in-progress queue, some updates could be lost whenever a work-in +// -progress render restarts by cloning from current. Similarly, if we only add +// updates to the current queue, the updates will be lost whenever an already +// in-progress queue commits and swaps with the current queue. However, by +// adding to both queues, we guarantee that the update will be part of the next +// work-in-progress. (And because the work-in-progress queue becomes the +// current queue once it commits, there's no danger of applying the same +// update twice.) +// +// Prioritization +// -------------- +// +// Updates are not sorted by priority, but by insertion; new updates are always +// appended to the end of the list. +// +// The priority is still important, though. When processing the update queue +// during the render phase, only the updates with sufficient priority are +// included in the result. If we skip an update because it has insufficient +// priority, it remains in the queue to be processed later, during a lower +// priority render. Crucially, all updates subsequent to a skipped update also +// remain in the queue *regardless of their priority*. That means high priority +// updates are sometimes processed twice, at two separate priorities. We also +// keep track of a base state, that represents the state before the first +// update in the queue is applied. +// +// For example: +// +// Given a base state of '', and the following queue of updates +// +// A1 - B2 - C1 - D2 +// +// where the number indicates the priority, and the update is applied to the +// previous state by appending a letter, React will process these updates as +// two separate renders, one per distinct priority level: +// +// First render, at priority 1: +// Base state: '' +// Updates: [A1, C1] +// Result state: 'AC' +// +// Second render, at priority 2: +// Base state: 'A' <- The base state does not include C1, +// because B2 was skipped. +// Updates: [B2, C1, D2] <- C1 was rebased on top of B2 +// Result state: 'ABCD' +// +// Because we process updates in insertion order, and rebase high priority +// updates when preceding updates are skipped, the final result is deterministic +// regardless of priority. Intermediate state may vary according to system +// resources, but the final state is always the same. + +var UpdateState = 0; +var ReplaceState = 1; +var ForceUpdate = 2; +var CaptureUpdate = 3; + +// Global state that is reset at the beginning of calling `processUpdateQueue`. +// It should only be read right after calling `processUpdateQueue`, via +// `checkHasForceUpdateAfterProcessing`. +var hasForceUpdate = false; + +var didWarnUpdateInsideUpdate = void 0; +var currentlyProcessingQueue = void 0; + +{ + didWarnUpdateInsideUpdate = false; + currentlyProcessingQueue = null; +} + +function createUpdateQueue(baseState) { + var queue = { + baseState: baseState, + firstUpdate: null, + lastUpdate: null, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; + return queue; +} + +function cloneUpdateQueue(currentQueue) { + var queue = { + baseState: currentQueue.baseState, + firstUpdate: currentQueue.firstUpdate, + lastUpdate: currentQueue.lastUpdate, + + // TODO: With resuming, if we bail out and resuse the child tree, we should + // keep these effects. + firstCapturedUpdate: null, + lastCapturedUpdate: null, + + firstEffect: null, + lastEffect: null, + + firstCapturedEffect: null, + lastCapturedEffect: null + }; + return queue; +} + +function createUpdate(expirationTime) { + return { + expirationTime: expirationTime, + + tag: UpdateState, + payload: null, + callback: null, + + next: null, + nextEffect: null + }; +} + +function appendUpdateToQueue(queue, update) { + // Append the update to the end of the list. + if (queue.lastUpdate === null) { + // Queue is empty + queue.firstUpdate = queue.lastUpdate = update; + } else { + queue.lastUpdate.next = update; + queue.lastUpdate = update; + } +} + +function enqueueUpdate(fiber, update) { + // Update queues are created lazily. + var alternate = fiber.alternate; + var queue1 = void 0; + var queue2 = void 0; + if (alternate === null) { + // There's only one fiber. + queue1 = fiber.updateQueue; + queue2 = null; + if (queue1 === null) { + queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); + } + } else { + // There are two owners. + queue1 = fiber.updateQueue; + queue2 = alternate.updateQueue; + if (queue1 === null) { + if (queue2 === null) { + // Neither fiber has an update queue. Create new ones. + queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); + queue2 = alternate.updateQueue = createUpdateQueue( + alternate.memoizedState + ); + } else { + // Only one fiber has an update queue. Clone to create a new one. + queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); + } + } else { + if (queue2 === null) { + // Only one fiber has an update queue. Clone to create a new one. + queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); + } else { + // Both owners have an update queue. + } + } + } + if (queue2 === null || queue1 === queue2) { + // There's only a single queue. + appendUpdateToQueue(queue1, update); + } else { + // There are two queues. We need to append the update to both queues, + // while accounting for the persistent structure of the list — we don't + // want the same update to be added multiple times. + if (queue1.lastUpdate === null || queue2.lastUpdate === null) { + // One of the queues is not empty. We must add the update to both queues. + appendUpdateToQueue(queue1, update); + appendUpdateToQueue(queue2, update); + } else { + // Both queues are non-empty. The last update is the same in both lists, + // because of structural sharing. So, only append to one of the lists. + appendUpdateToQueue(queue1, update); + // But we still need to update the `lastUpdate` pointer of queue2. + queue2.lastUpdate = update; + } + } + + { + if ( + fiber.tag === ClassComponent && + (currentlyProcessingQueue === queue1 || + (queue2 !== null && currentlyProcessingQueue === queue2)) && + !didWarnUpdateInsideUpdate + ) { + warningWithoutStack$1( + false, + "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." + ); + didWarnUpdateInsideUpdate = true; + } + } +} + +function enqueueCapturedUpdate(workInProgress, update) { + // Captured updates go into a separate list, and only on the work-in- + // progress queue. + var workInProgressQueue = workInProgress.updateQueue; + if (workInProgressQueue === null) { + workInProgressQueue = workInProgress.updateQueue = createUpdateQueue( + workInProgress.memoizedState + ); + } else { + // TODO: I put this here rather than createWorkInProgress so that we don't + // clone the queue unnecessarily. There's probably a better way to + // structure this. + workInProgressQueue = ensureWorkInProgressQueueIsAClone( + workInProgress, + workInProgressQueue + ); + } + + // Append the update to the end of the list. + if (workInProgressQueue.lastCapturedUpdate === null) { + // This is the first render phase update + workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update; + } else { + workInProgressQueue.lastCapturedUpdate.next = update; + workInProgressQueue.lastCapturedUpdate = update; + } +} + +function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { + var current = workInProgress.alternate; + if (current !== null) { + // If the work-in-progress queue is equal to the current queue, + // we need to clone it first. + if (queue === current.updateQueue) { + queue = workInProgress.updateQueue = cloneUpdateQueue(queue); + } + } + return queue; +} + +function getStateFromUpdate( + workInProgress, + queue, + update, + prevState, + nextProps, + instance +) { + switch (update.tag) { + case ReplaceState: { + var _payload = update.payload; + if (typeof _payload === "function") { + // Updater function + { + enterDisallowedContextReadInDEV(); + if ( + debugRenderPhaseSideEffects || + (debugRenderPhaseSideEffectsForStrictMode && + workInProgress.mode & StrictMode) + ) { + _payload.call(instance, prevState, nextProps); + } + } + var nextState = _payload.call(instance, prevState, nextProps); + { + exitDisallowedContextReadInDEV(); + } + return nextState; + } + // State object + return _payload; + } + case CaptureUpdate: { + workInProgress.effectTag = + (workInProgress.effectTag & ~ShouldCapture) | DidCapture; + } + // Intentional fallthrough + case UpdateState: { + var _payload2 = update.payload; + var partialState = void 0; + if (typeof _payload2 === "function") { + // Updater function + { + enterDisallowedContextReadInDEV(); + if ( + debugRenderPhaseSideEffects || + (debugRenderPhaseSideEffectsForStrictMode && + workInProgress.mode & StrictMode) + ) { + _payload2.call(instance, prevState, nextProps); + } + } + partialState = _payload2.call(instance, prevState, nextProps); + { + exitDisallowedContextReadInDEV(); + } + } else { + // Partial state object + partialState = _payload2; + } + if (partialState === null || partialState === undefined) { + // Null and undefined are treated as no-ops. + return prevState; + } + // Merge the partial state and the previous state. + return Object.assign({}, prevState, partialState); + } + case ForceUpdate: { + hasForceUpdate = true; + return prevState; + } + } + return prevState; +} + +function processUpdateQueue( + workInProgress, + queue, + props, + instance, + renderExpirationTime +) { + hasForceUpdate = false; + + queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); + + { + currentlyProcessingQueue = queue; + } + + // These values may change as we process the queue. + var newBaseState = queue.baseState; + var newFirstUpdate = null; + var newExpirationTime = NoWork; + + // Iterate through the list of updates to compute the result. + var update = queue.firstUpdate; + var resultState = newBaseState; + while (update !== null) { + var updateExpirationTime = update.expirationTime; + if (updateExpirationTime < renderExpirationTime) { + // This update does not have sufficient priority. Skip it. + if (newFirstUpdate === null) { + // This is the first skipped update. It will be the first update in + // the new list. + newFirstUpdate = update; + // Since this is the first update that was skipped, the current result + // is the new base state. + newBaseState = resultState; + } + // Since this update will remain in the list, update the remaining + // expiration time. + if (newExpirationTime < updateExpirationTime) { + newExpirationTime = updateExpirationTime; + } + } else { + // This update does have sufficient priority. + + // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + markRenderEventTime(updateExpirationTime); + + // Process it and compute a new result. + resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + ); + var _callback = update.callback; + if (_callback !== null) { + workInProgress.effectTag |= Callback; + // Set this to null, in case it was mutated during an aborted render. + update.nextEffect = null; + if (queue.lastEffect === null) { + queue.firstEffect = queue.lastEffect = update; + } else { + queue.lastEffect.nextEffect = update; + queue.lastEffect = update; + } + } + } + // Continue to the next update. + update = update.next; + } + + // Separately, iterate though the list of captured updates. + var newFirstCapturedUpdate = null; + update = queue.firstCapturedUpdate; + while (update !== null) { + var _updateExpirationTime = update.expirationTime; + if (_updateExpirationTime < renderExpirationTime) { + // This update does not have sufficient priority. Skip it. + if (newFirstCapturedUpdate === null) { + // This is the first skipped captured update. It will be the first + // update in the new list. + newFirstCapturedUpdate = update; + // If this is the first update that was skipped, the current result is + // the new base state. + if (newFirstUpdate === null) { + newBaseState = resultState; + } + } + // Since this update will remain in the list, update the remaining + // expiration time. + if (newExpirationTime < _updateExpirationTime) { + newExpirationTime = _updateExpirationTime; + } + } else { + // This update does have sufficient priority. Process it and compute + // a new result. + resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + ); + var _callback2 = update.callback; + if (_callback2 !== null) { + workInProgress.effectTag |= Callback; + // Set this to null, in case it was mutated during an aborted render. + update.nextEffect = null; + if (queue.lastCapturedEffect === null) { + queue.firstCapturedEffect = queue.lastCapturedEffect = update; + } else { + queue.lastCapturedEffect.nextEffect = update; + queue.lastCapturedEffect = update; + } + } + } + update = update.next; + } + + if (newFirstUpdate === null) { + queue.lastUpdate = null; + } + if (newFirstCapturedUpdate === null) { + queue.lastCapturedUpdate = null; + } else { + workInProgress.effectTag |= Callback; + } + if (newFirstUpdate === null && newFirstCapturedUpdate === null) { + // We processed every update, without skipping. That means the new base + // state is the same as the result state. + newBaseState = resultState; + } + + queue.baseState = newBaseState; + queue.firstUpdate = newFirstUpdate; + queue.firstCapturedUpdate = newFirstCapturedUpdate; + + // Set the remaining expiration time to be whatever is remaining in the queue. + // This should be fine because the only two other things that contribute to + // expiration time are props and context. We're already in the middle of the + // begin phase by the time we start processing the queue, so we've already + // dealt with the props. Context in components that specify + // shouldComponentUpdate is tricky; but we'll have to account for + // that regardless. + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = resultState; + + { + currentlyProcessingQueue = null; + } +} + +function callCallback(callback, context) { + (function() { + if (!(typeof callback === "function")) { + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + } + })(); + callback.call(context); +} + +function resetHasForceUpdateBeforeProcessing() { + hasForceUpdate = false; +} + +function checkHasForceUpdateAfterProcessing() { + return hasForceUpdate; +} + +function commitUpdateQueue( + finishedWork, + finishedQueue, + instance, + renderExpirationTime +) { + // If the finished render included captured updates, and there are still + // lower priority updates left over, we need to keep the captured updates + // in the queue so that they are rebased and not dropped once we process the + // queue again at the lower priority. + if (finishedQueue.firstCapturedUpdate !== null) { + // Join the captured update list to the end of the normal list. + if (finishedQueue.lastUpdate !== null) { + finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate; + finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate; + } + // Clear the list of captured updates. + finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null; + } + + // Commit the effects + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} + +function commitUpdateEffects(effect, instance) { + while (effect !== null) { + var _callback3 = effect.callback; + if (_callback3 !== null) { + effect.callback = null; + callCallback(_callback3, instance); + } + effect = effect.nextEffect; + } +} + var fakeInternalInstance = {}; var isArray$1 = Array.isArray; @@ -6569,15 +7511,13 @@ var didWarnAboutInvalidateContextType = void 0; Object.defineProperty(fakeInternalInstance, "_processChildContext", { enumerable: false, value: function() { - invariant( - false, - "_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)." - ); + (function() { + { + throw ReactError( + "_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)." + ); + } + })(); } }); Object.freeze(fakeInternalInstance); @@ -6991,23 +7931,51 @@ function constructClassInstance( var unmaskedContext = emptyContextObject; var context = null; var contextType = ctor.contextType; - if (typeof contextType === "object" && contextType !== null) { - { - if ( - contextType.$$typeof !== REACT_CONTEXT_TYPE && - !didWarnAboutInvalidateContextType.has(ctor) - ) { + + { + if ("contextType" in ctor) { + var isValid = + // Allow null for conditional declaration + contextType === null || + (contextType !== undefined && + contextType.$$typeof === REACT_CONTEXT_TYPE && + contextType._context === undefined); // Not a + + if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { didWarnAboutInvalidateContextType.add(ctor); + + var addendum = ""; + if (contextType === undefined) { + 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."; + } else if (typeof contextType !== "object") { + addendum = " However, it is set to a " + typeof contextType + "."; + } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { + addendum = " Did you accidentally pass the Context.Provider instead?"; + } else if (contextType._context !== undefined) { + // + addendum = " Did you accidentally pass the Context.Consumer instead?"; + } else { + addendum = + " However, it is set to an object with keys {" + + Object.keys(contextType).join(", ") + + "}."; + } warningWithoutStack$1( false, "%s defines an invalid contextType. " + - "contextType should point to the Context object returned by React.createContext(). " + - "Did you accidentally pass the Context.Provider instead?", - getComponentName(ctor) || "Component" + "contextType should point to the Context object returned by React.createContext().%s", + getComponentName(ctor) || "Component", + addendum ); } } + } + if (typeof contextType === "object" && contextType !== null) { context = readContext(contextType); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); @@ -7649,11 +8617,13 @@ var warnForMissingKey = function(child) {}; if (!child._store || child._store.validated || child.key != null) { return; } - invariant( - typeof child._store === "object", - "React Component in warnForMissingKey should have a _store. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(typeof child._store === "object")) { + throw ReactError( + "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); child._store.validated = true; var currentComponentErrorInfo = @@ -7709,19 +8679,24 @@ function coerceRef(returnFiber, current$$1, element) { var inst = void 0; if (owner) { var ownerFiber = owner; - invariant( - ownerFiber.tag === ClassComponent, - "Function components cannot have refs. " + - "Did you mean to use React.forwardRef()?" - ); + (function() { + if (!(ownerFiber.tag === ClassComponent)) { + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + } + })(); inst = ownerFiber.stateNode; } - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a " + - "bug in React. Please file an issue.", - mixedRef - ); + (function() { + if (!inst) { + throw ReactError( + "Missing owner for string ref " + + mixedRef + + ". This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref if ( @@ -7747,20 +8722,22 @@ function coerceRef(returnFiber, current$$1, element) { ref._stringRef = stringRef; return ref; } else { - invariant( - typeof mixedRef === "string", - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of" + - " the following reasons:\n" + - "1. You may be adding a ref to a function component\n" + - "2. You may be adding a ref to a component that was not created inside a component's render method\n" + - "3. You have multiple copies of React loaded\n" + - "See https://fb.me/react-refs-must-have-owner for more information.", - mixedRef - ); + (function() { + if (!(typeof mixedRef === "string")) { + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + } + })(); + (function() { + if (!element._owner) { + throw ReactError( + "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://fb.me/react-refs-must-have-owner for more information." + ); + } + })(); } } return mixedRef; @@ -7775,14 +8752,18 @@ function throwOnInvalidObjectType(returnFiber, newChild) { "instead." + getCurrentFiberStackInDev(); } - invariant( - false, - "Objects are not valid as a React child (found: %s).%s", - Object.prototype.toString.call(newChild) === "[object Object]" - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - addendum - ); + (function() { + { + throw ReactError( + "Objects are not valid as a React child (found: " + + (Object.prototype.toString.call(newChild) === "[object Object]" + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." + + addendum + ); + } + })(); } } @@ -8371,7 +9352,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChildren[newIdx], expirationTime ); - if (!_newFiber) { + if (_newFiber === null) { continue; } lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); @@ -8398,7 +9379,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChildren[newIdx], expirationTime ); - if (_newFiber2) { + if (_newFiber2 !== null) { if (shouldTrackSideEffects) { if (_newFiber2.alternate !== null) { // The new fiber is a work in progress, but if there exists a @@ -8441,11 +9422,13 @@ function ChildReconciler(shouldTrackSideEffects) { // but using the iterator instead. var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - typeof iteratorFn === "function", - "An object is not an iterable. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + (function() { + if (!(typeof iteratorFn === "function")) { + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); { // We don't support rendering Generators because it's a mutation. @@ -8495,7 +9478,11 @@ function ChildReconciler(shouldTrackSideEffects) { } var newChildren = iteratorFn.call(newChildrenIterable); - invariant(newChildren != null, "An iterable object provided no iterator."); + (function() { + if (!(newChildren != null)) { + throw ReactError("An iterable object provided no iterator."); + } + })(); var resultingFirstChild = null; var previousNewFiber = null; @@ -8528,7 +9515,7 @@ function ChildReconciler(shouldTrackSideEffects) { // unfortunate because it triggers the slow path all the time. We need // a better way to communicate whether this was a miss or null, // boolean, undefined, etc. - if (!oldFiber) { + if (oldFiber === null) { oldFiber = nextOldFiber; } break; @@ -8866,13 +9853,14 @@ function ChildReconciler(shouldTrackSideEffects) { // eslint-disable-next-lined no-fallthrough case FunctionComponent: { var Component = returnFiber.type; - invariant( - false, - "%s(...): Nothing was returned from render. This usually means a " + - "return statement is missing. Or, to render nothing, " + - "return null.", - Component.displayName || Component.name || "Component" - ); + (function() { + { + throw ReactError( + (Component.displayName || Component.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + ); + } + })(); } } } @@ -8888,10 +9876,11 @@ var reconcileChildFibers = ChildReconciler(true); var mountChildFibers = ChildReconciler(false); function cloneChildFibers(current$$1, workInProgress) { - invariant( - current$$1 === null || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + (function() { + if (!(current$$1 === null || workInProgress.child === current$$1.child)) { + throw ReactError("Resuming work not yet implemented."); + } + })(); if (workInProgress.child === null) { return; @@ -8925,11 +9914,13 @@ var contextFiberStackCursor = createCursor(NO_CONTEXT); var rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + if (!(c !== NO_CONTEXT)) { + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); return c; } @@ -8985,6 +9976,37 @@ function pushHostContext(fiber) { push(contextStackCursor$1, nextContext, fiber); } +function pushHostContextForEventComponent(fiber) { + var context = requiredContext(contextStackCursor$1.current); + var nextContext = getChildHostContextForEventComponent(context); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + +function pushHostContextForEventTarget(fiber) { + var context = requiredContext(contextStackCursor$1.current); + var eventTargetType = fiber.type.type; + var nextContext = getChildHostContextForEventTarget(context, eventTargetType); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + function popHostContext(fiber) { // Do not pop unless this Fiber provided the current context. // pushHostContext() only pushes Fibers that provide unique contexts. @@ -9013,7 +10035,7 @@ var didWarnAboutMismatchedHooksForComponent = void 0; } // These are set right before calling the component. -var renderExpirationTime = NoWork; +var renderExpirationTime$1 = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from // the work-in-progress hook. var currentlyRenderingFiber$1 = null; @@ -9022,7 +10044,6 @@ var currentlyRenderingFiber$1 = null; // current hook list is the list that belongs to the current fiber. The // work-in-progress hook list is a new list that will be added to the // work-in-progress fiber. -var firstCurrentHook = null; var currentHook = null; var nextCurrentHook = null; var firstWorkInProgressHook = null; @@ -9052,60 +10073,107 @@ var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook var currentHookNameInDev = null; -function warnOnHookMismatchInDev() { +// In DEV, this list ensures that hooks are called in the same order between renders. +// The list stores the order of hooks used during the initial render (mount). +// Subsequent renders (updates) reference this list. +var hookTypesDev = null; +var hookTypesUpdateIndexDev = -1; + +function mountHookTypesDev() { { - var componentName = getComponentName(currentlyRenderingFiber$1.type); - if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { - didWarnAboutMismatchedHooksForComponent.add(componentName); + var hookName = currentHookNameInDev; - var secondColumnStart = 22; + if (hookTypesDev === null) { + hookTypesDev = [hookName]; + } else { + hookTypesDev.push(hookName); + } + } +} - var table = ""; - var prevHook = firstCurrentHook; - var nextHook = firstWorkInProgressHook; - var n = 1; - while (prevHook !== null && nextHook !== null) { - var oldHookName = prevHook._debugType; - var newHookName = nextHook._debugType; +function updateHookTypesDev() { + { + var hookName = currentHookNameInDev; - var row = n + ". " + oldHookName; - - // Extra space so second column lines up - // lol @ IE not supporting String#repeat - while (row.length < secondColumnStart) { - row += " "; - } - - row += newHookName + "\n"; - - table += row; - prevHook = prevHook.next; - nextHook = nextHook.next; - n++; + if (hookTypesDev !== null) { + hookTypesUpdateIndexDev++; + if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { + warnOnHookMismatchInDev(hookName); } + } + } +} +function checkDepsAreArrayDev(deps) { + { + if (deps !== undefined && deps !== null && !Array.isArray(deps)) { + // Verify deps, but only on mount to avoid extra checks. + // It's unlikely their type would change as usually you define them inline. warning$1( false, - "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://fb.me/rules-of-hooks\n\n" + - " Previous render Next render\n" + - " -------------------------------\n" + - "%s" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - componentName, - table + "%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 ); } } } +function warnOnHookMismatchInDev(currentHookName) { + { + var componentName = getComponentName(currentlyRenderingFiber$1.type); + if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { + didWarnAboutMismatchedHooksForComponent.add(componentName); + + if (hookTypesDev !== null) { + var table = ""; + + var secondColumnStart = 30; + + for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { + var oldHookName = hookTypesDev[i]; + var newHookName = + i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; + + var row = i + 1 + ". " + oldHookName; + + // Extra space so second column lines up + // lol @ IE not supporting String#repeat + while (row.length < secondColumnStart) { + row += " "; + } + + row += newHookName + "\n"; + + table += row; + } + + warning$1( + false, + "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://fb.me/rules-of-hooks\n\n" + + " Previous render Next render\n" + + " ------------------------------------------------------\n" + + "%s" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + componentName, + table + ); + } + } + } +} + function throwInvalidHookError() { - invariant( - false, - "Hooks can only be called inside the body of a function component. " + - "(https://fb.me/react-invalid-hook-call)" - ); + (function() { + { + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + ); + } + })(); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -9133,8 +10201,8 @@ function areHookInputsEqual(nextDeps, prevDeps) { "Previous: %s\n" + "Incoming: %s", currentHookNameInDev, - "[" + nextDeps.join(", ") + "]", - "[" + prevDeps.join(", ") + "]" + "[" + prevDeps.join(", ") + "]", + "[" + nextDeps.join(", ") + "]" ); } } @@ -9155,10 +10223,14 @@ function renderWithHooks( refOrContext, nextRenderExpirationTime ) { - renderExpirationTime = nextRenderExpirationTime; + renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - firstCurrentHook = nextCurrentHook = - current !== null ? current.memoizedState : null; + nextCurrentHook = current !== null ? current.memoizedState : null; + + { + hookTypesDev = current !== null ? current._debugHookTypes : null; + hookTypesUpdateIndexDev = -1; + } // The following should have already been reset // currentHook = null; @@ -9172,11 +10244,26 @@ function renderWithHooks( // numberOfReRenders = 0; // sideEffectTag = 0; + // TODO Warn if no hooks are used at all during mount, then some are used during update. + // Currently we will identify the update render as a mount because nextCurrentHook === null. + // This is tricky because it's valid for certain types of components (e.g. React.lazy) + + // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used. + // Non-stateful hooks (e.g. context) don't get added to memoizedState, + // so nextCurrentHook would be null during updates and mounts. { - ReactCurrentDispatcher$1.current = - nextCurrentHook === null - ? HooksDispatcherOnMountInDEV - : HooksDispatcherOnUpdateInDEV; + if (nextCurrentHook !== null) { + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; + } else if (hookTypesDev !== null) { + // This dispatcher handles an edge case where a component is updating, + // but no stateful hooks have been used. + // We want to match the production code behavior (which will use HooksDispatcherOnMount), + // but with the extra DEV validation to ensure hooks ordering hasn't changed. + // This dispatcher does that. + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; + } else { + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; + } } var children = Component(props, refOrContext); @@ -9187,14 +10274,18 @@ function renderWithHooks( numberOfReRenders += 1; // Start over from the beginning of the list - firstCurrentHook = nextCurrentHook = - current !== null ? current.memoizedState : null; + nextCurrentHook = current !== null ? current.memoizedState : null; nextWorkInProgressHook = firstWorkInProgressHook; currentHook = null; workInProgressHook = null; componentUpdateQueue = null; + { + // Also validate hook order for cascading updates. + hookTypesUpdateIndexDev = -1; + } + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; children = Component(props, refOrContext); @@ -9204,10 +10295,6 @@ function renderWithHooks( numberOfReRenders = 0; } - { - currentHookNameInDev = null; - } - // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; @@ -9219,18 +10306,29 @@ function renderWithHooks( renderedWork.updateQueue = componentUpdateQueue; renderedWork.effectTag |= sideEffectTag; + { + renderedWork._debugHookTypes = hookTypesDev; + } + + // This check uses currentHook so that it works the same in DEV and prod bundles. + // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; - renderExpirationTime = NoWork; + renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; - firstCurrentHook = null; currentHook = null; nextCurrentHook = null; firstWorkInProgressHook = null; workInProgressHook = null; nextWorkInProgressHook = null; + { + currentHookNameInDev = null; + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + } + remainingExpirationTime = NoWork; componentUpdateQueue = null; sideEffectTag = 0; @@ -9240,11 +10338,13 @@ function renderWithHooks( // renderPhaseUpdates = null; // numberOfReRenders = 0; - invariant( - !didRenderTooFewHooks, - "Rendered fewer hooks than expected. This may be caused by an accidental " + - "early return statement." - ); + (function() { + if (!!didRenderTooFewHooks) { + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); + } + })(); return children; } @@ -9265,24 +10365,26 @@ function resetHooks() { // This is used to reset the state of this module when a component throws. // It's also called inside mountIndeterminateComponent if we determine the // component is a module-style component. - renderExpirationTime = NoWork; + renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; - firstCurrentHook = null; currentHook = null; nextCurrentHook = null; firstWorkInProgressHook = null; workInProgressHook = null; nextWorkInProgressHook = null; + { + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + + currentHookNameInDev = null; + } + remainingExpirationTime = NoWork; componentUpdateQueue = null; sideEffectTag = 0; - { - currentHookNameInDev = null; - } - didScheduleRenderPhaseUpdate = false; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -9299,9 +10401,6 @@ function mountWorkInProgressHook() { next: null }; - { - hook._debugType = currentHookNameInDev; - } if (workInProgressHook === null) { // This is the first hook in the list firstWorkInProgressHook = workInProgressHook = hook; @@ -9327,10 +10426,13 @@ function updateWorkInProgressHook() { nextCurrentHook = currentHook !== null ? currentHook.next : null; } else { // Clone from the current hook. - invariant( - nextCurrentHook !== null, - "Rendered more hooks than during the previous render." - ); + (function() { + if (!(nextCurrentHook !== null)) { + throw ReactError( + "Rendered more hooks than during the previous render." + ); + } + })(); currentHook = nextCurrentHook; var newHook = { @@ -9351,13 +10453,6 @@ function updateWorkInProgressHook() { workInProgressHook = workInProgressHook.next = newHook; } nextCurrentHook = currentHook.next; - - { - newHook._debugType = currentHookNameInDev; - if (currentHookNameInDev !== currentHook._debugType) { - warnOnHookMismatchInDev(); - } - } } return workInProgressHook; } @@ -9372,20 +10467,6 @@ function basicStateReducer(state, action) { return typeof action === "function" ? action(state) : action; } -function mountContext(context, observedBits) { - { - mountWorkInProgressHook(); - } - return readContext(context, observedBits); -} - -function updateContext(context, observedBits) { - { - updateWorkInProgressHook(); - } - return readContext(context, observedBits); -} - function mountReducer(reducer, initialArg, init) { var hook = mountWorkInProgressHook(); var initialState = void 0; @@ -9398,8 +10479,8 @@ function mountReducer(reducer, initialArg, init) { var queue = (hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialState + lastRenderedReducer: reducer, + lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( null, @@ -9413,10 +10494,15 @@ function mountReducer(reducer, initialArg, init) { function updateReducer(reducer, initialArg, init) { var hook = updateWorkInProgressHook(); var queue = hook.queue; - invariant( - queue !== null, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + (function() { + if (!(queue !== null)) { + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + } + })(); + + queue.lastRenderedReducer = reducer; if (numberOfReRenders > 0) { // This is a re-render. Apply the new render phase updates to the previous @@ -9452,8 +10538,7 @@ function updateReducer(reducer, initialArg, init) { hook.baseState = newState; } - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; return [newState, _dispatch]; } @@ -9489,7 +10574,7 @@ function updateReducer(reducer, initialArg, init) { var didSkip = false; do { var updateExpirationTime = _update.expirationTime; - if (updateExpirationTime < renderExpirationTime) { + if (updateExpirationTime < renderExpirationTime$1) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. @@ -9503,6 +10588,16 @@ function updateReducer(reducer, initialArg, init) { remainingExpirationTime = updateExpirationTime; } } else { + // This update does have sufficient priority. + + // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + markRenderEventTime(updateExpirationTime); + // Process this update. if (_update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -9532,8 +10627,7 @@ function updateReducer(reducer, initialArg, init) { hook.baseUpdate = newBaseUpdate; hook.baseState = newBaseState; - queue.eagerReducer = reducer; - queue.eagerState = _newState; + queue.lastRenderedState = _newState; } var dispatch = queue.dispatch; @@ -9549,8 +10643,8 @@ function mountState(initialState) { var queue = (hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( null, @@ -9793,25 +10887,14 @@ function updateMemo(nextCreate, deps) { return nextValue; } -// in a test-like environment, we want to warn if dispatchAction() -// is called outside of a batchedUpdates/TestUtils.act(...) call. -var shouldWarnForUnbatchedSetState = false; - -{ - // jest isn't a 'global', it's just exposed to tests via a wrapped function - // further, this isn't a test file, so flow doesn't recognize the symbol. So... - // $FlowExpectedError - because requirements don't give a damn about your type sigs. - if ("undefined" !== typeof jest) { - shouldWarnForUnbatchedSetState = true; - } -} - function dispatchAction(fiber, queue, action) { - invariant( - numberOfReRenders < RE_RENDER_LIMIT, - "Too many re-renders. React limits the number of renders to prevent " + - "an infinite loop." - ); + (function() { + if (!(numberOfReRenders < RE_RENDER_LIMIT)) { + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); + } + })(); { !(arguments.length <= 3) @@ -9834,7 +10917,7 @@ function dispatchAction(fiber, queue, action) { // and apply the stashed updates on top of the work-in-progress hook. didScheduleRenderPhaseUpdate = true; var update = { - expirationTime: renderExpirationTime, + expirationTime: renderExpirationTime$1, action: action, eagerReducer: null, eagerState: null, @@ -9890,21 +10973,21 @@ function dispatchAction(fiber, queue, action) { // The queue is currently empty, which means we can eagerly compute the // next state before entering the render phase. If the new state is the // same as the current state, we may be able to bail out entirely. - var _eagerReducer = queue.eagerReducer; - if (_eagerReducer !== null) { + var _lastRenderedReducer = queue.lastRenderedReducer; + if (_lastRenderedReducer !== null) { var prevDispatcher = void 0; { prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } try { - var currentState = queue.eagerState; - var _eagerState = _eagerReducer(currentState, action); + var currentState = queue.lastRenderedState; + var _eagerState = _lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute // it, on the update object. If the reducer hasn't changed by the // time we enter the render phase, then the eager state can be used // without calling the reducer again. - _update2.eagerReducer = _eagerReducer; + _update2.eagerReducer = _lastRenderedReducer; _update2.eagerState = _eagerState; if (is(_eagerState, currentState)) { // Fast path. We can bail out without scheduling React to re-render. @@ -9923,8 +11006,11 @@ function dispatchAction(fiber, queue, action) { } } { - if (shouldWarnForUnbatchedSetState === true) { - warnIfNotCurrentlyBatchingInDev(fiber); + // jest isn't a 'global', it's just exposed to tests via a wrapped function + // further, this isn't a test file, so flow doesn't recognize the symbol. So... + // $FlowExpectedError - because requirements don't give a damn about your type sigs. + if ("undefined" !== typeof jest) { + warnIfNotCurrentlyActingUpdatesInDev(fiber); } } scheduleWork(fiber, _expirationTime); @@ -9947,6 +11033,7 @@ var ContextOnlyDispatcher = { }; var HooksDispatcherOnMountInDEV = null; +var HooksDispatcherOnMountWithHookTypesInDEV = null; var HooksDispatcherOnUpdateInDEV = null; var InvalidNestedHooksDispatcherOnMountInDEV = null; var InvalidNestedHooksDispatcherOnUpdateInDEV = null; @@ -9978,26 +11065,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); return mountCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; - return mountContext(context, observedBits); + mountHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); return mountEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); return mountImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); return mountLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10008,6 +11106,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10018,10 +11117,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useRef: function(initialValue) { currentHookNameInDev = "useRef"; + mountHookTypesDev(); return mountRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10032,6 +11133,81 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; + mountHookTypesDev(); + return mountDebugValue(value, formatterFn); + } + }; + + HooksDispatcherOnMountWithHookTypesInDEV = { + readContext: function(context, observedBits) { + return readContext(context, observedBits); + }, + useCallback: function(callback, deps) { + currentHookNameInDev = "useCallback"; + updateHookTypesDev(); + return mountCallback(callback, deps); + }, + useContext: function(context, observedBits) { + currentHookNameInDev = "useContext"; + updateHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function(create, deps) { + currentHookNameInDev = "useEffect"; + updateHookTypesDev(); + return mountEffect(create, deps); + }, + useImperativeHandle: function(ref, create, deps) { + currentHookNameInDev = "useImperativeHandle"; + updateHookTypesDev(); + return mountImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function(create, deps) { + currentHookNameInDev = "useLayoutEffect"; + updateHookTypesDev(); + return mountLayoutEffect(create, deps); + }, + useMemo: function(create, deps) { + currentHookNameInDev = "useMemo"; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function(reducer, initialArg, init) { + currentHookNameInDev = "useReducer"; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function(initialValue) { + currentHookNameInDev = "useRef"; + updateHookTypesDev(); + return mountRef(initialValue); + }, + useState: function(initialState) { + currentHookNameInDev = "useState"; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function(value, formatterFn) { + currentHookNameInDev = "useDebugValue"; + updateHookTypesDev(); return mountDebugValue(value, formatterFn); } }; @@ -10042,26 +11218,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; + updateHookTypesDev(); return updateCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; - return updateContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; + updateHookTypesDev(); return updateEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; + updateHookTypesDev(); return updateImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; + updateHookTypesDev(); return updateLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10072,6 +11254,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10082,10 +11265,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useRef: function(initialValue) { currentHookNameInDev = "useRef"; + updateHookTypesDev(); return updateRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10096,6 +11281,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; + updateHookTypesDev(); return updateDebugValue(value, formatterFn); } }; @@ -10108,31 +11294,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; warnInvalidHookAccess(); - return mountContext(context, observedBits); + mountHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10144,6 +11336,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10155,11 +11348,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useRef: function(initialValue) { currentHookNameInDev = "useRef"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10171,6 +11366,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountDebugValue(value, formatterFn); } }; @@ -10183,31 +11379,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; warnInvalidHookAccess(); - return updateContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10219,6 +11421,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10230,11 +11433,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useRef: function(initialValue) { currentHookNameInDev = "useRef"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10246,11 +11451,16 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateDebugValue(value, formatterFn); } }; } +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var now$1 = Scheduler.unstable_now; + var commitTime = 0; var profilerStartTime = -1; @@ -10262,7 +11472,7 @@ function recordCommitTime() { if (!enableProfilerTimer) { return; } - commitTime = now$$1(); + commitTime = now$1(); } function startProfilerTimer(fiber) { @@ -10270,10 +11480,10 @@ function startProfilerTimer(fiber) { return; } - profilerStartTime = now$$1(); + profilerStartTime = now$1(); if (fiber.actualStartTime < 0) { - fiber.actualStartTime = now$$1(); + fiber.actualStartTime = now$1(); } } @@ -10290,7 +11500,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } if (profilerStartTime >= 0) { - var elapsedTime = now$$1() - profilerStartTime; + var elapsedTime = now$1() - profilerStartTime; fiber.actualDuration += elapsedTime; if (overrideBaseTime) { fiber.selfBaseDuration = elapsedTime; @@ -10509,11 +11719,13 @@ function prepareToHydrateHostInstance( hostContext ) { if (!supportsHydration) { - invariant( - false, - "Expected prepareToHydrateHostInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var instance = fiber.stateNode; @@ -10537,11 +11749,13 @@ function prepareToHydrateHostInstance( function prepareToHydrateHostTextInstance(fiber) { if (!supportsHydration) { - invariant( - false, - "Expected prepareToHydrateHostTextInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var textInstance = fiber.stateNode; @@ -10585,18 +11799,22 @@ function prepareToHydrateHostTextInstance(fiber) { function skipPastDehydratedSuspenseInstance(fiber) { if (!supportsHydration) { - invariant( - false, - "Expected skipPastDehydratedSuspenseInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var suspenseInstance = fiber.stateNode; - invariant( - suspenseInstance, - "Expected to have a hydrated suspense instance. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!suspenseInstance) { + throw ReactError( + "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance( suspenseInstance ); @@ -10675,17 +11893,21 @@ var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didReceiveUpdate = false; var didWarnAboutBadClass = void 0; +var didWarnAboutModulePatternComponent = void 0; var didWarnAboutContextTypeOnFunctionComponent = void 0; var didWarnAboutGetDerivedStateOnFunctionComponent = void 0; var didWarnAboutFunctionRefs = void 0; var didWarnAboutReassigningProps = void 0; +var didWarnAboutMaxDuration = void 0; { didWarnAboutBadClass = {}; + didWarnAboutModulePatternComponent = {}; didWarnAboutContextTypeOnFunctionComponent = {}; didWarnAboutGetDerivedStateOnFunctionComponent = {}; didWarnAboutFunctionRefs = {}; didWarnAboutReassigningProps = false; + didWarnAboutMaxDuration = false; } function reconcileChildren( @@ -11351,12 +12573,13 @@ function pushHostRootContext(workInProgress) { function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - invariant( - updateQueue !== null, - "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." - ); + (function() { + if (!(updateQueue !== null)) { + throw ReactError( + "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." + ); + } + })(); var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; @@ -11580,13 +12803,16 @@ function mountLazyComponent( // This message intentionally doesn't mention ForwardRef or MemoComponent // because the fact that it's a separate type of work is an // implementation detail. - invariant( - false, - "Element type is invalid. Received a promise that resolves to: %s. " + - "Lazy element type must resolve to a class or function.%s", - Component, - hint - ); + (function() { + { + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + Component + + ". Lazy element type must resolve to a class or function." + + hint + ); + } + })(); } } return child; @@ -11717,6 +12943,24 @@ function mountIndeterminateComponent( typeof value.render === "function" && value.$$typeof === undefined ) { + { + var _componentName = getComponentName(Component) || "Unknown"; + if (!didWarnAboutModulePatternComponent[_componentName]) { + warningWithoutStack$1( + false, + "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 + ); + didWarnAboutModulePatternComponent[_componentName] = true; + } + } + // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; @@ -11838,15 +13082,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { typeof Component.contextType === "object" && Component.contextType !== null ) { - var _componentName = getComponentName(Component) || "Unknown"; + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName]) { + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) { warningWithoutStack$1( false, "%s: Function components do not support contextType.", - _componentName + _componentName2 ); - didWarnAboutContextTypeOnFunctionComponent[_componentName] = true; + didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true; } } } @@ -11859,6 +13103,12 @@ function updateSuspenseComponent( var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; + { + if (shouldSuspend(workInProgress)) { + workInProgress.effectTag |= DidCapture; + } + } + // We should attempt to render the primary children unless this boundary // already suspended during this render (`alreadyCaptured` is true). var nextState = workInProgress.memoizedState; @@ -11872,12 +13122,26 @@ function updateSuspenseComponent( // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. nextState = { - timedOutAt: nextState !== null ? nextState.timedOutAt : NoWork + fallbackExpirationTime: + nextState !== null ? nextState.fallbackExpirationTime : NoWork }; nextDidTimeout = true; workInProgress.effectTag &= ~DidCapture; } + { + if ("maxDuration" in nextProps) { + if (!didWarnAboutMaxDuration) { + didWarnAboutMaxDuration = true; + warning$1( + false, + "maxDuration has been removed from React. " + + "Remove the maxDuration prop." + ); + } + } + } + // This next part is a bit confusing. If the children timeout, we switch to // showing the fallback children in place of the "primary" children. // However, we don't want to delete the primary children because then their @@ -12128,15 +13392,73 @@ function updateSuspenseComponent( return next; } +function retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime +) { + // Detach from the current dehydrated boundary. + current$$1.alternate = null; + workInProgress.alternate = null; + + // Insert a deletion in the effect list. + var returnFiber = workInProgress.return; + (function() { + if (!(returnFiber !== null)) { + throw ReactError( + "Suspense boundaries are never on the root. This is probably a bug in React." + ); + } + })(); + var last = returnFiber.lastEffect; + if (last !== null) { + last.nextEffect = current$$1; + returnFiber.lastEffect = current$$1; + } else { + returnFiber.firstEffect = returnFiber.lastEffect = current$$1; + } + current$$1.nextEffect = null; + current$$1.effectTag = Deletion; + + // Upgrade this work in progress to a real Suspense component. + workInProgress.tag = SuspenseComponent; + workInProgress.stateNode = null; + workInProgress.memoizedState = null; + // This is now an insertion. + workInProgress.effectTag |= Placement; + // Retry as a real Suspense component. + return updateSuspenseComponent(null, workInProgress, renderExpirationTime); +} + function updateDehydratedSuspenseComponent( current$$1, workInProgress, renderExpirationTime ) { + var suspenseInstance = workInProgress.stateNode; if (current$$1 === null) { // During the first pass, we'll bail out and not drill into the children. // Instead, we'll leave the content in place and try to hydrate it later. - workInProgress.expirationTime = Never; + if (isSuspenseInstanceFallback(suspenseInstance)) { + // This is a client-only boundary. Since we won't get any content from the server + // for this, we need to schedule that at a higher priority based on when it would + // have timed out. In theory we could render it in this pass but it would have the + // wrong priority associated with it and will prevent hydration of parent path. + // Instead, we'll leave work left on it to render it in a separate commit. + + // TODO This time should be the time at which the server rendered response that is + // a parent to this boundary was displayed. However, since we currently don't have + // a protocol to transfer that time, we'll just estimate it by using the current + // time. This will mean that Suspense timeouts are slightly shifted to later than + // they should be. + var serverDisplayTime = requestCurrentTime(); + // Schedule a normal pri update to render this content. + workInProgress.expirationTime = computeAsyncExpiration(serverDisplayTime); + } else { + // We'll continue hydrating the rest at offscreen priority since we'll already + // be showing the right content coming from the server, it is no rush. + workInProgress.expirationTime = Never; + } return null; } if ((workInProgress.effectTag & DidCapture) !== NoEffect) { @@ -12145,56 +13467,32 @@ function updateDehydratedSuspenseComponent( workInProgress.child = null; return null; } + if (isSuspenseInstanceFallback(suspenseInstance)) { + // This boundary is in a permanent fallback state. In this case, we'll never + // get an update and we'll never be able to hydrate the final content. Let's just try the + // client side render instead. + return retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime + ); + } // We use childExpirationTime to indicate that a child might depend on context, so if // any context has changed, we need to treat is as if the input might have changed. var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime; - var suspenseInstance = current$$1.stateNode; - if ( - didReceiveUpdate || - hasContextChanged$$1 || - isSuspenseInstanceFallback(suspenseInstance) - ) { + if (didReceiveUpdate || hasContextChanged$$1) { // This boundary has changed since the first render. This means that we are now unable to // hydrate it. We might still be able to hydrate it using an earlier expiration time but // during this render we can't. Instead, we're going to delete the whole subtree and // instead inject a new real Suspense boundary to take its place, which may render content // or fallback. The real Suspense boundary will suspend for a while so we have some time // to ensure it can produce real content, but all state and pending events will be lost. - - // Alternatively, this boundary is in a permanent fallback state. In this case, we'll never - // get an update and we'll never be able to hydrate the final content. Let's just try the - // client side render instead. - - // Detach from the current dehydrated boundary. - current$$1.alternate = null; - workInProgress.alternate = null; - - // Insert a deletion in the effect list. - var returnFiber = workInProgress.return; - invariant( - returnFiber !== null, - "Suspense boundaries are never on the root. " + - "This is probably a bug in React." + return retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime ); - var last = returnFiber.lastEffect; - if (last !== null) { - last.nextEffect = current$$1; - returnFiber.lastEffect = current$$1; - } else { - returnFiber.firstEffect = returnFiber.lastEffect = current$$1; - } - current$$1.nextEffect = null; - current$$1.effectTag = Deletion; - - // Upgrade this work in progress to a real Suspense component. - workInProgress.tag = SuspenseComponent; - workInProgress.stateNode = null; - workInProgress.memoizedState = null; - // This is now an insertion. - workInProgress.effectTag |= Placement; - // Retry as a real Suspense component. - return updateSuspenseComponent(null, workInProgress, renderExpirationTime); } else if (isSuspenseInstancePending(suspenseInstance)) { // This component is still pending more data from the server, so we can't hydrate its // content. We treat it as if this component suspended itself. It might seem as if @@ -12392,6 +13690,55 @@ function updateContextConsumer( return workInProgress.child; } +function updateEventComponent$1( + current$$1, + workInProgress, + renderExpirationTime +) { + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; + + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + pushHostContextForEventComponent(workInProgress); + return workInProgress.child; +} + +function updateEventTarget(current$$1, workInProgress, renderExpirationTime) { + var type = workInProgress.type.type; + var nextProps = workInProgress.pendingProps; + var eventTargetChild = getEventTargetChildElement(type, nextProps); + + { + !(nextProps.children == null) + ? warning$1(false, "Event targets should not have children.") + : void 0; + } + if (eventTargetChild !== null) { + var child = (workInProgress.child = createFiberFromTypeAndProps( + eventTargetChild.type, + null, + eventTargetChild.props, + null, + workInProgress.mode, + renderExpirationTime + )); + child.return = workInProgress; + + if (current$$1 === null || current$$1.child === null) { + child.effectTag = Placement; + } + } else { + reconcileChildren(current$$1, workInProgress, null, renderExpirationTime); + } + pushHostContextForEventTarget(workInProgress); + return workInProgress.child; +} + function markWorkInProgressReceivedUpdate() { didReceiveUpdate = true; } @@ -12428,7 +13775,7 @@ function bailoutOnAlreadyFinishedWork( } } -function beginWork(current$$1, workInProgress, renderExpirationTime) { +function beginWork$1(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if (current$$1 !== null) { @@ -12521,8 +13868,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { // been unsuspended it has committed as a regular Suspense component. // If it needs to be retried, it should have work scheduled on it. workInProgress.effectTag |= DidCapture; - break; } + break; + } + case EventComponent: + if (enableEventAPI) { + pushHostContextForEventComponent(workInProgress); + } + break; + case EventTarget: { + if (enableEventAPI) { + pushHostContextForEventTarget(workInProgress); + } + break; } } return bailoutOnAlreadyFinishedWork( @@ -12707,920 +14065,34 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } break; } - } - invariant( - false, - "Unknown unit of work tag. This error is likely caused by a bug in " + - "React. Please file an issue." - ); -} - -var valueCursor = createCursor(null); - -var rendererSigil = void 0; -{ - // Use this to detect multiple renderers using the same context - rendererSigil = {}; -} - -var currentlyRenderingFiber = null; -var lastContextDependency = null; -var lastContextWithAllBitsObserved = null; - -var isDisallowedContextReadInDEV = false; - -function resetContextDependences() { - // This is called right before React yields execution, to ensure `readContext` - // cannot be called outside the render phase. - currentlyRenderingFiber = null; - lastContextDependency = null; - lastContextWithAllBitsObserved = null; - { - isDisallowedContextReadInDEV = false; - } -} - -function enterDisallowedContextReadInDEV() { - { - isDisallowedContextReadInDEV = true; - } -} - -function exitDisallowedContextReadInDEV() { - { - isDisallowedContextReadInDEV = false; - } -} - -function pushProvider(providerFiber, nextValue) { - var context = providerFiber.type._context; - - if (isPrimaryRenderer) { - push(valueCursor, context._currentValue, providerFiber); - - context._currentValue = nextValue; - { - !( - context._currentRenderer === undefined || - context._currentRenderer === null || - context._currentRenderer === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; - context._currentRenderer = rendererSigil; - } - } else { - push(valueCursor, context._currentValue2, providerFiber); - - context._currentValue2 = nextValue; - { - !( - context._currentRenderer2 === undefined || - context._currentRenderer2 === null || - context._currentRenderer2 === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; - context._currentRenderer2 = rendererSigil; - } - } -} - -function popProvider(providerFiber) { - var currentValue = valueCursor.current; - - pop(valueCursor, providerFiber); - - var context = providerFiber.type._context; - if (isPrimaryRenderer) { - context._currentValue = currentValue; - } else { - context._currentValue2 = currentValue; - } -} - -function calculateChangedBits(context, newValue, oldValue) { - if (is(oldValue, newValue)) { - // No change - return 0; - } else { - var changedBits = - typeof context._calculateChangedBits === "function" - ? context._calculateChangedBits(oldValue, newValue) - : maxSigned31BitInt; - - { - !((changedBits & maxSigned31BitInt) === changedBits) - ? warning$1( - false, - "calculateChangedBits: Expected the return value to be a " + - "31-bit integer. Instead received: %s", - changedBits - ) - : void 0; - } - return changedBits | 0; - } -} - -function scheduleWorkOnParentPath(parent, renderExpirationTime) { - // Update the child expiration time of all the ancestors, including - // the alternates. - var node = parent; - while (node !== null) { - var alternate = node.alternate; - if (node.childExpirationTime < renderExpirationTime) { - node.childExpirationTime = renderExpirationTime; - if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; + case EventComponent: { + if (enableEventAPI) { + return updateEventComponent$1( + current$$1, + workInProgress, + renderExpirationTime + ); } - } else if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; - } else { - // Neither alternate was updated, which means the rest of the - // ancestor path already has sufficient priority. break; } - node = node.return; - } -} - -function propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime -) { - var fiber = workInProgress.child; - if (fiber !== null) { - // Set the return pointer of the child to the work-in-progress fiber. - fiber.return = workInProgress; - } - while (fiber !== null) { - var nextFiber = void 0; - - // Visit this fiber. - var list = fiber.contextDependencies; - if (list !== null) { - nextFiber = fiber.child; - - var dependency = list.first; - while (dependency !== null) { - // Check if the context matches. - if ( - dependency.context === context && - (dependency.observedBits & changedBits) !== 0 - ) { - // Match! Schedule an update on this fiber. - - if (fiber.tag === ClassComponent) { - // Schedule a force update on the work-in-progress. - var update = createUpdate(renderExpirationTime); - update.tag = ForceUpdate; - // TODO: Because we don't have a work-in-progress, this will add the - // update to the current fiber, too, which means it will persist even if - // this render is thrown away. Since it's a race condition, not sure it's - // worth fixing. - enqueueUpdate(fiber, update); - } - - if (fiber.expirationTime < renderExpirationTime) { - fiber.expirationTime = renderExpirationTime; - } - var alternate = fiber.alternate; - if ( - alternate !== null && - alternate.expirationTime < renderExpirationTime - ) { - alternate.expirationTime = renderExpirationTime; - } - - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); - - // Mark the expiration time on the list, too. - if (list.expirationTime < renderExpirationTime) { - list.expirationTime = renderExpirationTime; - } - - // Since we already found a match, we can stop traversing the - // dependency list. - break; - } - dependency = dependency.next; - } - } else if (fiber.tag === ContextProvider) { - // Don't scan deeper if this is a matching provider - nextFiber = fiber.type === workInProgress.type ? null : fiber.child; - } else if ( - enableSuspenseServerRenderer && - fiber.tag === DehydratedSuspenseComponent - ) { - // If a dehydrated suspense component is in this subtree, we don't know - // if it will have any context consumers in it. The best we can do is - // mark it as having updates on its children. - if (fiber.expirationTime < renderExpirationTime) { - fiber.expirationTime = renderExpirationTime; - } - var _alternate = fiber.alternate; - if ( - _alternate !== null && - _alternate.expirationTime < renderExpirationTime - ) { - _alternate.expirationTime = renderExpirationTime; - } - // This is intentionally passing this fiber as the parent - // because we want to schedule this fiber as having work - // on its children. We'll use the childExpirationTime on - // this fiber to indicate that a context has changed. - scheduleWorkOnParentPath(fiber, renderExpirationTime); - nextFiber = fiber.sibling; - } else { - // Traverse down. - nextFiber = fiber.child; - } - - if (nextFiber !== null) { - // Set the return pointer of the child to the work-in-progress fiber. - nextFiber.return = fiber; - } else { - // No child. Traverse to next sibling. - nextFiber = fiber; - while (nextFiber !== null) { - if (nextFiber === workInProgress) { - // We're back to the root of this subtree. Exit. - nextFiber = null; - break; - } - var sibling = nextFiber.sibling; - if (sibling !== null) { - // Set the return pointer of the sibling to the work-in-progress fiber. - sibling.return = nextFiber.return; - nextFiber = sibling; - break; - } - // No more siblings. Traverse up. - nextFiber = nextFiber.return; - } - } - fiber = nextFiber; - } -} - -function prepareToReadContext(workInProgress, renderExpirationTime) { - currentlyRenderingFiber = workInProgress; - lastContextDependency = null; - lastContextWithAllBitsObserved = null; - - var currentDependencies = workInProgress.contextDependencies; - if ( - currentDependencies !== null && - currentDependencies.expirationTime >= renderExpirationTime - ) { - // Context list has a pending update. Mark that this fiber performed work. - markWorkInProgressReceivedUpdate(); - } - - // Reset the work-in-progress list - workInProgress.contextDependencies = null; -} - -function readContext(context, observedBits) { - { - // This warning would fire if you read context inside a Hook like useMemo. - // Unlike the class check below, it's not enforced in production for perf. - !!isDisallowedContextReadInDEV - ? warning$1( - false, - "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()." - ) - : void 0; - } - - if (lastContextWithAllBitsObserved === context) { - // Nothing to do. We already observe everything in this context. - } else if (observedBits === false || observedBits === 0) { - // Do not observe any updates. - } else { - var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types. - if ( - typeof observedBits !== "number" || - observedBits === maxSigned31BitInt - ) { - // Observe all updates. - lastContextWithAllBitsObserved = context; - resolvedObservedBits = maxSigned31BitInt; - } else { - resolvedObservedBits = observedBits; - } - - var contextItem = { - context: context, - observedBits: resolvedObservedBits, - next: null - }; - - if (lastContextDependency === null) { - invariant( - currentlyRenderingFiber !== null, - "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()." - ); - - // This is the first dependency for this component. Create a new list. - lastContextDependency = contextItem; - currentlyRenderingFiber.contextDependencies = { - first: contextItem, - expirationTime: NoWork - }; - } else { - // Append a new context item. - lastContextDependency = lastContextDependency.next = contextItem; - } - } - return isPrimaryRenderer ? context._currentValue : context._currentValue2; -} - -// UpdateQueue is a linked list of prioritized updates. -// -// Like fibers, update queues come in pairs: a current queue, which represents -// the visible state of the screen, and a work-in-progress queue, which can be -// mutated and processed asynchronously before it is committed — a form of -// double buffering. If a work-in-progress render is discarded before finishing, -// we create a new work-in-progress by cloning the current queue. -// -// Both queues share a persistent, singly-linked list structure. To schedule an -// update, we append it to the end of both queues. Each queue maintains a -// pointer to first update in the persistent list that hasn't been processed. -// The work-in-progress pointer always has a position equal to or greater than -// the current queue, since we always work on that one. The current queue's -// pointer is only updated during the commit phase, when we swap in the -// work-in-progress. -// -// For example: -// -// Current pointer: A - B - C - D - E - F -// Work-in-progress pointer: D - E - F -// ^ -// The work-in-progress queue has -// processed more updates than current. -// -// The reason we append to both queues is because otherwise we might drop -// updates without ever processing them. For example, if we only add updates to -// the work-in-progress queue, some updates could be lost whenever a work-in -// -progress render restarts by cloning from current. Similarly, if we only add -// updates to the current queue, the updates will be lost whenever an already -// in-progress queue commits and swaps with the current queue. However, by -// adding to both queues, we guarantee that the update will be part of the next -// work-in-progress. (And because the work-in-progress queue becomes the -// current queue once it commits, there's no danger of applying the same -// update twice.) -// -// Prioritization -// -------------- -// -// Updates are not sorted by priority, but by insertion; new updates are always -// appended to the end of the list. -// -// The priority is still important, though. When processing the update queue -// during the render phase, only the updates with sufficient priority are -// included in the result. If we skip an update because it has insufficient -// priority, it remains in the queue to be processed later, during a lower -// priority render. Crucially, all updates subsequent to a skipped update also -// remain in the queue *regardless of their priority*. That means high priority -// updates are sometimes processed twice, at two separate priorities. We also -// keep track of a base state, that represents the state before the first -// update in the queue is applied. -// -// For example: -// -// Given a base state of '', and the following queue of updates -// -// A1 - B2 - C1 - D2 -// -// where the number indicates the priority, and the update is applied to the -// previous state by appending a letter, React will process these updates as -// two separate renders, one per distinct priority level: -// -// First render, at priority 1: -// Base state: '' -// Updates: [A1, C1] -// Result state: 'AC' -// -// Second render, at priority 2: -// Base state: 'A' <- The base state does not include C1, -// because B2 was skipped. -// Updates: [B2, C1, D2] <- C1 was rebased on top of B2 -// Result state: 'ABCD' -// -// Because we process updates in insertion order, and rebase high priority -// updates when preceding updates are skipped, the final result is deterministic -// regardless of priority. Intermediate state may vary according to system -// resources, but the final state is always the same. - -var UpdateState = 0; -var ReplaceState = 1; -var ForceUpdate = 2; -var CaptureUpdate = 3; - -// Global state that is reset at the beginning of calling `processUpdateQueue`. -// It should only be read right after calling `processUpdateQueue`, via -// `checkHasForceUpdateAfterProcessing`. -var hasForceUpdate = false; - -var didWarnUpdateInsideUpdate = void 0; -var currentlyProcessingQueue = void 0; -var resetCurrentlyProcessingQueue = void 0; -{ - didWarnUpdateInsideUpdate = false; - currentlyProcessingQueue = null; - resetCurrentlyProcessingQueue = function() { - currentlyProcessingQueue = null; - }; -} - -function createUpdateQueue(baseState) { - var queue = { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; - return queue; -} - -function cloneUpdateQueue(currentQueue) { - var queue = { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - - // TODO: With resuming, if we bail out and resuse the child tree, we should - // keep these effects. - firstCapturedUpdate: null, - lastCapturedUpdate: null, - - firstEffect: null, - lastEffect: null, - - firstCapturedEffect: null, - lastCapturedEffect: null - }; - return queue; -} - -function createUpdate(expirationTime) { - return { - expirationTime: expirationTime, - - tag: UpdateState, - payload: null, - callback: null, - - next: null, - nextEffect: null - }; -} - -function appendUpdateToQueue(queue, update) { - // Append the update to the end of the list. - if (queue.lastUpdate === null) { - // Queue is empty - queue.firstUpdate = queue.lastUpdate = update; - } else { - queue.lastUpdate.next = update; - queue.lastUpdate = update; - } -} - -function enqueueUpdate(fiber, update) { - // Update queues are created lazily. - var alternate = fiber.alternate; - var queue1 = void 0; - var queue2 = void 0; - if (alternate === null) { - // There's only one fiber. - queue1 = fiber.updateQueue; - queue2 = null; - if (queue1 === null) { - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - } - } else { - // There are two owners. - queue1 = fiber.updateQueue; - queue2 = alternate.updateQueue; - if (queue1 === null) { - if (queue2 === null) { - // Neither fiber has an update queue. Create new ones. - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState + case EventTarget: { + if (enableEventAPI) { + return updateEventTarget( + current$$1, + workInProgress, + renderExpirationTime ); - } else { - // Only one fiber has an update queue. Clone to create a new one. - queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); - } - } else { - if (queue2 === null) { - // Only one fiber has an update queue. Clone to create a new one. - queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); - } else { - // Both owners have an update queue. } + break; } } - if (queue2 === null || queue1 === queue2) { - // There's only a single queue. - appendUpdateToQueue(queue1, update); - } else { - // There are two queues. We need to append the update to both queues, - // while accounting for the persistent structure of the list — we don't - // want the same update to be added multiple times. - if (queue1.lastUpdate === null || queue2.lastUpdate === null) { - // One of the queues is not empty. We must add the update to both queues. - appendUpdateToQueue(queue1, update); - appendUpdateToQueue(queue2, update); - } else { - // Both queues are non-empty. The last update is the same in both lists, - // because of structural sharing. So, only append to one of the lists. - appendUpdateToQueue(queue1, update); - // But we still need to update the `lastUpdate` pointer of queue2. - queue2.lastUpdate = update; - } - } - - { - if ( - fiber.tag === ClassComponent && - (currentlyProcessingQueue === queue1 || - (queue2 !== null && currentlyProcessingQueue === queue2)) && - !didWarnUpdateInsideUpdate - ) { - warningWithoutStack$1( - false, - "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." + (function() { + { + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); - didWarnUpdateInsideUpdate = true; } - } -} - -function enqueueCapturedUpdate(workInProgress, update) { - // Captured updates go into a separate list, and only on the work-in- - // progress queue. - var workInProgressQueue = workInProgress.updateQueue; - if (workInProgressQueue === null) { - workInProgressQueue = workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - ); - } else { - // TODO: I put this here rather than createWorkInProgress so that we don't - // clone the queue unnecessarily. There's probably a better way to - // structure this. - workInProgressQueue = ensureWorkInProgressQueueIsAClone( - workInProgress, - workInProgressQueue - ); - } - - // Append the update to the end of the list. - if (workInProgressQueue.lastCapturedUpdate === null) { - // This is the first render phase update - workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update; - } else { - workInProgressQueue.lastCapturedUpdate.next = update; - workInProgressQueue.lastCapturedUpdate = update; - } -} - -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; - if (current !== null) { - // If the work-in-progress queue is equal to the current queue, - // we need to clone it first. - if (queue === current.updateQueue) { - queue = workInProgress.updateQueue = cloneUpdateQueue(queue); - } - } - return queue; -} - -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case ReplaceState: { - var _payload = update.payload; - if (typeof _payload === "function") { - // Updater function - { - enterDisallowedContextReadInDEV(); - if ( - debugRenderPhaseSideEffects || - (debugRenderPhaseSideEffectsForStrictMode && - workInProgress.mode & StrictMode) - ) { - _payload.call(instance, prevState, nextProps); - } - } - var nextState = _payload.call(instance, prevState, nextProps); - { - exitDisallowedContextReadInDEV(); - } - return nextState; - } - // State object - return _payload; - } - case CaptureUpdate: { - workInProgress.effectTag = - (workInProgress.effectTag & ~ShouldCapture) | DidCapture; - } - // Intentional fallthrough - case UpdateState: { - var _payload2 = update.payload; - var partialState = void 0; - if (typeof _payload2 === "function") { - // Updater function - { - enterDisallowedContextReadInDEV(); - if ( - debugRenderPhaseSideEffects || - (debugRenderPhaseSideEffectsForStrictMode && - workInProgress.mode & StrictMode) - ) { - _payload2.call(instance, prevState, nextProps); - } - } - partialState = _payload2.call(instance, prevState, nextProps); - { - exitDisallowedContextReadInDEV(); - } - } else { - // Partial state object - partialState = _payload2; - } - if (partialState === null || partialState === undefined) { - // Null and undefined are treated as no-ops. - return prevState; - } - // Merge the partial state and the previous state. - return Object.assign({}, prevState, partialState); - } - case ForceUpdate: { - hasForceUpdate = true; - return prevState; - } - } - return prevState; -} - -function processUpdateQueue( - workInProgress, - queue, - props, - instance, - renderExpirationTime -) { - hasForceUpdate = false; - - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - - { - currentlyProcessingQueue = queue; - } - - // These values may change as we process the queue. - var newBaseState = queue.baseState; - var newFirstUpdate = null; - var newExpirationTime = NoWork; - - // Iterate through the list of updates to compute the result. - var update = queue.firstUpdate; - var resultState = newBaseState; - while (update !== null) { - var updateExpirationTime = update.expirationTime; - if (updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstUpdate === null) { - // This is the first skipped update. It will be the first update in - // the new list. - newFirstUpdate = update; - // Since this is the first update that was skipped, the current result - // is the new base state. - newBaseState = resultState; - } - // Since this update will remain in the list, update the remaining - // expiration time. - if (newExpirationTime < updateExpirationTime) { - newExpirationTime = updateExpirationTime; - } - } else { - // This update does have sufficient priority. Process it and compute - // a new result. - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var _callback = update.callback; - if (_callback !== null) { - workInProgress.effectTag |= Callback; - // Set this to null, in case it was mutated during an aborted render. - update.nextEffect = null; - if (queue.lastEffect === null) { - queue.firstEffect = queue.lastEffect = update; - } else { - queue.lastEffect.nextEffect = update; - queue.lastEffect = update; - } - } - } - // Continue to the next update. - update = update.next; - } - - // Separately, iterate though the list of captured updates. - var newFirstCapturedUpdate = null; - update = queue.firstCapturedUpdate; - while (update !== null) { - var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstCapturedUpdate === null) { - // This is the first skipped captured update. It will be the first - // update in the new list. - newFirstCapturedUpdate = update; - // If this is the first update that was skipped, the current result is - // the new base state. - if (newFirstUpdate === null) { - newBaseState = resultState; - } - } - // Since this update will remain in the list, update the remaining - // expiration time. - if (newExpirationTime < _updateExpirationTime) { - newExpirationTime = _updateExpirationTime; - } - } else { - // This update does have sufficient priority. Process it and compute - // a new result. - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var _callback2 = update.callback; - if (_callback2 !== null) { - workInProgress.effectTag |= Callback; - // Set this to null, in case it was mutated during an aborted render. - update.nextEffect = null; - if (queue.lastCapturedEffect === null) { - queue.firstCapturedEffect = queue.lastCapturedEffect = update; - } else { - queue.lastCapturedEffect.nextEffect = update; - queue.lastCapturedEffect = update; - } - } - } - update = update.next; - } - - if (newFirstUpdate === null) { - queue.lastUpdate = null; - } - if (newFirstCapturedUpdate === null) { - queue.lastCapturedUpdate = null; - } else { - workInProgress.effectTag |= Callback; - } - if (newFirstUpdate === null && newFirstCapturedUpdate === null) { - // We processed every update, without skipping. That means the new base - // state is the same as the result state. - newBaseState = resultState; - } - - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = newFirstCapturedUpdate; - - // Set the remaining expiration time to be whatever is remaining in the queue. - // This should be fine because the only two other things that contribute to - // expiration time are props and context. We're already in the middle of the - // begin phase by the time we start processing the queue, so we've already - // dealt with the props. Context in components that specify - // shouldComponentUpdate is tricky; but we'll have to account for - // that regardless. - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; - - { - currentlyProcessingQueue = null; - } -} - -function callCallback(callback, context) { - invariant( - typeof callback === "function", - "Invalid argument passed as callback. Expected a function. Instead " + - "received: %s", - callback - ); - callback.call(context); -} - -function resetHasForceUpdateBeforeProcessing() { - hasForceUpdate = false; -} - -function checkHasForceUpdateAfterProcessing() { - return hasForceUpdate; -} - -function commitUpdateQueue( - finishedWork, - finishedQueue, - instance, - renderExpirationTime -) { - // If the finished render included captured updates, and there are still - // lower priority updates left over, we need to keep the captured updates - // in the queue so that they are rebased and not dropped once we process the - // queue again at the lower priority. - if (finishedQueue.firstCapturedUpdate !== null) { - // Join the captured update list to the end of the normal list. - if (finishedQueue.lastUpdate !== null) { - finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate; - finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate; - } - // Clear the list of captured updates. - finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null; - } - - // Commit the effects - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} - -function commitUpdateEffects(effect, instance) { - while (effect !== null) { - var _callback3 = effect.callback; - if (_callback3 !== null) { - effect.callback = null; - callCallback(_callback3, instance); - } - effect = effect.nextEffect; - } -} - -function createCapturedValue(value, source) { - // If the value is an error, call this function immediately after it is thrown - // so the stack is accurate. - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; + })(); } function markUpdate(workInProgress) { @@ -13741,43 +14213,19 @@ if (supportsMutation) { // eslint-disable-next-line no-labels branches: if (node.tag === HostComponent) { var instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var props = node.memoizedProps; var type = node.type; - if (isHidden) { - // This child is inside a timed out tree. Hide it. - instance = cloneHiddenInstance(instance, type, props, node); - } else { - // This child was previously inside a timed out tree. If it was not - // updated during this render, it may need to be unhidden. Clone - // again to be sure. - instance = cloneUnhiddenInstance(instance, type, props, node); - } - node.stateNode = instance; + instance = cloneHiddenInstance(instance, type, props, node); } appendInitialChild(parent, instance); } else if (node.tag === HostText) { var _instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var text = node.memoizedProps; - var rootContainerInstance = getRootHostContainer(); - var currentHostContext = getHostContext(); - if (isHidden) { - _instance = createHiddenTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } else { - _instance = createTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } - node.stateNode = _instance; + _instance = cloneHiddenTextInstance(_instance, text, node); } appendInitialChild(parent, _instance); } else if (node.tag === HostPortal) { @@ -13785,22 +14233,28 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - var current = node.alternate; - if (current !== null) { - var oldState = current.memoizedState; - var newState = node.memoizedState; - var oldIsHidden = oldState !== null; - var newIsHidden = newState !== null; - if (oldIsHidden !== newIsHidden) { - // The placeholder either just timed out or switched back to the normal - // children after having previously timed out. Toggle the visibility of - // the direct host children. - var primaryChildParent = newIsHidden ? node.child : node; + if ((node.effectTag & Update) !== NoEffect) { + // Need to toggle the visibility of the primary children. + var newIsHidden = node.memoizedState !== null; + if (newIsHidden) { + var primaryChildParent = node.child; if (primaryChildParent !== null) { - appendAllChildren(parent, primaryChildParent, true, newIsHidden); + if (primaryChildParent.child !== null) { + primaryChildParent.child.return = primaryChildParent; + appendAllChildren( + parent, + primaryChildParent, + true, + newIsHidden + ); + } + var fallbackChildParent = primaryChildParent.sibling; + if (fallbackChildParent !== null) { + fallbackChildParent.return = node; + node = fallbackChildParent; + continue; + } } - // eslint-disable-next-line no-labels - break branches; } } if (node.child !== null) { @@ -13844,43 +14298,19 @@ if (supportsMutation) { // eslint-disable-next-line no-labels branches: if (node.tag === HostComponent) { var instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var props = node.memoizedProps; var type = node.type; - if (isHidden) { - // This child is inside a timed out tree. Hide it. - instance = cloneHiddenInstance(instance, type, props, node); - } else { - // This child was previously inside a timed out tree. If it was not - // updated during this render, it may need to be unhidden. Clone - // again to be sure. - instance = cloneUnhiddenInstance(instance, type, props, node); - } - node.stateNode = instance; + instance = cloneHiddenInstance(instance, type, props, node); } appendChildToContainerChildSet(containerChildSet, instance); } else if (node.tag === HostText) { var _instance2 = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var text = node.memoizedProps; - var rootContainerInstance = getRootHostContainer(); - var currentHostContext = getHostContext(); - if (isHidden) { - _instance2 = createHiddenTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } else { - _instance2 = createTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } - node.stateNode = _instance2; + _instance2 = cloneHiddenTextInstance(_instance2, text, node); } appendChildToContainerChildSet(containerChildSet, _instance2); } else if (node.tag === HostPortal) { @@ -13888,27 +14318,28 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - var current = node.alternate; - if (current !== null) { - var oldState = current.memoizedState; - var newState = node.memoizedState; - var oldIsHidden = oldState !== null; - var newIsHidden = newState !== null; - if (oldIsHidden !== newIsHidden) { - // The placeholder either just timed out or switched back to the normal - // children after having previously timed out. Toggle the visibility of - // the direct host children. - var primaryChildParent = newIsHidden ? node.child : node; + if ((node.effectTag & Update) !== NoEffect) { + // Need to toggle the visibility of the primary children. + var newIsHidden = node.memoizedState !== null; + if (newIsHidden) { + var primaryChildParent = node.child; if (primaryChildParent !== null) { - appendAllChildrenToContainer( - containerChildSet, - primaryChildParent, - true, - newIsHidden - ); + if (primaryChildParent.child !== null) { + primaryChildParent.child.return = primaryChildParent; + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + true, + newIsHidden + ); + } + var fallbackChildParent = primaryChildParent.sibling; + if (fallbackChildParent !== null) { + fallbackChildParent.return = node; + node = fallbackChildParent; + continue; + } } - // eslint-disable-next-line no-labels - break branches; } } if (node.child !== null) { @@ -14112,11 +14543,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } else { if (!newProps) { - invariant( - workInProgress.stateNode !== null, - "We must have new props for new mounts. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(workInProgress.stateNode !== null)) { + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // This can happen when we abort work. break; } @@ -14185,11 +14618,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { updateHostText$1(current, workInProgress, oldText, newText); } else { if (typeof newText !== "string") { - invariant( - workInProgress.stateNode !== null, - "We must have new props for new mounts. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(workInProgress.stateNode !== null)) { + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // This can happen when we abort work. } var _rootContainerInstance = getRootHostContainer(); @@ -14222,37 +14657,72 @@ function completeWork(current, workInProgress, renderExpirationTime) { } var nextDidTimeout = nextState !== null; - var prevDidTimeout = current !== null && current.memoizedState !== null; - + var prevDidTimeout = false; if (current === null) { // In cases where we didn't find a suitable hydration boundary we never // downgraded this to a DehydratedSuspenseComponent, but we still need to // pop the hydration state since we might be inside the insertion tree. popHydrationState(workInProgress); - } else if (!nextDidTimeout && prevDidTimeout) { - // We just switched from the fallback to the normal children. Delete - // the fallback. - // TODO: Would it be better to store the fallback fragment on - var currentFallbackChild = current.child.sibling; - if (currentFallbackChild !== null) { - // Deletions go at the beginning of the return fiber's effect list - var first = workInProgress.firstEffect; - if (first !== null) { - workInProgress.firstEffect = currentFallbackChild; - currentFallbackChild.nextEffect = first; - } else { - workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; - currentFallbackChild.nextEffect = null; + } else { + var prevState = current.memoizedState; + prevDidTimeout = prevState !== null; + if (!nextDidTimeout && prevState !== null) { + // We just switched from the fallback to the normal children. + + // Mark the event time of the switching from fallback to normal children, + // based on the start of when we first showed the fallback. This time + var fallbackExpirationTime = prevState.fallbackExpirationTime; + markRenderEventTime(fallbackExpirationTime); + + // Delete the fallback. + // TODO: Would it be better to store the fallback fragment on + // the stateNode during the begin phase? + var currentFallbackChild = current.child.sibling; + if (currentFallbackChild !== null) { + // Deletions go at the beginning of the return fiber's effect list + var first = workInProgress.firstEffect; + if (first !== null) { + workInProgress.firstEffect = currentFallbackChild; + currentFallbackChild.nextEffect = first; + } else { + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; + currentFallbackChild.nextEffect = null; + } + currentFallbackChild.effectTag = Deletion; } - currentFallbackChild.effectTag = Deletion; } } - if (nextDidTimeout || prevDidTimeout) { - // If the children are hidden, or if they were previous hidden, schedule - // an effect to toggle their visibility. This is also used to attach a - // retry listener to the promise. - workInProgress.effectTag |= Update; + if (nextDidTimeout && !prevDidTimeout) { + // If this subtreee is running in concurrent mode we can suspend, + // otherwise we won't suspend. + // TODO: This will still suspend a synchronous tree if anything + // in the concurrent tree already suspended during this render. + // This is a known bug. + if ((workInProgress.mode & ConcurrentMode) !== NoContext) { + renderDidSuspend(); + } + } + + if (supportsPersistence) { + // TODO: Only schedule updates if not prevDidTimeout. + if (nextDidTimeout) { + // If this boundary just timed out, schedule an effect to attach a + // retry listener to the proimse. This flag is also used to hide the + // primary children. + workInProgress.effectTag |= Update; + } + } + if (supportsMutation) { + // TODO: Only schedule updates if these values are non equal, i.e. it changed. + if (nextDidTimeout || prevDidTimeout) { + // If this boundary just timed out, schedule an effect to attach a + // retry listener to the proimse. This flag is also used to hide the + // primary children. In mutation mode, we also need the flag to + // *unhide* children that were previously hidden, so check if the + // is currently timed out, too. + workInProgress.effectTag |= Update; + } } break; } @@ -14287,11 +14757,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (enableSuspenseServerRenderer) { if (current === null) { var _wasHydrated2 = popHydrationState(workInProgress); - invariant( - _wasHydrated2, - "A dehydrated suspense component was completed without a hydrated node. " + - "This is probably a bug in React." - ); + (function() { + if (!_wasHydrated2) { + throw ReactError( + "A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React." + ); + } + })(); skipPastDehydratedSuspenseInstance(workInProgress); } else if ((workInProgress.effectTag & DidCapture) === NoEffect) { // This boundary did not suspend so it's now hydrated. @@ -14306,12 +14778,67 @@ function completeWork(current, workInProgress, renderExpirationTime) { } break; } + case EventComponent: { + if (enableEventAPI) { + popHostContext(workInProgress); + var _rootContainerInstance2 = getRootHostContainer(); + var responder = workInProgress.type.responder; + var eventComponentInstance = workInProgress.stateNode; + + if (eventComponentInstance === null) { + var responderState = null; + if (responder.createInitialState !== undefined) { + responderState = responder.createInitialState(newProps); + } + eventComponentInstance = workInProgress.stateNode = { + currentFiber: workInProgress, + props: newProps, + responder: responder, + rootEventTypes: null, + rootInstance: _rootContainerInstance2, + state: responderState + }; + markUpdate(workInProgress); + } else { + // Update the props on the event component state node + eventComponentInstance.props = newProps; + // Update the root container, so we can properly unmount events at some point + eventComponentInstance.rootInstance = _rootContainerInstance2; + // Update the current fiber + eventComponentInstance.currentFiber = workInProgress; + updateEventComponent(eventComponentInstance); + } + } + break; + } + case EventTarget: { + if (enableEventAPI) { + popHostContext(workInProgress); + var _type = workInProgress.type.type; + var _rootContainerInstance3 = getRootHostContainer(); + var shouldUpdate = handleEventTarget( + _type, + newProps, + _rootContainerInstance3, + workInProgress + ); + // Update the latest props on the stateNode. This is used + // during the event phase to find the most current props. + workInProgress.stateNode.props = newProps; + if (shouldUpdate) { + markUpdate(workInProgress); + } + } + break; + } default: - invariant( - false, - "Unknown unit of work tag. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } return null; @@ -14328,6 +14855,16 @@ function shouldCaptureSuspense(workInProgress) { return nextState === null; } +function createCapturedValue(value, source) { + // If the value is an error, call this function immediately after it is thrown + // so the stack is accurate. + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; +} + // Module provided by RN: /** * Intercept lifecycle errors and ensure they are shown with the correct stack @@ -14616,14 +15153,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostText: case HostPortal: case IncompleteClassComponent: + case EventTarget: // Nothing to do for these component types return; default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -14659,22 +15199,23 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } else if (typeof _destroy.then === "function") { addendum = "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. " + - "Instead, you may write an async function separately " + - "and then call it from inside the effect:\n\n" + - "async function fetchComment(commentId) {\n" + - " // You can await here\n" + - "}\n\n" + + "Instead, write the async function inside your effect " + + "and call it immediately:\n\n" + "useEffect(() => {\n" + - " fetchComment(commentId);\n" + - "}, [commentId]);\n\n" + - "In the future, React will provide a more idiomatic solution for data fetching " + - "that doesn't involve writing effects manually."; + " 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://fb.me/react-hooks-data-fetching"; } else { addendum = " You returned: " + _destroy; } warningWithoutStack$1( false, - "An Effect function must not return anything besides a function, " + + "An effect function must not return anything besides a function, " + "which is used for clean-up.%s%s", addendum, getStackByFiberInDevAndProd(finishedWork) @@ -14911,15 +15452,52 @@ function commitLifeCycles( return; } case SuspenseComponent: - break; case IncompleteClassComponent: - break; + return; + case EventTarget: { + if (enableEventAPI) { + var _type = finishedWork.type.type; + var _props = finishedWork.memoizedProps; + var _instance3 = finishedWork.stateNode; + var parentInstance = null; + + var node = finishedWork.return; + // Traverse up the fiber tree until we find the parent host node. + while (node !== null) { + if (node.tag === HostComponent) { + parentInstance = node.stateNode; + break; + } else if (node.tag === HostRoot) { + parentInstance = node.stateNode.containerInfo; + break; + } + node = node.return; + } + (function() { + if (!(parentInstance !== null)) { + throw ReactError( + "This should have a parent host component initialized. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + commitEventTarget(_type, _props, _instance3, parentInstance); + } + return; + } + case EventComponent: { + if (enableEventAPI) { + mountEventComponent(finishedWork.stateNode); + } + return; + } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -14937,11 +15515,11 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { unhideInstance(node.stateNode, node.memoizedProps); } } else if (node.tag === HostText) { - var _instance3 = node.stateNode; + var _instance4 = node.stateNode; if (isHidden) { - hideTextInstance(_instance3); + hideTextInstance(_instance4); } else { - unhideTextInstance(_instance3, node.memoizedProps); + unhideTextInstance(_instance4, node.memoizedProps); } } else if ( node.tag === SuspenseComponent && @@ -15066,6 +15644,13 @@ function commitUnmount(current$$1) { } return; } + case EventComponent: { + if (enableEventAPI) { + var eventComponentInstance = current$$1.stateNode; + unmountEventComponent(eventComponentInstance); + current$$1.stateNode = null; + } + } } } @@ -15139,13 +15724,11 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { - return; - } - case HostComponent: { - return; - } - case HostText: { + case ClassComponent: + case HostComponent: + case HostText: + case EventTarget: + case EventComponent: { return; } case HostRoot: @@ -15157,11 +15740,13 @@ function commitContainer(finishedWork) { return; } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -15174,11 +15759,13 @@ function getHostParentFiber(fiber) { } parent = parent.return; } - invariant( - false, - "Expected to find a host parent. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } function isHostParent(fiber) { @@ -15260,11 +15847,13 @@ function commitPlacement(finishedWork) { isContainer = true; break; default: - invariant( - false, - "Invalid host parent fiber. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } if (parentFiber.effectTag & ContentReset) { // Reset the text content of the parent before doing any insertions @@ -15279,17 +15868,18 @@ function commitPlacement(finishedWork) { var node = finishedWork; while (true) { if (node.tag === HostComponent || node.tag === HostText) { + var stateNode = node.stateNode; if (before) { if (isContainer) { - insertInContainerBefore(parent, node.stateNode, before); + insertInContainerBefore(parent, stateNode, before); } else { - insertBefore(parent, node.stateNode, before); + insertBefore(parent, stateNode, before); } } else { if (isContainer) { - appendChildToContainer(parent, node.stateNode); + appendChildToContainer(parent, stateNode); } else { - appendChild$1(parent, node.stateNode); + appendChild$1(parent, stateNode); } } } else if (node.tag === HostPortal) { @@ -15331,11 +15921,13 @@ function unmountHostComponents(current$$1) { if (!currentParentIsValid) { var parent = node.return; findParent: while (true) { - invariant( - parent !== null, - "Expected to find a host parent. This error is likely caused by " + - "a bug in React. Please file an issue." - ); + (function() { + if (!(parent !== null)) { + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); switch (parent.tag) { case HostComponent: currentParent = parent.stateNode; @@ -15438,6 +16030,13 @@ function commitWork(current$$1, finishedWork) { commitHookEffectList(UnmountMutation, MountMutation, finishedWork); return; } + case Profiler: { + return; + } + case SuspenseComponent: { + commitSuspenseComponent(finishedWork); + return; + } } commitContainer(finishedWork); @@ -15485,11 +16084,13 @@ function commitWork(current$$1, finishedWork) { return; } case HostText: { - invariant( - finishedWork.stateNode !== null, - "This should have a text node initialized. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(finishedWork.stateNode !== null)) { + throw ReactError( + "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var textInstance = finishedWork.stateNode; var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps @@ -15499,6 +16100,9 @@ function commitWork(current$$1, finishedWork) { commitTextUpdate(textInstance, oldText, newText); return; } + case EventTarget: { + return; + } case HostRoot: { return; } @@ -15506,63 +16110,75 @@ function commitWork(current$$1, finishedWork) { return; } case SuspenseComponent: { - var newState = finishedWork.memoizedState; - - var newDidTimeout = void 0; - var primaryChildParent = finishedWork; - if (newState === null) { - newDidTimeout = false; - } else { - newDidTimeout = true; - primaryChildParent = finishedWork.child; - if (newState.timedOutAt === NoWork) { - // If the children had not already timed out, record the time. - // This is used to compute the elapsed time during subsequent - // attempts to render the children. - newState.timedOutAt = requestCurrentTime(); - } - } - - if (primaryChildParent !== null) { - hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); - } - - // If this boundary just timed out, then it will have a set of thenables. - // For each thenable, attach a listener so that when it resolves, React - // attempts to re-render the boundary in the primary (pre-timeout) state. - var thenables = finishedWork.updateQueue; - if (thenables !== null) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; - if (retryCache === null) { - retryCache = finishedWork.stateNode = new PossiblyWeakSet$1(); - } - thenables.forEach(function(thenable) { - // Memoize using the boundary fiber to prevent redundant listeners. - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - if (enableSchedulerTracing) { - retry = tracing.unstable_wrap(retry); - } - if (!retryCache.has(thenable)) { - retryCache.add(thenable); - thenable.then(retry, retry); - } - }); - } - + commitSuspenseComponent(finishedWork); return; } case IncompleteClassComponent: { return; } + case EventComponent: { + return; + } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + } + } +} + +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + + var newDidTimeout = void 0; + var primaryChildParent = finishedWork; + if (newState === null) { + newDidTimeout = false; + } else { + newDidTimeout = true; + primaryChildParent = finishedWork.child; + if (newState.fallbackExpirationTime === NoWork) { + // If the children had not already timed out, record the time. + // This is used to compute the elapsed time during subsequent + // attempts to render the children. + // We model this as a normal pri expiration time since that's + // how we infer start time for updates. + newState.fallbackExpirationTime = computeAsyncExpirationNoBucket( + requestCurrentTime() ); } } + + if (supportsMutation && primaryChildParent !== null) { + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + } + + // If this boundary just timed out, then it will have a set of thenables. + // For each thenable, attach a listener so that when it resolves, React + // attempts to re-render the boundary in the primary (pre-timeout) state. + var thenables = finishedWork.updateQueue; + if (thenables !== null) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + if (retryCache === null) { + retryCache = finishedWork.stateNode = new PossiblyWeakSet$1(); + } + thenables.forEach(function(thenable) { + // Memoize using the boundary fiber to prevent redundant listeners. + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + if (!retryCache.has(thenable)) { + if (enableSchedulerTracing) { + retry = tracing.unstable_wrap(retry); + } + retryCache.add(thenable); + thenable.then(retry, retry); + } + }); + } } function commitResetTextContent(current$$1) { @@ -15691,48 +16307,8 @@ function throwException( // This is a thenable. var thenable = value; - // Find the earliest timeout threshold of all the placeholders in the - // ancestor path. We could avoid this traversal by storing the thresholds on - // the stack, but we choose not to because we only hit this path if we're - // IO-bound (i.e. if something suspends). Whereas the stack is used even in - // the non-IO- bound case. - var _workInProgress = returnFiber; - var earliestTimeoutMs = -1; - var startTimeMs = -1; - do { - if (_workInProgress.tag === SuspenseComponent) { - var current$$1 = _workInProgress.alternate; - if (current$$1 !== null) { - var currentState = current$$1.memoizedState; - if (currentState !== null) { - // Reached a boundary that already timed out. Do not search - // any further. - var timedOutAt = currentState.timedOutAt; - startTimeMs = expirationTimeToMs(timedOutAt); - // Do not search any further. - break; - } - } - var timeoutPropMs = _workInProgress.pendingProps.maxDuration; - if (typeof timeoutPropMs === "number") { - if (timeoutPropMs <= 0) { - earliestTimeoutMs = 0; - } else if ( - earliestTimeoutMs === -1 || - timeoutPropMs < earliestTimeoutMs - ) { - earliestTimeoutMs = timeoutPropMs; - } - } - } - // If there is a DehydratedSuspenseComponent we don't have to do anything because - // if something suspends inside it, we will simply leave that as dehydrated. It - // will never timeout. - _workInProgress = _workInProgress.return; - } while (_workInProgress !== null); - // Schedule the nearest Suspense to re-render the timed out view. - _workInProgress = returnFiber; + var _workInProgress = returnFiber; do { if ( _workInProgress.tag === SuspenseComponent && @@ -15758,7 +16334,7 @@ function throwException( // Note: It doesn't matter whether the component that suspended was // inside a concurrent mode tree. If the Suspense is outside of it, we // should *not* suspend the commit. - if ((_workInProgress.mode & ConcurrentMode) === NoEffect) { + if ((_workInProgress.mode & ConcurrentMode) === NoContext) { _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete. @@ -15796,41 +16372,6 @@ function throwException( attachPingListener(root, renderExpirationTime, thenable); - var absoluteTimeoutMs = void 0; - if (earliestTimeoutMs === -1) { - // If no explicit threshold is given, default to an arbitrarily large - // value. The actual size doesn't matter because the threshold for the - // whole tree will be clamped to the expiration time. - absoluteTimeoutMs = maxSigned31BitInt; - } else { - if (startTimeMs === -1) { - // This suspend happened outside of any already timed-out - // placeholders. We don't know exactly when the update was - // scheduled, but we can infer an approximate start time from the - // expiration time. First, find the earliest uncommitted expiration - // time in the tree, including work that is suspended. Then subtract - // the offset used to compute an async update's expiration time. - // This will cause high priority (interactive) work to expire - // earlier than necessary, but we can account for this by adjusting - // for the Just Noticeable Difference. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; - } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; - } - - // Mark the earliest timeout in the suspended fiber's ancestor path. - // After completing the root, we'll take the largest of all the - // suspended fiber's timeouts and use it to compute a timeout for the - // whole tree. - renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); - _workInProgress.effectTag |= ShouldCapture; _workInProgress.expirationTime = renderExpirationTime; return; @@ -15844,13 +16385,15 @@ function throwException( var retryCache = _workInProgress.memoizedState; if (retryCache === null) { retryCache = _workInProgress.memoizedState = new PossiblyWeakSet(); - var _current = _workInProgress.alternate; - invariant( - _current, - "A dehydrated suspense boundary must commit before trying to render. " + - "This is probably a bug in React." - ); - _current.memoizedState = retryCache; + var current$$1 = _workInProgress.alternate; + (function() { + if (!current$$1) { + throw ReactError( + "A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React." + ); + } + })(); + current$$1.memoizedState = retryCache; } // Memoize using the boundary fiber to prevent redundant listeners. if (!retryCache.has(thenable)) { @@ -15954,11 +16497,13 @@ function unwindWork(workInProgress, renderExpirationTime) { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); var _effectTag = workInProgress.effectTag; - invariant( - (_effectTag & DidCapture) === NoEffect, - "The root failed to unmount after an error. This is likely a bug in " + - "React. Please file an issue." - ); + (function() { + if (!((_effectTag & DidCapture) === NoEffect)) { + throw ReactError( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + } + })(); workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } @@ -15995,6 +16540,12 @@ function unwindWork(workInProgress, renderExpirationTime) { case ContextProvider: popProvider(workInProgress); return null; + case EventComponent: + case EventTarget: + if (enableEventAPI) { + popHostContext(workInProgress); + } + return null; default: return null; } @@ -16029,1518 +16580,200 @@ function unwindInterruptedWork(interruptedWork) { } } +// TODO: Ahaha Andrew is bad at spellling +// DEV stuff +var ceil = Math.ceil; + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; +var ReactShouldWarnActingUpdates = + ReactSharedInternals.ReactShouldWarnActingUpdates; -var didWarnAboutStateTransition = void 0; -var didWarnSetStateChildContext = void 0; -var warnAboutUpdateOnUnmounted = void 0; -var warnAboutInvalidUpdates = void 0; +var NotWorking = 0; +var BatchedPhase = 1; +var LegacyUnbatchedPhase = 2; +var RenderPhase = 4; +var CommitPhase = 5; -if (enableSchedulerTracing) { - // Provide explicit error message when production+profiling bundle of e.g. react-dom - // is used with production (non-profiling) bundle of scheduler/tracing - invariant( - tracing.__interactionsRef != null && - tracing.__interactionsRef.current != null, - "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 http://fb.me/react-profiling" - ); -} +var RootIncomplete = 0; +var RootErrored = 1; +var RootSuspended = 2; +var RootCompleted = 3; -{ - didWarnAboutStateTransition = false; - didWarnSetStateChildContext = false; - var didWarnStateUpdateForUnmountedComponent = {}; +// The phase of work we're currently in +var workPhase = NotWorking; +// The root we're working on +var workInProgressRoot = null; +// The fiber we're working on +var workInProgress = null; +// The expiration time we're rendering +var renderExpirationTime = NoWork; +// Whether to root completed, errored, suspended, etc. +var workInProgressRootExitStatus = RootIncomplete; +// Most recent event time among processed updates during this render. +// This is conceptually a time stamp but expressed in terms of an ExpirationTime +// because we deal mostly with expiration times in the hot path, so this avoids +// the conversion happening in the hot path. +var workInProgressRootMostRecentEventTime = Sync; - warnAboutUpdateOnUnmounted = function(fiber, isClass) { - // We show the whole stack but dedupe on the top component's name because - // the problematic code almost always lies inside that component. - var componentName = getComponentName(fiber.type) || "ReactComponent"; - if (didWarnStateUpdateForUnmountedComponent[componentName]) { - return; - } - warningWithoutStack$1( - false, - "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.%s", - isClass - ? "the componentWillUnmount method" - : "a useEffect cleanup function", - getStackByFiberInDevAndProd(fiber) - ); - didWarnStateUpdateForUnmountedComponent[componentName] = true; - }; - - warnAboutInvalidUpdates = function(instance) { - switch (phase) { - case "getChildContext": - if (didWarnSetStateChildContext) { - return; - } - warningWithoutStack$1( - false, - "setState(...): Cannot call setState() inside getChildContext()" - ); - didWarnSetStateChildContext = true; - break; - case "render": - if (didWarnAboutStateTransition) { - return; - } - warningWithoutStack$1( - false, - "Cannot update during an existing state transition (such as within " + - "`render`). Render methods should be a pure function of props and state." - ); - didWarnAboutStateTransition = true; - break; - } - }; -} - -var isWorking = false; - -// The next work in progress fiber that we're currently working on. -var nextUnitOfWork = null; -var nextRoot = null; -// The time at which we're currently rendering work. -var nextRenderExpirationTime = NoWork; -var nextLatestAbsoluteTimeoutMs = -1; -var nextRenderDidError = false; - -// The next fiber with an effect that we're currently committing. var nextEffect = null; - -var isCommitting$1 = false; -var rootWithPendingPassiveEffects = null; -var passiveEffectCallbackHandle = null; -var passiveEffectCallback = null; - +var hasUncaughtError = false; +var firstUncaughtError = null; var legacyErrorBoundariesThatAlreadyFailed = null; -// Used for performance tracking. +var rootDoesHavePassiveEffects = false; +var rootWithPendingPassiveEffects = null; +var pendingPassiveEffectsExpirationTime = NoWork; + +var rootsWithPendingDiscreteUpdates = null; + +// Use these to prevent an infinite loop of nested updates +var NESTED_UPDATE_LIMIT = 50; +var nestedUpdateCount = 0; +var rootWithNestedUpdates = null; + +var NESTED_PASSIVE_UPDATE_LIMIT = 50; +var nestedPassiveUpdateCount = 0; + var interruptedBy = null; -var stashedWorkInProgressProperties = void 0; -var replayUnitOfWork = void 0; -var mayReplayFailedUnitOfWork = void 0; -var isReplayingFailedUnitOfWork = void 0; -var originalReplayError = void 0; -var rethrowOriginalError = void 0; -if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - stashedWorkInProgressProperties = null; - mayReplayFailedUnitOfWork = true; - isReplayingFailedUnitOfWork = false; - originalReplayError = null; - replayUnitOfWork = function(failedUnitOfWork, thrownValue, isYieldy) { - if ( - thrownValue !== null && - typeof thrownValue === "object" && - typeof thrownValue.then === "function" - ) { - // Don't replay promises. Treat everything else like an error. - // TODO: Need to figure out a different strategy if/when we add - // support for catching other types. - return; - } +// Expiration times are computed by adding to the current time (the start +// time). However, if two updates are scheduled within the same event, we +// should treat their start times as simultaneous, even if the actual clock +// time has advanced between the first and second call. - // Restore the original state of the work-in-progress - if (stashedWorkInProgressProperties === null) { - // This should never happen. Don't throw because this code is DEV-only. - warningWithoutStack$1( - false, - "Could not replay rendering after an error. This is likely a bug in React. " + - "Please file an issue." - ); - return; - } - assignFiberPropertiesInDEV( - failedUnitOfWork, - stashedWorkInProgressProperties - ); +// In other words, because expiration times determine how updates are batched, +// we want all updates of like priority that occur within the same event to +// receive the same expiration time. Otherwise we get tearing. +var currentEventTime = NoWork; - switch (failedUnitOfWork.tag) { - case HostRoot: - popHostContainer(failedUnitOfWork); - popTopLevelContextObject(failedUnitOfWork); - break; - case HostComponent: - popHostContext(failedUnitOfWork); - break; - case ClassComponent: { - var Component = failedUnitOfWork.type; - if (isContextProvider(Component)) { - popContext(failedUnitOfWork); - } - break; - } - case HostPortal: - popHostContainer(failedUnitOfWork); - break; - case ContextProvider: - popProvider(failedUnitOfWork); - break; - } - // Replay the begin phase. - isReplayingFailedUnitOfWork = true; - originalReplayError = thrownValue; - invokeGuardedCallback(null, workLoop, null, isYieldy); - isReplayingFailedUnitOfWork = false; - originalReplayError = null; - if (hasCaughtError()) { - var replayError = clearCaughtError(); - if (replayError != null && thrownValue != null) { - try { - // Reading the expando property is intentionally - // inside `try` because it might be a getter or Proxy. - if (replayError._suppressLogging) { - // Also suppress logging for the original error. - thrownValue._suppressLogging = true; - } - } catch (inner) { - // Ignore. - } - } - } else { - // If the begin phase did not fail the second time, set this pointer - // back to the original value. - nextUnitOfWork = failedUnitOfWork; - } - }; - rethrowOriginalError = function() { - throw originalReplayError; - }; -} - -function resetStack() { - if (nextUnitOfWork !== null) { - var interruptedWork = nextUnitOfWork.return; - while (interruptedWork !== null) { - unwindInterruptedWork(interruptedWork); - interruptedWork = interruptedWork.return; - } +function requestCurrentTime() { + if (workPhase === RenderPhase || workPhase === CommitPhase) { + // We're inside React, so it's fine to read the actual time. + return msToExpirationTime(now()); } - - { - ReactStrictModeWarnings.discardPendingWarnings(); - checkThatStackIsEmpty(); + // We're not inside React, so we may be in the middle of a browser event. + if (currentEventTime !== NoWork) { + // Use the same start time for all updates until we enter React again. + return currentEventTime; } - - nextRoot = null; - nextRenderExpirationTime = NoWork; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = false; - nextUnitOfWork = null; -} - -function commitAllHostEffects() { - while (nextEffect !== null) { - { - setCurrentFiber(nextEffect); - } - recordEffect(); - - var effectTag = nextEffect.effectTag; - - if (effectTag & ContentReset) { - commitResetTextContent(nextEffect); - } - - if (effectTag & Ref) { - var current$$1 = nextEffect.alternate; - if (current$$1 !== null) { - commitDetachRef(current$$1); - } - } - - // The following switch statement is only concerned about placement, - // updates, and deletions. To avoid needing to add a case for every - // possible bitmap value, we remove the secondary effects from the - // effect tag and switch on that value. - var primaryEffectTag = effectTag & (Placement | Update | Deletion); - switch (primaryEffectTag) { - case Placement: { - commitPlacement(nextEffect); - // Clear the "placement" from effect tag so that we know that this is inserted, before - // any life-cycles like componentDidMount gets called. - // TODO: findDOMNode doesn't rely on this any more but isMounted - // does and isMounted is deprecated anyway so we should be able - // to kill this. - nextEffect.effectTag &= ~Placement; - break; - } - case PlacementAndUpdate: { - // Placement - commitPlacement(nextEffect); - // Clear the "placement" from effect tag so that we know that this is inserted, before - // any life-cycles like componentDidMount gets called. - nextEffect.effectTag &= ~Placement; - - // Update - var _current = nextEffect.alternate; - commitWork(_current, nextEffect); - break; - } - case Update: { - var _current2 = nextEffect.alternate; - commitWork(_current2, nextEffect); - break; - } - case Deletion: { - commitDeletion(nextEffect); - break; - } - } - nextEffect = nextEffect.nextEffect; - } - - { - resetCurrentFiber(); - } -} - -function commitBeforeMutationLifecycles() { - while (nextEffect !== null) { - { - setCurrentFiber(nextEffect); - } - - var effectTag = nextEffect.effectTag; - if (effectTag & Snapshot) { - recordEffect(); - var current$$1 = nextEffect.alternate; - commitBeforeMutationLifeCycles(current$$1, nextEffect); - } - - nextEffect = nextEffect.nextEffect; - } - - { - resetCurrentFiber(); - } -} - -function commitAllLifeCycles(finishedRoot, committedExpirationTime) { - { - ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); - ReactStrictModeWarnings.flushLegacyContextWarning(); - - if (warnAboutDeprecatedLifecycles) { - ReactStrictModeWarnings.flushPendingDeprecationWarnings(); - } - } - while (nextEffect !== null) { - { - setCurrentFiber(nextEffect); - } - var effectTag = nextEffect.effectTag; - - if (effectTag & (Update | Callback)) { - recordEffect(); - var current$$1 = nextEffect.alternate; - commitLifeCycles( - finishedRoot, - current$$1, - nextEffect, - committedExpirationTime - ); - } - - if (effectTag & Ref) { - recordEffect(); - commitAttachRef(nextEffect); - } - - if (effectTag & Passive) { - rootWithPendingPassiveEffects = finishedRoot; - } - - nextEffect = nextEffect.nextEffect; - } - { - resetCurrentFiber(); - } -} - -function commitPassiveEffects(root, firstEffect) { - rootWithPendingPassiveEffects = null; - passiveEffectCallbackHandle = null; - passiveEffectCallback = null; - - // Set this to true to prevent re-entrancy - var previousIsRendering = isRendering; - isRendering = true; - - var effect = firstEffect; - do { - { - setCurrentFiber(effect); - } - - if (effect.effectTag & Passive) { - var didError = false; - var error = void 0; - { - invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); - if (hasCaughtError()) { - didError = true; - error = clearCaughtError(); - } - } - if (didError) { - captureCommitPhaseError(effect, error); - } - } - effect = effect.nextEffect; - } while (effect !== null); - { - resetCurrentFiber(); - } - - isRendering = previousIsRendering; - - // Check if work was scheduled by one of the effects - var rootExpirationTime = root.expirationTime; - if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); - } - // Flush any sync work that was scheduled by effects - if (!isBatchingUpdates && !isRendering) { - performSyncWork(); - } -} - -function isAlreadyFailedLegacyErrorBoundary(instance) { - return ( - legacyErrorBoundariesThatAlreadyFailed !== null && - legacyErrorBoundariesThatAlreadyFailed.has(instance) - ); -} - -function markLegacyErrorBoundaryAsFailed(instance) { - if (legacyErrorBoundariesThatAlreadyFailed === null) { - legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); - } else { - legacyErrorBoundariesThatAlreadyFailed.add(instance); - } -} - -function flushPassiveEffects() { - if (passiveEffectCallbackHandle !== null) { - cancelPassiveEffects(passiveEffectCallbackHandle); - } - if (passiveEffectCallback !== null) { - // We call the scheduled callback instead of commitPassiveEffects directly - // to ensure tracing works correctly. - passiveEffectCallback(); - } -} - -function commitRoot(root, finishedWork) { - isWorking = true; - isCommitting$1 = true; - startCommitTimer(); - - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug " + - "related to the return field. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - committedExpirationTime !== NoWork, - "Cannot commit an incomplete root. This error is likely caused by a " + - "bug in React. Please file an issue." - ); - root.pendingCommitExpirationTime = NoWork; - - // Update the pending priority levels to account for the work that we are - // about to commit. This needs to happen before calling the lifecycles, since - // they may schedule additional updates. - var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; - var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; - var earliestRemainingTimeBeforeCommit = - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit - ? childExpirationTimeBeforeCommit - : updateExpirationTimeBeforeCommit; - markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); - - var prevInteractions = null; - if (enableSchedulerTracing) { - // Restore any pending interactions at this point, - // So that cascading work triggered during the render phase will be accounted for. - prevInteractions = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - } - - // Reset this to null before calling lifecycles - ReactCurrentOwner$2.current = null; - - var firstEffect = void 0; - if (finishedWork.effectTag > PerformedWork) { - // A fiber's effect list consists only of its children, not itself. So if - // the root has an effect, we need to add it to the end of the list. The - // resulting list is the set that would belong to the root's parent, if - // it had one; that is, all the effects in the tree including the root. - if (finishedWork.lastEffect !== null) { - finishedWork.lastEffect.nextEffect = finishedWork; - firstEffect = finishedWork.firstEffect; - } else { - firstEffect = finishedWork; - } - } else { - // There is no effect on the root. - firstEffect = finishedWork.firstEffect; - } - - prepareForCommit(root.containerInfo); - - // Invoke instances of getSnapshotBeforeUpdate before mutation. - nextEffect = firstEffect; - startCommitSnapshotEffectsTimer(); - while (nextEffect !== null) { - var didError = false; - var error = void 0; - { - invokeGuardedCallback(null, commitBeforeMutationLifecycles, null); - if (hasCaughtError()) { - didError = true; - error = clearCaughtError(); - } - } - if (didError) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, error); - // Clean-up - if (nextEffect !== null) { - nextEffect = nextEffect.nextEffect; - } - } - } - stopCommitSnapshotEffectsTimer(); - - if (enableProfilerTimer) { - // Mark the current commit time to be shared by all Profilers in this batch. - // This enables them to be grouped later. - recordCommitTime(); - } - - // Commit all the side-effects within a tree. We'll do this in two passes. - // The first pass performs all the host insertions, updates, deletions and - // ref unmounts. - nextEffect = firstEffect; - startCommitHostEffectsTimer(); - while (nextEffect !== null) { - var _didError = false; - var _error = void 0; - { - invokeGuardedCallback(null, commitAllHostEffects, null); - if (hasCaughtError()) { - _didError = true; - _error = clearCaughtError(); - } - } - if (_didError) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, _error); - // Clean-up - if (nextEffect !== null) { - nextEffect = nextEffect.nextEffect; - } - } - } - stopCommitHostEffectsTimer(); - - resetAfterCommit(root.containerInfo); - - // The work-in-progress tree is now the current tree. This must come after - // the first pass of the commit phase, so that the previous tree is still - // current during componentWillUnmount, but before the second pass, so that - // the finished work is current during componentDidMount/Update. - root.current = finishedWork; - - // In the second pass we'll perform all life-cycles and ref callbacks. - // Life-cycles happen as a separate pass so that all placements, updates, - // and deletions in the entire tree have already been invoked. - // This pass also triggers any renderer-specific initial effects. - nextEffect = firstEffect; - startCommitLifeCyclesTimer(); - while (nextEffect !== null) { - var _didError2 = false; - var _error2 = void 0; - { - invokeGuardedCallback( - null, - commitAllLifeCycles, - null, - root, - committedExpirationTime - ); - if (hasCaughtError()) { - _didError2 = true; - _error2 = clearCaughtError(); - } - } - if (_didError2) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, _error2); - if (nextEffect !== null) { - nextEffect = nextEffect.nextEffect; - } - } - } - - if (firstEffect !== null && rootWithPendingPassiveEffects !== null) { - // This commit included a passive effect. These do not need to fire until - // after the next paint. Schedule an callback to fire them in an async - // event. To ensure serial execution, the callback will be flushed early if - // we enter rootWithPendingPassiveEffects commit phase before then. - var callback = commitPassiveEffects.bind(null, root, firstEffect); - if (enableSchedulerTracing) { - // TODO: Avoid this extra callback by mutating the tracing ref directly, - // like we do at the beginning of commitRoot. I've opted not to do that - // here because that code is still in flux. - callback = tracing.unstable_wrap(callback); - } - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return schedulePassiveEffects(callback); - } - ); - passiveEffectCallback = callback; - } - - isCommitting$1 = false; - isWorking = false; - stopCommitLifeCyclesTimer(); - stopCommitTimer(); - onCommitRoot(finishedWork.stateNode); - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCommitWork(finishedWork); - } - - var updateExpirationTimeAfterCommit = finishedWork.expirationTime; - var childExpirationTimeAfterCommit = finishedWork.childExpirationTime; - var earliestRemainingTimeAfterCommit = - childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit - ? childExpirationTimeAfterCommit - : updateExpirationTimeAfterCommit; - if (earliestRemainingTimeAfterCommit === NoWork) { - // If there's no remaining work, we can clear the set of already failed - // error boundaries. - legacyErrorBoundariesThatAlreadyFailed = null; - } - onCommit(root, earliestRemainingTimeAfterCommit); - - if (enableSchedulerTracing) { - tracing.__interactionsRef.current = prevInteractions; - - var subscriber = void 0; - - try { - subscriber = tracing.__subscriberRef.current; - if (subscriber !== null && root.memoizedInteractions.size > 0) { - var threadID = computeThreadID( - committedExpirationTime, - root.interactionThreadID - ); - subscriber.onWorkStopped(root.memoizedInteractions, threadID); - } - } catch (error) { - // It's not safe for commitRoot() to throw. - // Store the error for now and we'll re-throw in finishRendering(). - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } - } finally { - // Clear completed interactions from the pending Map. - // Unless the render was suspended or cascading work was scheduled, - // In which case– leave pending interactions until the subsequent render. - var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - // Only decrement the pending interaction count if we're done. - // If there's still work at the current priority, - // That indicates that we are waiting for suspense data. - if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { - pendingInteractionMap.delete(scheduledExpirationTime); - - scheduledInteractions.forEach(function(interaction) { - interaction.__count--; - - if (subscriber !== null && interaction.__count === 0) { - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - // It's not safe for commitRoot() to throw. - // Store the error for now and we'll re-throw in finishRendering(). - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } - } - } - }); - } - }); - } - } -} - -function resetChildExpirationTime(workInProgress, renderTime) { - if (renderTime !== Never && workInProgress.childExpirationTime === Never) { - // The children of this component are hidden. Don't bubble their - // expiration times. - return; - } - - var newChildExpirationTime = NoWork; - - // Bubble up the earliest expiration time. - if (enableProfilerTimer && workInProgress.mode & ProfileMode) { - // We're in profiling mode. - // Let's use this same traversal to update the render durations. - var actualDuration = workInProgress.actualDuration; - var treeBaseDuration = workInProgress.selfBaseDuration; - - // When a fiber is cloned, its actualDuration is reset to 0. - // This value will only be updated if work is done on the fiber (i.e. it doesn't bailout). - // When work is done, it should bubble to the parent's actualDuration. - // If the fiber has not been cloned though, (meaning no work was done), - // Then this value will reflect the amount of time spent working on a previous render. - // In that case it should not bubble. - // We determine whether it was cloned by comparing the child pointer. - var shouldBubbleActualDurations = - workInProgress.alternate === null || - workInProgress.child !== workInProgress.alternate.child; - - var child = workInProgress.child; - while (child !== null) { - var childUpdateExpirationTime = child.expirationTime; - var childChildExpirationTime = child.childExpirationTime; - if (childUpdateExpirationTime > newChildExpirationTime) { - newChildExpirationTime = childUpdateExpirationTime; - } - if (childChildExpirationTime > newChildExpirationTime) { - newChildExpirationTime = childChildExpirationTime; - } - if (shouldBubbleActualDurations) { - actualDuration += child.actualDuration; - } - treeBaseDuration += child.treeBaseDuration; - child = child.sibling; - } - workInProgress.actualDuration = actualDuration; - workInProgress.treeBaseDuration = treeBaseDuration; - } else { - var _child = workInProgress.child; - while (_child !== null) { - var _childUpdateExpirationTime = _child.expirationTime; - var _childChildExpirationTime = _child.childExpirationTime; - if (_childUpdateExpirationTime > newChildExpirationTime) { - newChildExpirationTime = _childUpdateExpirationTime; - } - if (_childChildExpirationTime > newChildExpirationTime) { - newChildExpirationTime = _childChildExpirationTime; - } - _child = _child.sibling; - } - } - - workInProgress.childExpirationTime = newChildExpirationTime; -} - -function completeUnitOfWork(workInProgress) { - // Attempt to complete the current unit of work, then move to the - // next sibling. If there are no more siblings, return to the - // parent fiber. - while (true) { - // The current, flushed, state of this fiber is the alternate. - // Ideally nothing should rely on this, but relying on it here - // means that we don't need an additional field on the work in - // progress. - var current$$1 = workInProgress.alternate; - { - setCurrentFiber(workInProgress); - } - - var returnFiber = workInProgress.return; - var siblingFiber = workInProgress.sibling; - - if ((workInProgress.effectTag & Incomplete) === NoEffect) { - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - // Don't replay if it fails during completion phase. - mayReplayFailedUnitOfWork = false; - } - // This fiber completed. - // Remember we're completing this unit so we can find a boundary if it fails. - nextUnitOfWork = workInProgress; - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - startProfilerTimer(workInProgress); - } - nextUnitOfWork = completeWork( - current$$1, - workInProgress, - nextRenderExpirationTime - ); - if (workInProgress.mode & ProfileMode) { - // Update render duration assuming we didn't error. - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); - } - } else { - nextUnitOfWork = completeWork( - current$$1, - workInProgress, - nextRenderExpirationTime - ); - } - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - // We're out of completion phase so replaying is fine now. - mayReplayFailedUnitOfWork = true; - } - stopWorkTimer(workInProgress); - resetChildExpirationTime(workInProgress, nextRenderExpirationTime); - { - resetCurrentFiber(); - } - - if (nextUnitOfWork !== null) { - // Completing this fiber spawned new work. Work on that next. - return nextUnitOfWork; - } - - if ( - returnFiber !== null && - // Do not append effects to parents if a sibling failed to complete - (returnFiber.effectTag & Incomplete) === NoEffect - ) { - // Append all the effects of the subtree and this fiber onto the effect - // list of the parent. The completion order of the children affects the - // side-effect order. - if (returnFiber.firstEffect === null) { - returnFiber.firstEffect = workInProgress.firstEffect; - } - if (workInProgress.lastEffect !== null) { - if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; - } - returnFiber.lastEffect = workInProgress.lastEffect; - } - - // If this fiber had side-effects, we append it AFTER the children's - // side-effects. We can perform certain side-effects earlier if - // needed, by doing multiple passes over the effect list. We don't want - // to schedule our own side-effect on our own list because if end up - // reusing children we'll schedule this effect onto itself since we're - // at the end. - var effectTag = workInProgress.effectTag; - // Skip both NoWork and PerformedWork tags when creating the effect list. - // PerformedWork effect is read by React DevTools but shouldn't be committed. - if (effectTag > PerformedWork) { - if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = workInProgress; - } else { - returnFiber.firstEffect = workInProgress; - } - returnFiber.lastEffect = workInProgress; - } - } - - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); - } - - if (siblingFiber !== null) { - // If there is more work to do in this returnFiber, do that next. - return siblingFiber; - } else if (returnFiber !== null) { - // If there's no more work in this returnFiber. Complete the returnFiber. - workInProgress = returnFiber; - continue; - } else { - // We've reached the root. - return null; - } - } else { - if (enableProfilerTimer && workInProgress.mode & ProfileMode) { - // Record the render duration for the fiber that errored. - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); - - // Include the time spent working on failed children before continuing. - var actualDuration = workInProgress.actualDuration; - var child = workInProgress.child; - while (child !== null) { - actualDuration += child.actualDuration; - child = child.sibling; - } - workInProgress.actualDuration = actualDuration; - } - - // This fiber did not complete because something threw. Pop values off - // the stack without entering the complete phase. If this is a boundary, - // capture values if possible. - var next = unwindWork(workInProgress, nextRenderExpirationTime); - // Because this fiber did not complete, don't reset its expiration time. - if (workInProgress.effectTag & DidCapture) { - // Restarting an error boundary - stopFailedWorkTimer(workInProgress); - } else { - stopWorkTimer(workInProgress); - } - - { - resetCurrentFiber(); - } - - if (next !== null) { - stopWorkTimer(workInProgress); - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); - } - - // If completing this work spawned new work, do that next. We'll come - // back here again. - // Since we're restarting, remove anything that is not a host effect - // from the effect tag. - next.effectTag &= HostEffectMask; - return next; - } - - if (returnFiber !== null) { - // Mark the parent fiber as incomplete and clear its effect list. - returnFiber.firstEffect = returnFiber.lastEffect = null; - returnFiber.effectTag |= Incomplete; - } - - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); - } - - if (siblingFiber !== null) { - // If there is more work to do in this returnFiber, do that next. - return siblingFiber; - } else if (returnFiber !== null) { - // If there's no more work in this returnFiber. Complete the returnFiber. - workInProgress = returnFiber; - continue; - } else { - return null; - } - } - } - - // Without this explicit null return Flow complains of invalid return type - // TODO Remove the above while(true) loop - // eslint-disable-next-line no-unreachable - return null; -} - -function performUnitOfWork(workInProgress) { - // The current, flushed, state of this fiber is the alternate. - // Ideally nothing should rely on this, but relying on it here - // means that we don't need an additional field on the work in - // progress. - var current$$1 = workInProgress.alternate; - - // See if beginning this work spawns more work. - startWorkTimer(workInProgress); - { - setCurrentFiber(workInProgress); - } - - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - stashedWorkInProgressProperties = assignFiberPropertiesInDEV( - stashedWorkInProgressProperties, - workInProgress - ); - } - - var next = void 0; - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - startProfilerTimer(workInProgress); - } - - next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); - workInProgress.memoizedProps = workInProgress.pendingProps; - - if (workInProgress.mode & ProfileMode) { - // Record the render duration assuming we didn't bailout (or error). - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); - } - } else { - next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); - workInProgress.memoizedProps = workInProgress.pendingProps; - } - - { - resetCurrentFiber(); - if (isReplayingFailedUnitOfWork) { - // Currently replaying a failed unit of work. This should be unreachable, - // because the render phase is meant to be idempotent, and it should - // have thrown again. Since it didn't, rethrow the original error, so - // React's internal stack is not misaligned. - rethrowOriginalError(); - } - } - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress); - } - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - next = completeUnitOfWork(workInProgress); - } - - ReactCurrentOwner$2.current = null; - - return next; -} - -function workLoop(isYieldy) { - if (!isYieldy) { - // Flush work without yielding - while (nextUnitOfWork !== null) { - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - } - } else { - // Flush asynchronous work until there's a higher priority event - while (nextUnitOfWork !== null && !shouldYield$$1()) { - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - } - } -} - -function renderRoot(root, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused " + - "by a bug in React. Please file an issue." - ); - - flushPassiveEffects(); - - isWorking = true; - var previousDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - - var expirationTime = root.nextExpirationTimeToWorkOn; - - // Check if we're starting from a fresh stack, or if we're resuming from - // previously yielded work. - if ( - expirationTime !== nextRenderExpirationTime || - root !== nextRoot || - nextUnitOfWork === null - ) { - // Reset the stack and start working from the root. - resetStack(); - nextRoot = root; - nextRenderExpirationTime = expirationTime; - nextUnitOfWork = createWorkInProgress( - nextRoot.current, - null, - nextRenderExpirationTime - ); - root.pendingCommitExpirationTime = NoWork; - - if (enableSchedulerTracing) { - // Determine which interactions this batch of work currently includes, - // So that we can accurately attribute time spent working on it, - var interactions = new Set(); - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - if (scheduledExpirationTime >= expirationTime) { - scheduledInteractions.forEach(function(interaction) { - return interactions.add(interaction); - }); - } - }); - - // Store the current set of interactions on the FiberRoot for a few reasons: - // We can re-use it in hot functions like renderRoot() without having to recalculate it. - // We will also use it in commitWork() to pass to any Profiler onRender() hooks. - // This also provides DevTools with a way to access it when the onCommitRoot() hook is called. - root.memoizedInteractions = interactions; - - if (interactions.size > 0) { - var subscriber = tracing.__subscriberRef.current; - if (subscriber !== null) { - var threadID = computeThreadID( - expirationTime, - root.interactionThreadID - ); - try { - subscriber.onWorkStarted(interactions, threadID); - } catch (error) { - // Work thrown by an interaction tracing subscriber should be rethrown, - // But only once it's safe (to avoid leaving the scheduler in an invalid state). - // Store the error for now and we'll re-throw in finishRendering(). - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } - } - } - } - } - } - - var prevInteractions = null; - if (enableSchedulerTracing) { - // We're about to start new traced work. - // Restore pending interactions so cascading work triggered during the render phase will be accounted for. - prevInteractions = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - } - - var didFatal = false; - - startWorkLoopTimer(nextUnitOfWork); - - do { - try { - workLoop(isYieldy); - } catch (thrownValue) { - resetContextDependences(); - resetHooks(); - - // Reset in case completion throws. - // This is only used in DEV and when replaying is on. - var mayReplay = void 0; - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - mayReplay = mayReplayFailedUnitOfWork; - mayReplayFailedUnitOfWork = true; - } - - if (nextUnitOfWork === null) { - // This is a fatal error. - didFatal = true; - onUncaughtError(thrownValue); - } else { - if (enableProfilerTimer && nextUnitOfWork.mode & ProfileMode) { - // Record the time spent rendering before an error was thrown. - // This avoids inaccurate Profiler durations in the case of a suspended render. - stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, true); - } - - { - // Reset global debug state - // We assume this is defined in DEV - resetCurrentlyProcessingQueue(); - } - - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - if (mayReplay) { - var failedUnitOfWork = nextUnitOfWork; - replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy); - } - } - - // TODO: we already know this isn't true in some cases. - // At least this shows a nicer error message until we figure out the cause. - // https://github.com/facebook/react/issues/12449#issuecomment-386727431 - invariant( - nextUnitOfWork !== null, - "Failed to replay rendering after an error. This " + - "is likely caused by a bug in React. Please file an issue " + - "with a reproducing case to help us find it." - ); - - var sourceFiber = nextUnitOfWork; - var returnFiber = sourceFiber.return; - if (returnFiber === null) { - // This is the root. The root could capture its own errors. However, - // we don't know if it errors before or after we pushed the host - // context. This information is needed to avoid a stack mismatch. - // Because we're not sure, treat this as a fatal error. We could track - // which phase it fails in, but doesn't seem worth it. At least - // for now. - didFatal = true; - onUncaughtError(thrownValue); - } else { - throwException( - root, - returnFiber, - sourceFiber, - thrownValue, - nextRenderExpirationTime - ); - nextUnitOfWork = completeUnitOfWork(sourceFiber); - continue; - } - } - } - break; - } while (true); - - if (enableSchedulerTracing) { - // Traced work is done for now; restore the previous interactions. - tracing.__interactionsRef.current = prevInteractions; - } - - // We're done performing work. Time to clean up. - isWorking = false; - ReactCurrentDispatcher.current = previousDispatcher; - resetContextDependences(); - resetHooks(); - - // Yield back to main thread. - if (didFatal) { - var _didCompleteRoot = false; - stopWorkLoopTimer(interruptedBy, _didCompleteRoot); - interruptedBy = null; - // There was a fatal error. - { - resetStackAfterFatalErrorInDev(); - } - // `nextRoot` points to the in-progress root. A non-null value indicates - // that we're in the middle of an async render. Set it to null to indicate - // there's no more work to be done in the current batch. - nextRoot = null; - onFatal(root); - return; - } - - if (nextUnitOfWork !== null) { - // There's still remaining async work in this tree, but we ran out of time - // in the current frame. Yield back to the renderer. Unless we're - // interrupted by a higher priority update, we'll continue later from where - // we left off. - var _didCompleteRoot2 = false; - stopWorkLoopTimer(interruptedBy, _didCompleteRoot2); - interruptedBy = null; - onYield(root); - return; - } - - // We completed the whole tree. - var didCompleteRoot = true; - stopWorkLoopTimer(interruptedBy, didCompleteRoot); - var rootWorkInProgress = root.current.alternate; - invariant( - rootWorkInProgress !== null, - "Finished root should have a work-in-progress. This error is likely " + - "caused by a bug in React. Please file an issue." - ); - - // `nextRoot` points to the in-progress root. A non-null value indicates - // that we're in the middle of an async render. Set it to null to indicate - // there's no more work to be done in the current batch. - nextRoot = null; - interruptedBy = null; - - if (nextRenderDidError) { - // There was an error - if (hasLowerPriorityWork(root, expirationTime)) { - // There's lower priority work. If so, it may have the effect of fixing - // the exception that was just thrown. Exit without committing. This is - // similar to a suspend, but without a timeout because we're not waiting - // for a promise to resolve. React will restart at the lower - // priority level. - markSuspendedPriorityLevel(root, expirationTime); - var suspendedExpirationTime = expirationTime; - var rootExpirationTime = root.expirationTime; - onSuspend( - root, - rootWorkInProgress, - suspendedExpirationTime, - rootExpirationTime, - -1 // Indicates no timeout - ); - return; - } else if ( - // There's no lower priority work, but we're rendering asynchronously. - // Synchronously attempt to render the same level one more time. This is - // similar to a suspend, but without a timeout because we're not waiting - // for a promise to resolve. - !root.didError && - isYieldy - ) { - root.didError = true; - var _suspendedExpirationTime = (root.nextExpirationTimeToWorkOn = expirationTime); - var _rootExpirationTime = (root.expirationTime = Sync); - onSuspend( - root, - rootWorkInProgress, - _suspendedExpirationTime, - _rootExpirationTime, - -1 // Indicates no timeout - ); - return; - } - } - - if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { - // The tree was suspended. - var _suspendedExpirationTime2 = expirationTime; - markSuspendedPriorityLevel(root, _suspendedExpirationTime2); - - // Find the earliest uncommitted expiration time in the tree, including - // work that is suspended. The timeout threshold cannot be longer than - // the overall expiration. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - expirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime); - if (earliestExpirationTimeMs < nextLatestAbsoluteTimeoutMs) { - nextLatestAbsoluteTimeoutMs = earliestExpirationTimeMs; - } - - // Subtract the current time from the absolute timeout to get the number - // of milliseconds until the timeout. In other words, convert an absolute - // timestamp to a relative time. This is the value that is passed - // to `setTimeout`. - var currentTimeMs = expirationTimeToMs(requestCurrentTime()); - var msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs; - msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout; - - // TODO: Account for the Just Noticeable Difference - - var _rootExpirationTime2 = root.expirationTime; - onSuspend( - root, - rootWorkInProgress, - _suspendedExpirationTime2, - _rootExpirationTime2, - msUntilTimeout - ); - return; - } - - // Ready to commit. - onComplete(root, rootWorkInProgress, expirationTime); -} - -function captureCommitPhaseError(sourceFiber, value) { - var expirationTime = Sync; - var fiber = sourceFiber.return; - while (fiber !== null) { - switch (fiber.tag) { - case ClassComponent: - var ctor = fiber.type; - var instance = fiber.stateNode; - if ( - typeof ctor.getDerivedStateFromError === "function" || - (typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance)) - ) { - var errorInfo = createCapturedValue(value, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, expirationTime); - enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); - return; - } - break; - case HostRoot: { - var _errorInfo = createCapturedValue(value, sourceFiber); - var _update = createRootErrorUpdate(fiber, _errorInfo, expirationTime); - enqueueUpdate(fiber, _update); - scheduleWork(fiber, expirationTime); - return; - } - } - fiber = fiber.return; - } - - if (sourceFiber.tag === HostRoot) { - // Error was thrown at the root. There is no parent, so the root - // itself should capture it. - var rootFiber = sourceFiber; - var _errorInfo2 = createCapturedValue(value, rootFiber); - var _update2 = createRootErrorUpdate( - rootFiber, - _errorInfo2, - expirationTime - ); - enqueueUpdate(rootFiber, _update2); - scheduleWork(rootFiber, expirationTime); - } -} - -function computeThreadID(expirationTime, interactionThreadID) { - // Interaction threads are unique per root and expiration time. - return expirationTime * 1000 + interactionThreadID; + // This is the first update since React yielded. Compute a new start time. + currentEventTime = msToExpirationTime(now()); + return currentEventTime; } function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(); - - var expirationTime = void 0; if ((fiber.mode & ConcurrentMode) === NoContext) { - // Outside of concurrent mode, updates are always synchronous. - expirationTime = Sync; - } else if (isWorking && !isCommitting$1) { - // During render phase, updates expire during as the current render. - expirationTime = nextRenderExpirationTime; - } else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = Sync; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = computeInteractiveExpiration(currentTime); - break; - case scheduler.unstable_NormalPriority: - // This is a normal, concurrent update - expirationTime = computeAsyncExpiration(currentTime); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = Never; - break; - default: - invariant( - false, - "Unknown priority level. This error is likely caused by a bug in " + - "React. Please file an issue." - ); - } - - // If we're in the middle of rendering a tree, do not update at the same - // expiration time that is already rendering. - if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { - expirationTime -= 1; - } + return Sync; } - // Keep track of the lowest pending interactive expiration time. This - // allows us to synchronously flush all interactive updates - // when needed. - // TODO: Move this to renderer? - if ( - priorityLevel === scheduler.unstable_UserBlockingPriority && - (lowestPriorityPendingInteractiveExpirationTime === NoWork || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) - ) { - lowestPriorityPendingInteractiveExpirationTime = expirationTime; + if (workPhase === RenderPhase) { + // Use whatever time we're already rendering + return renderExpirationTime; + } + + // Compute an expiration time based on the Scheduler priority. + var expirationTime = void 0; + var priorityLevel = getCurrentPriorityLevel(); + switch (priorityLevel) { + case ImmediatePriority: + expirationTime = Sync; + break; + case UserBlockingPriority: + // TODO: Rename this to computeUserBlockingExpiration + expirationTime = computeInteractiveExpiration(currentTime); + break; + case NormalPriority: + case LowPriority: + // TODO: Handle LowPriority + // TODO: Rename this to... something better. + expirationTime = computeAsyncExpiration(currentTime); + break; + case IdlePriority: + expirationTime = Never; + break; + default: + (function() { + { + throw ReactError("Expected a valid priority level"); + } + })(); + } + + // If we're in the middle of rendering a tree, do not update at the same + // expiration time that is already rendering. + if (workInProgressRoot !== null && expirationTime === renderExpirationTime) { + // This is a trick to move this update into a separate batch + expirationTime -= 1; } return expirationTime; } -function renderDidSuspend(root, absoluteTimeoutMs, suspendedTime) { - // Schedule the timeout. - if ( - absoluteTimeoutMs >= 0 && - nextLatestAbsoluteTimeoutMs < absoluteTimeoutMs - ) { - nextLatestAbsoluteTimeoutMs = absoluteTimeoutMs; - } -} +function scheduleUpdateOnFiber(fiber, expirationTime) { + checkForNestedUpdates(); + warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber); -function renderDidError() { - nextRenderDidError = true; -} - -function pingSuspendedRoot(root, thenable, pingTime) { - // A promise that previously suspended React from committing has resolved. - // If React is still suspended, try again at the previous level (pingTime). - - var pingCache = root.pingCache; - if (pingCache !== null) { - // The thenable resolved, so we no longer need to memoize, because it will - // never be thrown again. - pingCache.delete(thenable); + var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (root === null) { + warnAboutUpdateOnUnmountedFiberInDEV(fiber); + return; } - if (nextRoot !== null && nextRenderExpirationTime === pingTime) { - // Received a ping at the same priority level at which we're currently - // rendering. Restart from the root. - nextRoot = null; - } else { - // Confirm that the root is still suspended at this level. Otherwise exit. - if (isPriorityLevelSuspended(root, pingTime)) { - // Ping at the original level - markPingedPriorityLevel(root, pingTime); - var rootExpirationTime = root.expirationTime; - if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); - } - } - } -} + root.pingTime = NoWork; -function retryTimedOutBoundary(boundaryFiber) { - var currentTime = requestCurrentTime(); - var retryTime = computeExpirationForFiber(currentTime, boundaryFiber); - var root = scheduleWorkToRoot(boundaryFiber, retryTime); - if (root !== null) { - markPendingPriorityLevel(root, retryTime); - var rootExpirationTime = root.expirationTime; - if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); - } - } -} - -function resolveRetryThenable(boundaryFiber, thenable) { - // The boundary fiber (a Suspense component) previously timed out and was - // rendered in its fallback state. One of the promises that suspended it has - // resolved, which means at least part of the tree was likely unblocked. Try - var retryCache = void 0; - if (enableSuspenseServerRenderer) { - switch (boundaryFiber.tag) { - case SuspenseComponent: - retryCache = boundaryFiber.stateNode; - break; - case DehydratedSuspenseComponent: - retryCache = boundaryFiber.memoizedState; - break; - default: - invariant( - false, - "Pinged unknown suspense boundary type. " + - "This is probably a bug in React." - ); - } - } else { - retryCache = boundaryFiber.stateNode; - } - if (retryCache !== null) { - // The thenable resolved, so we no longer need to memoize, because it will - // never be thrown again. - retryCache.delete(thenable); - } - - retryTimedOutBoundary(boundaryFiber); -} - -function scheduleWorkToRoot(fiber, expirationTime) { + checkForInterruption(fiber, expirationTime); recordScheduleUpdate(); - { - if (fiber.tag === ClassComponent) { - var instance = fiber.stateNode; - warnAboutInvalidUpdates(instance); + if (expirationTime === Sync) { + if (workPhase === LegacyUnbatchedPhase) { + // This is a legacy edge case. The initial mount of a ReactDOM.render-ed + // root inside of batchedUpdates should be synchronous, but layout updates + // should be deferred until the end of the batch. + var callback = renderRoot(root, Sync, true); + while (callback !== null) { + callback = callback(true); + } + } else { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + if (workPhase === NotWorking) { + // Flush the synchronous work now, wnless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initated + // updates, to preserve historical behavior of sync mode. + flushImmediateQueue(); + } } + } else { + // TODO: computeExpirationForFiber also reads the priority. Pass the + // priority as an argument to that function and this one. + var priorityLevel = getCurrentPriorityLevel(); + if (priorityLevel === UserBlockingPriority) { + // This is the result of a discrete event. Track the lowest priority + // discrete update per root so we can flush them early, if needed. + if (rootsWithPendingDiscreteUpdates === null) { + rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); + } else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); + if ( + lastDiscreteTime === undefined || + lastDiscreteTime > expirationTime + ) { + rootsWithPendingDiscreteUpdates.set(root, expirationTime); + } + } + } + scheduleCallbackForRoot(root, priorityLevel, expirationTime); } +} +var scheduleWork = scheduleUpdateOnFiber; +// This is split into a separate function so we can mark a fiber with pending +// work without treating it as a typical update that originates from an event; +// e.g. retrying a Suspense boundary isn't an update, but it does schedule work +// on a fiber. +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { // Update the source fiber's expiration time if (fiber.expirationTime < expirationTime) { fiber.expirationTime = expirationTime; @@ -17579,56 +16812,1576 @@ function scheduleWorkToRoot(fiber, expirationTime) { } } - if (enableSchedulerTracing) { - if (root !== null) { - var interactions = tracing.__interactionsRef.current; - if (interactions.size > 0) { - var pendingInteractionMap = root.pendingInteractionMap; - var pendingInteractions = pendingInteractionMap.get(expirationTime); - if (pendingInteractions != null) { - interactions.forEach(function(interaction) { - if (!pendingInteractions.has(interaction)) { - // Update the pending async work count for previously unscheduled interaction. - interaction.__count++; - } - - pendingInteractions.add(interaction); - }); - } else { - pendingInteractionMap.set(expirationTime, new Set(interactions)); - - // Update the pending async work count for the current interactions. - interactions.forEach(function(interaction) { - interaction.__count++; - }); - } - - var subscriber = tracing.__subscriberRef.current; - if (subscriber !== null) { - var threadID = computeThreadID( - expirationTime, - root.interactionThreadID - ); - subscriber.onWorkScheduled(interactions, threadID); - } - } + if (root !== null) { + // Update the first and last pending expiration times in this root + var firstPendingTime = root.firstPendingTime; + if (expirationTime > firstPendingTime) { + root.firstPendingTime = expirationTime; + } + var lastPendingTime = root.lastPendingTime; + if (lastPendingTime === NoWork || expirationTime < lastPendingTime) { + root.lastPendingTime = expirationTime; } } + return root; } -function warnIfNotCurrentlyBatchingInDev(fiber) { +// Use this function, along with runRootCallback, to ensure that only a single +// callback per root is scheduled. It's still possible to call renderRoot +// directly, but scheduling via this function helps avoid excessive callbacks. +// It works by storing the callback node and expiration time on the root. When a +// new callback comes in, it compares the expiration time to determine if it +// should cancel the previous one. It also relies on commitRoot scheduling a +// callback to render the next level, because that means we don't need a +// separate callback per expiration time. +function scheduleCallbackForRoot(root, priorityLevel, expirationTime) { + var existingCallbackExpirationTime = root.callbackExpirationTime; + if (existingCallbackExpirationTime < expirationTime) { + // New callback has higher priority than the existing one. + var existingCallbackNode = root.callbackNode; + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + root.callbackExpirationTime = expirationTime; + + var options = null; + if (expirationTime !== Sync && expirationTime !== Never) { + var timeout = expirationTimeToMs(expirationTime) - now(); + if (timeout > 5000) { + // Sanity check. Should never take longer than 5 seconds. + // TODO: Add internal warning? + timeout = 5000; + } + options = { timeout: timeout }; + } + + root.callbackNode = scheduleCallback( + priorityLevel, + runRootCallback.bind( + null, + root, + renderRoot.bind(null, root, expirationTime) + ), + options + ); + if ( + enableUserTimingAPI && + expirationTime !== Sync && + workPhase !== RenderPhase && + workPhase !== CommitPhase + ) { + // Scheduled an async callback, and we're not already working. Add an + // entry to the flamegraph that shows we're waiting for a callback + // to fire. + startRequestCallbackTimer(); + } + } + + // Add the current set of interactions to the pending set associated with + // this root. + schedulePendingInteraction(root, expirationTime); +} + +function runRootCallback(root, callback, isSync) { + var prevCallbackNode = root.callbackNode; + var continuation = null; + try { + continuation = callback(isSync); + if (continuation !== null) { + return runRootCallback.bind(null, root, continuation); + } else { + return null; + } + } finally { + // If the callback exits without returning a continuation, remove the + // corresponding callback node from the root. Unless the callback node + // has changed, which implies that it was already cancelled by a high + // priority update. + if (continuation === null && prevCallbackNode === root.callbackNode) { + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + } + } +} + +function flushInteractiveUpdates$1() { + if (workPhase === RenderPhase || workPhase === CommitPhase) { + // Can't synchronously flush interactive updates if React is already + // working. This is currently a no-op. + // TODO: Should we fire a warning? This happens if you synchronously invoke + // an input event inside an effect, like with `element.click()`. + return; + } + flushPendingDiscreteUpdates(); +} + +function resolveLocksOnRoot(root, expirationTime) { + var firstBatch = root.firstBatch; + if ( + firstBatch !== null && + firstBatch._defer && + firstBatch._expirationTime >= expirationTime + ) { + root.finishedWork = root.current.alternate; + root.pendingCommitExpirationTime = expirationTime; + scheduleCallback(NormalPriority, function() { + firstBatch._onComplete(); + return null; + }); + return true; + } else { + return false; + } +} + +function interactiveUpdates$1(fn, a, b, c) { + if (workPhase === NotWorking) { + // TODO: Remove this call. Instead of doing this automatically, the caller + // should explicitly call flushInteractiveUpdates. + flushPendingDiscreteUpdates(); + } + return runWithPriority(UserBlockingPriority, fn.bind(null, a, b, c)); +} + +function flushPendingDiscreteUpdates() { + if (rootsWithPendingDiscreteUpdates !== null) { + // For each root with pending discrete updates, schedule a callback to + // immediately flush them. + var roots = rootsWithPendingDiscreteUpdates; + rootsWithPendingDiscreteUpdates = null; + roots.forEach(function(expirationTime, root) { + scheduleCallback( + ImmediatePriority, + renderRoot.bind(null, root, expirationTime) + ); + }); + // Now flush the immediate queue. + flushImmediateQueue(); + } +} + +function batchedUpdates$1(fn, a) { + if (workPhase !== NotWorking) { + // We're already working, or inside a batch, so batchedUpdates is a no-op. + return fn(a); + } + workPhase = BatchedPhase; + try { + return fn(a); + } finally { + workPhase = NotWorking; + // Flush the immediate callbacks that were scheduled during this batch + flushImmediateQueue(); + } +} + +function prepareFreshStack(root, expirationTime) { + root.pendingCommitExpirationTime = NoWork; + + var timeoutHandle = root.timeoutHandle; + if (timeoutHandle !== noTimeout) { + // The root previous suspended and scheduled a timeout to commit a fallback + // state. Now that we have additional work, cancel the timeout. + root.timeoutHandle = noTimeout; + // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above + cancelTimeout(timeoutHandle); + } + + if (workInProgress !== null) { + var interruptedWork = workInProgress.return; + while (interruptedWork !== null) { + unwindInterruptedWork(interruptedWork); + interruptedWork = interruptedWork.return; + } + } + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null, expirationTime); + renderExpirationTime = expirationTime; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootMostRecentEventTime = Sync; + { - if (isRendering === false && isBatchingUpdates === false) { + ReactStrictModeWarnings.discardPendingWarnings(); + } +} + +function renderRoot(root, expirationTime, isSync) { + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Should not already be working."); + } + })(); + + if (enableUserTimingAPI && expirationTime !== Sync) { + var didExpire = isSync; + stopRequestCallbackTimer(didExpire); + } + + if (root.firstPendingTime < expirationTime) { + // If there's no work left at this expiration time, exit immediately. This + // happens when multiple callbacks are scheduled for a single root, but an + // earlier callback flushes the work of a later one. + return null; + } + + if (root.pendingCommitExpirationTime === expirationTime) { + // There's already a pending commit at this expiration time. + root.pendingCommitExpirationTime = NoWork; + return commitRoot.bind(null, root, expirationTime); + } + + flushPassiveEffects(); + + // If the root or expiration time have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteraction(root, expirationTime); + } + + // If we have a work-in-progress fiber, it means there's still work to do + // in this root. + if (workInProgress !== null) { + var prevWorkPhase = workPhase; + workPhase = RenderPhase; + var prevDispatcher = ReactCurrentDispatcher.current; + if (prevDispatcher === null) { + // The React isomorphic package does not include a default dispatcher. + // Instead the first renderer will lazily attach one, in order to give + // nicer error messages. + prevDispatcher = ContextOnlyDispatcher; + } + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + startWorkLoopTimer(workInProgress); + + // TODO: Fork renderRoot into renderRootSync and renderRootAsync + if (isSync) { + if (expirationTime !== Sync) { + // An async update expired. There may be other expired updates on + // this root. We should render all the expired work in a + // single batch. + var currentTime = requestCurrentTime(); + if (currentTime < expirationTime) { + // Restart at the current time. + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher.current = prevDispatcher; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + return renderRoot.bind(null, root, currentTime); + } + } + } else { + // Since we know we're in a React event, we can clear the current + // event time. The next update will compute a new event time. + currentEventTime = NoWork; + } + + do { + try { + if (isSync) { + workLoopSync(); + } else { + workLoop(); + } + break; + } catch (thrownValue) { + // Reset module-level state that was set during the render phase. + resetContextDependences(); + resetHooks(); + + var sourceFiber = workInProgress; + if (sourceFiber === null || sourceFiber.return === null) { + // Expected to be working on a non-root fiber. This is a fatal error + // because there's no ancestor that can handle it; the root is + // supposed to capture all errors that weren't caught by an error + // boundary. + prepareFreshStack(root, expirationTime); + workPhase = prevWorkPhase; + throw thrownValue; + } + + if (enableProfilerTimer && sourceFiber.mode & ProfileMode) { + // Record the time spent rendering before an error was thrown. This + // avoids inaccurate Profiler durations in the case of a + // suspended render. + stopProfilerTimerIfRunningAndRecordDelta(sourceFiber, true); + } + + var returnFiber = sourceFiber.return; + throwException( + root, + returnFiber, + sourceFiber, + thrownValue, + renderExpirationTime + ); + workInProgress = completeUnitOfWork(sourceFiber); + } + } while (true); + + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher.current = prevDispatcher; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + + if (workInProgress !== null) { + // There's still work left over. Return a continuation. + stopInterruptedWorkLoopTimer(); + if (expirationTime !== Sync) { + startRequestCallbackTimer(); + } + return renderRoot.bind(null, root, expirationTime); + } + } + + // We now have a consistent tree. The next step is either to commit it, or, if + // something suspended, wait to commit it after a timeout. + stopFinishedWorkLoopTimer(); + + var isLocked = resolveLocksOnRoot(root, expirationTime); + if (isLocked) { + // This root has a lock that prevents it from committing. Exit. If we begin + // work on the root again, without any intervening updates, it will finish + // without doing additional work. + return null; + } + + // Set this to null to indicate there's no in-progress render. + workInProgressRoot = null; + + switch (workInProgressRootExitStatus) { + case RootIncomplete: { + (function() { + { + throw ReactError("Should have a work-in-progress."); + } + })(); + } + // Flow knows about invariant, so it compains if I add a break statement, + // but eslint doesn't know about invariant, so it complains if I do. + // eslint-disable-next-line no-fallthrough + case RootErrored: { + // An error was thrown. First check if there is lower priority work + // scheduled on this root. + var lastPendingTime = root.lastPendingTime; + if (root.lastPendingTime < expirationTime) { + // There's lower priority work. Before raising the error, try rendering + // at the lower priority to see if it fixes it. Use a continuation to + // maintain the existing priority and position in the queue. + return renderRoot.bind(null, root, lastPendingTime); + } + if (!isSync) { + // If we're rendering asynchronously, it's possible the error was + // caused by tearing due to a mutation during an event. Try rendering + // one more time without yiedling to events. + prepareFreshStack(root, expirationTime); + scheduleCallback( + ImmediatePriority, + renderRoot.bind(null, root, expirationTime) + ); + return null; + } + // If we're already rendering synchronously, commit the root in its + // errored state. + return commitRoot.bind(null, root, expirationTime); + } + case RootSuspended: { + if (!isSync) { + var _lastPendingTime = root.lastPendingTime; + if (root.lastPendingTime < expirationTime) { + // There's lower priority work. It might be unsuspended. Try rendering + // at that level. + return renderRoot.bind(null, root, _lastPendingTime); + } + // If workInProgressRootMostRecentEventTime is Sync, that means we didn't + // track any event times. That can happen if we retried but nothing switched + // from fallback to content. There's no reason to delay doing no work. + if (workInProgressRootMostRecentEventTime !== Sync) { + var msUntilTimeout = computeMsUntilTimeout( + workInProgressRootMostRecentEventTime, + expirationTime + ); + // Don't bother with a very short suspense time. + if (msUntilTimeout > 10) { + // The render is suspended, it hasn't timed out, and there's no lower + // priority work to do. Instead of committing the fallback + // immediately, wait for more data to arrive. + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, expirationTime), + msUntilTimeout + ); + return null; + } + } + } + // The work expired. Commit immediately. + return commitRoot.bind(null, root, expirationTime); + } + case RootCompleted: { + // The work completed. Ready to commit. + return commitRoot.bind(null, root, expirationTime); + } + default: { + (function() { + { + throw ReactError("Unknown root exit status."); + } + })(); + } + } +} + +function markRenderEventTime(expirationTime) { + if (expirationTime < workInProgressRootMostRecentEventTime) { + workInProgressRootMostRecentEventTime = expirationTime; + } +} + +function renderDidSuspend() { + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootSuspended; + } +} + +function renderDidError() { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) { + workInProgressRootExitStatus = RootErrored; + } +} + +function inferTimeFromExpirationTime(expirationTime) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; +} + +function workLoopSync() { + // Already timed out, so perform work without checking if we need to yield. + while (workInProgress !== null) { + workInProgress = performUnitOfWork(workInProgress); + } +} + +function workLoop() { + // Perform work until Scheduler asks us to yield + while (workInProgress !== null && !shouldYield()) { + workInProgress = performUnitOfWork(workInProgress); + } +} + +function performUnitOfWork(unitOfWork) { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current$$1 = unitOfWork.alternate; + + startWorkTimer(unitOfWork); + setCurrentFiber(unitOfWork); + + var next = void 0; + if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoContext) { + startProfilerTimer(unitOfWork); + next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime); + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); + } else { + next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime); + } + + resetCurrentFiber(); + unitOfWork.memoizedProps = unitOfWork.pendingProps; + if (next === null) { + // If this doesn't spawn new work, complete the current work. + next = completeUnitOfWork(unitOfWork); + } + + ReactCurrentOwner$2.current = null; + return next; +} + +function completeUnitOfWork(unitOfWork) { + // Attempt to complete the current unit of work, then move to the next + // sibling. If there are no more siblings, return to the parent fiber. + workInProgress = unitOfWork; + do { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current$$1 = workInProgress.alternate; + var returnFiber = workInProgress.return; + + // Check if the work completed or if something threw. + if ((workInProgress.effectTag & Incomplete) === NoEffect) { + setCurrentFiber(workInProgress); + var next = void 0; + if ( + !enableProfilerTimer || + (workInProgress.mode & ProfileMode) === NoContext + ) { + next = completeWork(current$$1, workInProgress, renderExpirationTime); + } else { + startProfilerTimer(workInProgress); + next = completeWork(current$$1, workInProgress, renderExpirationTime); + // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + } + stopWorkTimer(workInProgress); + resetCurrentFiber(); + resetChildExpirationTime(workInProgress); + + if (next !== null) { + // Completing this fiber spawned new work. Work on that next. + return next; + } + + if ( + returnFiber !== null && + // Do not append effects to parents if a sibling failed to complete + (returnFiber.effectTag & Incomplete) === NoEffect + ) { + // Append all the effects of the subtree and this fiber onto the effect + // list of the parent. The completion order of the children affects the + // side-effect order. + if (returnFiber.firstEffect === null) { + returnFiber.firstEffect = workInProgress.firstEffect; + } + if (workInProgress.lastEffect !== null) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; + } + returnFiber.lastEffect = workInProgress.lastEffect; + } + + // If this fiber had side-effects, we append it AFTER the children's + // side-effects. We can perform certain side-effects earlier if needed, + // by doing multiple passes over the effect list. We don't want to + // schedule our own side-effect on our own list because if end up + // reusing children we'll schedule this effect onto itself since we're + // at the end. + var effectTag = workInProgress.effectTag; + + // Skip both NoWork and PerformedWork tags when creating the effect + // list. PerformedWork effect is read by React DevTools but shouldn't be + // committed. + if (effectTag > PerformedWork) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = workInProgress; + } else { + returnFiber.firstEffect = workInProgress; + } + returnFiber.lastEffect = workInProgress; + } + } + } else { + // This fiber did not complete because something threw. Pop values off + // the stack without entering the complete phase. If this is a boundary, + // capture values if possible. + var _next = unwindWork(workInProgress, renderExpirationTime); + + // Because this fiber did not complete, don't reset its expiration time. + + if ( + enableProfilerTimer && + (workInProgress.mode & ProfileMode) !== NoContext + ) { + // Record the render duration for the fiber that errored. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + + // Include the time spent working on failed children before continuing. + var actualDuration = workInProgress.actualDuration; + var child = workInProgress.child; + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + workInProgress.actualDuration = actualDuration; + } + + if (_next !== null) { + // If completing this work spawned new work, do that next. We'll come + // back here again. + // Since we're restarting, remove anything that is not a host effect + // from the effect tag. + // TODO: The name stopFailedWorkTimer is misleading because Suspense + // also captures and restarts. + stopFailedWorkTimer(workInProgress); + _next.effectTag &= HostEffectMask; + return _next; + } + stopWorkTimer(workInProgress); + + if (returnFiber !== null) { + // Mark the parent fiber as incomplete and clear its effect list. + returnFiber.firstEffect = returnFiber.lastEffect = null; + returnFiber.effectTag |= Incomplete; + } + } + + var siblingFiber = workInProgress.sibling; + if (siblingFiber !== null) { + // If there is more work to do in this returnFiber, do that next. + return siblingFiber; + } + // Otherwise, return to the parent + workInProgress = returnFiber; + } while (workInProgress !== null); + + // We've reached the root. + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootCompleted; + } + return null; +} + +function resetChildExpirationTime(completedWork) { + if ( + renderExpirationTime !== Never && + completedWork.childExpirationTime === Never + ) { + // The children of this component are hidden. Don't bubble their + // expiration times. + return; + } + + var newChildExpirationTime = NoWork; + + // Bubble up the earliest expiration time. + if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoContext) { + // In profiling mode, resetChildExpirationTime is also used to reset + // profiler durations. + var actualDuration = completedWork.actualDuration; + var treeBaseDuration = completedWork.selfBaseDuration; + + // When a fiber is cloned, its actualDuration is reset to 0. This value will + // only be updated if work is done on the fiber (i.e. it doesn't bailout). + // When work is done, it should bubble to the parent's actualDuration. If + // the fiber has not been cloned though, (meaning no work was done), then + // this value will reflect the amount of time spent working on a previous + // render. In that case it should not bubble. We determine whether it was + // cloned by comparing the child pointer. + var shouldBubbleActualDurations = + completedWork.alternate === null || + completedWork.child !== completedWork.alternate.child; + + var child = completedWork.child; + while (child !== null) { + var childUpdateExpirationTime = child.expirationTime; + var childChildExpirationTime = child.childExpirationTime; + if (childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childUpdateExpirationTime; + } + if (childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childChildExpirationTime; + } + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + completedWork.actualDuration = actualDuration; + completedWork.treeBaseDuration = treeBaseDuration; + } else { + var _child = completedWork.child; + while (_child !== null) { + var _childUpdateExpirationTime = _child.expirationTime; + var _childChildExpirationTime = _child.childExpirationTime; + if (_childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childUpdateExpirationTime; + } + if (_childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childChildExpirationTime; + } + _child = _child.sibling; + } + } + + completedWork.childExpirationTime = newChildExpirationTime; +} + +function commitRoot(root, expirationTime) { + runWithPriority( + ImmediatePriority, + commitRootImpl.bind(null, root, expirationTime) + ); + // If there are passive effects, schedule a callback to flush them. This goes + // outside commitRootImpl so that it inherits the priority of the render. + if (rootWithPendingPassiveEffects !== null) { + var priorityLevel = getCurrentPriorityLevel(); + scheduleCallback(priorityLevel, function() { + flushPassiveEffects(); + return null; + }); + } + return null; +} + +function commitRootImpl(root, expirationTime) { + flushPassiveEffects(); + flushRenderPhaseStrictModeWarningsInDEV(); + + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Should not already be working."); + } + })(); + var finishedWork = root.current.alternate; + (function() { + if (!(finishedWork !== null)) { + throw ReactError("Should have a work-in-progress root."); + } + })(); + + // commitRoot never returns a continuation; it always finishes synchronously. + // So we can clear these now to allow a new callback to be scheduled. + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + + startCommitTimer(); + + // Update the first and last pending times on this root. The new first + // pending time is whatever is left on the root fiber. + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; + var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + var firstPendingTimeBeforeCommit = + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit; + root.firstPendingTime = firstPendingTimeBeforeCommit; + if (firstPendingTimeBeforeCommit < root.lastPendingTime) { + // This usually means we've finished all the work, but it can also happen + // when something gets downprioritized during render, like a hidden tree. + root.lastPendingTime = firstPendingTimeBeforeCommit; + } + + if (root === workInProgressRoot) { + // We can reset these now that they are finished. + workInProgressRoot = null; + workInProgress = null; + renderExpirationTime = NoWork; + } else { + } + // This indicates that the last root we worked on is not the same one that + // we're committing now. This most commonly happens when a suspended root + // times out. + + // Get the list of effects. + var firstEffect = void 0; + if (finishedWork.effectTag > PerformedWork) { + // A fiber's effect list consists only of its children, not itself. So if + // the root has an effect, we need to add it to the end of the list. The + // resulting list is the set that would belong to the root's parent, if it + // had one; that is, all the effects in the tree including the root. + if (finishedWork.lastEffect !== null) { + finishedWork.lastEffect.nextEffect = finishedWork; + firstEffect = finishedWork.firstEffect; + } else { + firstEffect = finishedWork; + } + } else { + // There is no effect on the root. + firstEffect = finishedWork.firstEffect; + } + + if (firstEffect !== null) { + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + // Reset this to null before calling lifecycles + ReactCurrentOwner$2.current = null; + + // The commit phase is broken into several sub-phases. We do a separate pass + // of the effect list for each phase: all mutation effects come before all + // layout effects, and so on. + + // The first phase a "before mutation" phase. We use this phase to read the + // state of the host tree right before we mutate it. This is where + // getSnapshotBeforeUpdate is called. + startCommitSnapshotEffectsTimer(); + prepareForCommit(root.containerInfo); + nextEffect = firstEffect; + do { + { + invokeGuardedCallback(null, commitBeforeMutationEffects, null); + if (hasCaughtError()) { + (function() { + if (!(nextEffect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var error = clearCaughtError(); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + stopCommitSnapshotEffectsTimer(); + + if (enableProfilerTimer) { + // Mark the current commit time to be shared by all Profilers in this + // batch. This enables them to be grouped later. + recordCommitTime(); + } + + // The next phase is the mutation phase, where we mutate the host tree. + startCommitHostEffectsTimer(); + nextEffect = firstEffect; + do { + { + invokeGuardedCallback(null, commitMutationEffects, null); + if (hasCaughtError()) { + (function() { + if (!(nextEffect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var _error = clearCaughtError(); + captureCommitPhaseError(nextEffect, _error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + stopCommitHostEffectsTimer(); + resetAfterCommit(root.containerInfo); + + // The work-in-progress tree is now the current tree. This must come after + // the mutation phase, so that the previous tree is still current during + // componentWillUnmount, but before the layout phase, so that the finished + // work is current during componentDidMount/Update. + root.current = finishedWork; + + // The next phase is the layout phase, where we call effects that read + // the host tree after it's been mutated. The idiomatic use case for this is + // layout, but class component lifecycles also fire here for legacy reasons. + startCommitLifeCyclesTimer(); + nextEffect = firstEffect; + do { + { + invokeGuardedCallback( + null, + commitLayoutEffects, + null, + root, + expirationTime + ); + if (hasCaughtError()) { + (function() { + if (!(nextEffect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var _error2 = clearCaughtError(); + captureCommitPhaseError(nextEffect, _error2); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + stopCommitLifeCyclesTimer(); + + nextEffect = null; + + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + workPhase = prevWorkPhase; + } else { + // No effects. + root.current = finishedWork; + // Measure these anyway so the flamegraph explicitly shows that there were + // no effects. + // TODO: Maybe there's a better way to report this. + startCommitSnapshotEffectsTimer(); + stopCommitSnapshotEffectsTimer(); + if (enableProfilerTimer) { + recordCommitTime(); + } + startCommitHostEffectsTimer(); + stopCommitHostEffectsTimer(); + startCommitLifeCyclesTimer(); + stopCommitLifeCyclesTimer(); + } + + stopCommitTimer(); + + if (rootDoesHavePassiveEffects) { + // This commit has passive effects. Stash a reference to them. But don't + // schedule a callback until after flushing layout work. + rootDoesHavePassiveEffects = false; + rootWithPendingPassiveEffects = root; + pendingPassiveEffectsExpirationTime = expirationTime; + } else { + if (enableSchedulerTracing) { + // If there are no passive effects, then we can complete the pending + // interactions. Otherwise, we'll wait until after the passive effects + // are flushed. + finishPendingInteractions(root, expirationTime); + } + } + + // Check if there's remaining work on this root + var remainingExpirationTime = root.firstPendingTime; + if (remainingExpirationTime !== NoWork) { + var currentTime = requestCurrentTime(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + remainingExpirationTime + ); + scheduleCallbackForRoot(root, priorityLevel, remainingExpirationTime); + } else { + // If there's no remaining work, we can clear the set of already failed + // error boundaries. + legacyErrorBoundariesThatAlreadyFailed = null; + } + + onCommitRoot(finishedWork.stateNode); + + if (remainingExpirationTime === Sync) { + // Count the number of times the root synchronously re-renders without + // finishing. If there are too many, it indicates an infinite update loop. + if (root === rootWithNestedUpdates) { + nestedUpdateCount++; + } else { + nestedUpdateCount = 0; + rootWithNestedUpdates = root; + } + } else { + nestedUpdateCount = 0; + } + + if (hasUncaughtError) { + hasUncaughtError = false; + var _error3 = firstUncaughtError; + firstUncaughtError = null; + throw _error3; + } + + if (workPhase === LegacyUnbatchedPhase) { + // This is a legacy edge case. We just committed the initial mount of + // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired + // synchronously, but layout updates should be deferred until the end + // of the batch. + return null; + } + + // If layout work was scheduled, flush it now. + flushImmediateQueue(); + return null; +} + +function commitBeforeMutationEffects() { + while (nextEffect !== null) { + if ((nextEffect.effectTag & Snapshot) !== NoEffect) { + setCurrentFiber(nextEffect); + recordEffect(); + + var current$$1 = nextEffect.alternate; + commitBeforeMutationLifeCycles(current$$1, nextEffect); + + resetCurrentFiber(); + } + nextEffect = nextEffect.nextEffect; + } +} + +function commitMutationEffects() { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + + var effectTag = nextEffect.effectTag; + + if (effectTag & ContentReset) { + commitResetTextContent(nextEffect); + } + + if (effectTag & Ref) { + var current$$1 = nextEffect.alternate; + if (current$$1 !== null) { + commitDetachRef(current$$1); + } + } + + // The following switch statement is only concerned about placement, + // updates, and deletions. To avoid needing to add a case for every possible + // bitmap value, we remove the secondary effects from the effect tag and + // switch on that value. + var primaryEffectTag = effectTag & (Placement | Update | Deletion); + switch (primaryEffectTag) { + case Placement: { + commitPlacement(nextEffect); + // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + // TODO: findDOMNode doesn't rely on this any more but isMounted does + // and isMounted is deprecated anyway so we should be able to kill this. + nextEffect.effectTag &= ~Placement; + break; + } + case PlacementAndUpdate: { + // Placement + commitPlacement(nextEffect); + // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + nextEffect.effectTag &= ~Placement; + + // Update + var _current = nextEffect.alternate; + commitWork(_current, nextEffect); + break; + } + case Update: { + var _current2 = nextEffect.alternate; + commitWork(_current2, nextEffect); + break; + } + case Deletion: { + commitDeletion(nextEffect); + break; + } + } + + // TODO: Only record a mutation effect if primaryEffectTag is non-zero. + recordEffect(); + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} + +function commitLayoutEffects(root, committedExpirationTime) { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + + var effectTag = nextEffect.effectTag; + + if (effectTag & (Update | Callback)) { + recordEffect(); + var current$$1 = nextEffect.alternate; + commitLifeCycles(root, current$$1, nextEffect, committedExpirationTime); + } + + if (effectTag & Ref) { + recordEffect(); + commitAttachRef(nextEffect); + } + + if (effectTag & Passive) { + rootDoesHavePassiveEffects = true; + } + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} + +function flushPassiveEffects() { + if (rootWithPendingPassiveEffects === null) { + return false; + } + var root = rootWithPendingPassiveEffects; + var expirationTime = pendingPassiveEffectsExpirationTime; + rootWithPendingPassiveEffects = null; + pendingPassiveEffectsExpirationTime = NoWork; + + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Cannot flush passive effects while already rendering."); + } + })(); + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + + // Note: This currently assumes there are no passive effects on the root + // fiber, because the root is not part of its own effect list. This could + // change in the future. + var effect = root.current.firstEffect; + while (effect !== null) { + { + setCurrentFiber(effect); + invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + if (hasCaughtError()) { + (function() { + if (!(effect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var error = clearCaughtError(); + captureCommitPhaseError(effect, error); + } + resetCurrentFiber(); + } + effect = effect.nextEffect; + } + + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + finishPendingInteractions(root, expirationTime); + } + + workPhase = prevWorkPhase; + flushImmediateQueue(); + + // If additional passive effects were scheduled, increment a counter. If this + // exceeds the limit, we'll fire a warning. + nestedPassiveUpdateCount = + rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; + + return true; +} + +function isAlreadyFailedLegacyErrorBoundary(instance) { + return ( + legacyErrorBoundariesThatAlreadyFailed !== null && + legacyErrorBoundariesThatAlreadyFailed.has(instance) + ); +} + +function markLegacyErrorBoundaryAsFailed(instance) { + if (legacyErrorBoundariesThatAlreadyFailed === null) { + legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); + } else { + legacyErrorBoundariesThatAlreadyFailed.add(instance); + } +} + +function prepareToThrowUncaughtError(error) { + if (!hasUncaughtError) { + hasUncaughtError = true; + firstUncaughtError = error; + } +} +var onUncaughtError = prepareToThrowUncaughtError; + +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); + enqueueUpdate(rootFiber, update); + var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); + if (root !== null) { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + } +} + +function captureCommitPhaseError(sourceFiber, error) { + if (sourceFiber.tag === HostRoot) { + // Error was thrown at the root. There is no parent, so the root + // itself should capture it. + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + return; + } + + var fiber = sourceFiber.return; + while (fiber !== null) { + if (fiber.tag === HostRoot) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + return; + } else if (fiber.tag === ClassComponent) { + var ctor = fiber.type; + var instance = fiber.stateNode; + if ( + typeof ctor.getDerivedStateFromError === "function" || + (typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance)) + ) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createClassErrorUpdate( + fiber, + errorInfo, + // TODO: This is always sync + Sync + ); + enqueueUpdate(fiber, update); + var root = markUpdateTimeFromFiberToRoot(fiber, Sync); + if (root !== null) { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + } + return; + } + } + fiber = fiber.return; + } +} + +function pingSuspendedRoot(root, thenable, suspendedTime) { + var pingCache = root.pingCache; + if (pingCache !== null) { + // The thenable resolved, so we no longer need to memoize, because it will + // never be thrown again. + pingCache.delete(thenable); + } + + if (workInProgressRoot === root && renderExpirationTime === suspendedTime) { + // Received a ping at the same priority level at which we're currently + // rendering. Restart from the root. Don't need to schedule a ping because + // we're already working on this tree. + prepareFreshStack(root, renderExpirationTime); + return; + } + + var lastPendingTime = root.lastPendingTime; + if (lastPendingTime < suspendedTime) { + // The root is no longer suspended at this time. + return; + } + + var pingTime = root.pingTime; + if (pingTime !== NoWork && pingTime < suspendedTime) { + // There's already a lower priority ping scheduled. + return; + } + + // Mark the time at which this ping was scheduled. + root.pingTime = suspendedTime; + + var currentTime = requestCurrentTime(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + suspendedTime + ); + scheduleCallbackForRoot(root, priorityLevel, suspendedTime); +} + +function retryTimedOutBoundary(boundaryFiber) { + // The boundary fiber (a Suspense component) previously timed out and was + // rendered in its fallback state. One of the promises that suspended it has + // resolved, which means at least part of the tree was likely unblocked. Try + // rendering again, at a new expiration time. + var currentTime = requestCurrentTime(); + var retryTime = computeExpirationForFiber(currentTime, boundaryFiber); + // TODO: Special case idle priority? + var priorityLevel = inferPriorityFromExpirationTime(currentTime, retryTime); + var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); + if (root !== null) { + scheduleCallbackForRoot(root, priorityLevel, retryTime); + } +} + +function resolveRetryThenable(boundaryFiber, thenable) { + var retryCache = void 0; + if (enableSuspenseServerRenderer) { + switch (boundaryFiber.tag) { + case SuspenseComponent: + retryCache = boundaryFiber.stateNode; + break; + case DehydratedSuspenseComponent: + retryCache = boundaryFiber.memoizedState; + break; + default: + (function() { + { + throw ReactError( + "Pinged unknown suspense boundary type. This is probably a bug in React." + ); + } + })(); + } + } else { + retryCache = boundaryFiber.stateNode; + } + + if (retryCache !== null) { + // The thenable resolved, so we no longer need to memoize, because it will + // never be thrown again. + retryCache.delete(thenable); + } + + retryTimedOutBoundary(boundaryFiber); +} + +// Computes the next Just Noticeable Difference (JND) boundary. +// The theory is that a person can't tell the difference between small differences in time. +// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable +// difference in the experience. However, waiting for longer might mean that we can avoid +// showing an intermediate loading state. The longer we have already waited, the harder it +// is to tell small differences in time. Therefore, the longer we've already waited, +// the longer we can wait additionally. At some point we have to give up though. +// We pick a train model where the next boundary commits at a consistent schedule. +// These particular numbers are vague estimates. We expect to adjust them based on research. +function jnd(timeElapsed) { + return timeElapsed < 120 + ? 120 + : timeElapsed < 480 + ? 480 + : timeElapsed < 1080 + ? 1080 + : timeElapsed < 1920 + ? 1920 + : timeElapsed < 3000 + ? 3000 + : timeElapsed < 4320 + ? 4320 + : ceil(timeElapsed / 1960) * 1960; +} + +function computeMsUntilTimeout(mostRecentEventTime, committedExpirationTime) { + if (disableYielding) { + // Timeout immediately when yielding is disabled. + return 0; + } + + var eventTimeMs = inferTimeFromExpirationTime(mostRecentEventTime); + var currentTimeMs = now(); + var timeElapsed = currentTimeMs - eventTimeMs; + + var msUntilTimeout = jnd(timeElapsed) - timeElapsed; + + // Compute the time until this render pass would expire. + var timeUntilExpirationMs = + expirationTimeToMs(committedExpirationTime) - currentTimeMs; + + // Clamp the timeout to the expiration time. + // TODO: Once the event time is exact instead of inferred from expiration time + // we don't need this. + if (timeUntilExpirationMs < msUntilTimeout) { + msUntilTimeout = timeUntilExpirationMs; + } + + // This is the value that is passed to `setTimeout`. + return msUntilTimeout; +} + +function checkForNestedUpdates() { + if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { + nestedUpdateCount = 0; + rootWithNestedUpdates = null; + (function() { + { + throw ReactError( + "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." + ); + } + })(); + } + + { + if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { + nestedPassiveUpdateCount = 0; + warning$1( + false, + "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." + ); + } + } +} + +function flushRenderPhaseStrictModeWarningsInDEV() { + { + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + ReactStrictModeWarnings.flushLegacyContextWarning(); + + if (warnAboutDeprecatedLifecycles) { + ReactStrictModeWarnings.flushPendingDeprecationWarnings(); + } + } +} + +function stopFinishedWorkLoopTimer() { + var didCompleteRoot = true; + stopWorkLoopTimer(interruptedBy, didCompleteRoot); + interruptedBy = null; +} + +function stopInterruptedWorkLoopTimer() { + // TODO: Track which fiber caused the interruption. + var didCompleteRoot = false; + stopWorkLoopTimer(interruptedBy, didCompleteRoot); + interruptedBy = null; +} + +function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { + if ( + enableUserTimingAPI && + workInProgressRoot !== null && + updateExpirationTime > renderExpirationTime + ) { + interruptedBy = fiberThatReceivedUpdate; + } +} + +var didWarnStateUpdateForUnmountedComponent = null; +function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { + { + var tag = fiber.tag; + if ( + tag !== HostRoot && + tag !== ClassComponent && + tag !== FunctionComponent && + tag !== ForwardRef && + tag !== MemoComponent && + tag !== SimpleMemoComponent + ) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } + // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. + var componentName = getComponentName(fiber.type) || "ReactComponent"; + if (didWarnStateUpdateForUnmountedComponent !== null) { + if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { + return; + } + didWarnStateUpdateForUnmountedComponent.add(componentName); + } else { + didWarnStateUpdateForUnmountedComponent = new Set([componentName]); + } + warningWithoutStack$1( + false, + "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.%s", + tag === ClassComponent + ? "the componentWillUnmount method" + : "a useEffect cleanup function", + getStackByFiberInDevAndProd(fiber) + ); + } +} + +var beginWork$$1 = void 0; +if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + var dummyFiber = null; + beginWork$$1 = function(current$$1, unitOfWork, expirationTime) { + // If a component throws an error, we replay it again in a synchronously + // dispatched event, so that the debugger will treat it as an uncaught + // error See ReactErrorUtils for more information. + + // Before entering the begin phase, copy the work-in-progress onto a dummy + // fiber. If beginWork throws, we'll use this to reset the state. + var originalWorkInProgressCopy = assignFiberPropertiesInDEV( + dummyFiber, + unitOfWork + ); + try { + return beginWork$1(current$$1, unitOfWork, expirationTime); + } catch (originalError) { + if ( + originalError !== null && + typeof originalError === "object" && + typeof originalError.then === "function" + ) { + // Don't replay promises. Treat everything else like an error. + throw originalError; + } + + // Keep this code in sync with renderRoot; any changes here must have + // corresponding changes there. + resetContextDependences(); + resetHooks(); + + // Unwind the failed stack frame + unwindInterruptedWork(unitOfWork); + + // Restore the original properties of the fiber. + assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); + + if (enableProfilerTimer && unitOfWork.mode & ProfileMode) { + // Reset the profiler timer. + startProfilerTimer(unitOfWork); + } + + // Run beginWork again. + invokeGuardedCallback( + null, + beginWork$1, + null, + current$$1, + unitOfWork, + expirationTime + ); + + if (hasCaughtError()) { + var replayError = clearCaughtError(); + // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. + // Rethrow this error instead of the original one. + throw replayError; + } else { + // This branch is reachable if the render phase is impure. + throw originalError; + } + } + }; +} else { + beginWork$$1 = beginWork$1; +} + +var didWarnAboutUpdateInRender = false; +var didWarnAboutUpdateInGetChildContext = false; +function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { + { + if (fiber.tag === ClassComponent) { + switch (phase) { + case "getChildContext": + if (didWarnAboutUpdateInGetChildContext) { + return; + } + warningWithoutStack$1( + false, + "setState(...): Cannot call setState() inside getChildContext()" + ); + didWarnAboutUpdateInGetChildContext = true; + break; + case "render": + if (didWarnAboutUpdateInRender) { + return; + } + warningWithoutStack$1( + false, + "Cannot update during an existing state transition (such as " + + "within `render`). Render methods should be a pure function of " + + "props and state." + ); + didWarnAboutUpdateInRender = true; + break; + } + } + } +} + +function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { + { + if ( + workPhase === NotWorking && + ReactShouldWarnActingUpdates.current === false + ) { warningWithoutStack$1( false, "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" + + "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." + + "This ensures that you're testing the behavior the user would see " + + "in the browser." + " Learn more at https://fb.me/react-wrap-tests-with-act" + "%s", getComponentName(fiber.type), @@ -17638,652 +18391,157 @@ function warnIfNotCurrentlyBatchingInDev(fiber) { } } -function scheduleWork(fiber, expirationTime) { - var root = scheduleWorkToRoot(fiber, expirationTime); - if (root === null) { - { - switch (fiber.tag) { - case ClassComponent: - warnAboutUpdateOnUnmounted(fiber, true); - break; - case FunctionComponent: - case ForwardRef: - case MemoComponent: - case SimpleMemoComponent: - warnAboutUpdateOnUnmounted(fiber, false); - break; - } - } +var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; + +function computeThreadID(root, expirationTime) { + // Interaction threads are unique per root and expiration time. + return expirationTime * 1000 + root.interactionThreadID; +} + +function schedulePendingInteraction(root, expirationTime) { + // This is called when work is scheduled on a root. It sets up a pending + // interaction, which is completed once the work commits. + if (!enableSchedulerTracing) { return; } - if ( - !isWorking && - nextRenderExpirationTime !== NoWork && - expirationTime > nextRenderExpirationTime - ) { - // This is an interruption. (Used for performance tracking.) - interruptedBy = fiber; - resetStack(); - } - markPendingPriorityLevel(root, expirationTime); - if ( - // If we're in the render phase, we don't need to schedule this root - // for an update, because we'll do it before we exit... - !isWorking || - isCommitting$1 || - // ...unless this is a different root than the one we're rendering. - nextRoot !== root - ) { - var rootExpirationTime = root.expirationTime; - requestWork(root, rootExpirationTime); - } - if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { - // Reset this back to zero so subsequent updates don't throw. - nestedUpdateCount = 0; - invariant( - false, - "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." - ); - } -} + var interactions = tracing.__interactionsRef.current; + if (interactions.size > 0) { + var pendingInteractionMap = root.pendingInteractionMap; + var pendingInteractions = pendingInteractionMap.get(expirationTime); + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (!pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } -// TODO: Everything below this is written as if it has been lifted to the -// renderers. I'll do this in a follow-up. - -// Linked-list of roots -var firstScheduledRoot = null; -var lastScheduledRoot = null; - -var callbackExpirationTime = NoWork; -var callbackID = void 0; -var isRendering = false; -var nextFlushedRoot = null; -var nextFlushedExpirationTime = NoWork; -var lowestPriorityPendingInteractiveExpirationTime = NoWork; -var hasUnhandledError = false; -var unhandledError = null; - -var isBatchingUpdates = false; -var isUnbatchingUpdates = false; - -var completedBatches = null; - -var originalStartTimeMs = now$$1(); -var currentRendererTime = msToExpirationTime(originalStartTimeMs); -var currentSchedulerTime = currentRendererTime; - -// Use these to prevent an infinite loop of nested updates -var NESTED_UPDATE_LIMIT = 50; -var nestedUpdateCount = 0; -var lastCommittedRootDuringThisBatch = null; - -function recomputeCurrentRendererTime() { - var currentTimeMs = now$$1() - originalStartTimeMs; - currentRendererTime = msToExpirationTime(currentTimeMs); -} - -function scheduleCallbackWithExpirationTime(root, expirationTime) { - if (callbackExpirationTime !== NoWork) { - // A callback is already scheduled. Check its expiration time (timeout). - if (expirationTime < callbackExpirationTime) { - // Existing callback has sufficient timeout. Exit. - return; + pendingInteractions.add(interaction); + }); } else { - if (callbackID !== null) { - // Existing callback has insufficient timeout. Cancel and schedule a - // new one. - cancelDeferredCallback$$1(callbackID); - } + pendingInteractionMap.set(expirationTime, new Set(interactions)); + + // Update the pending async work count for the current interactions. + interactions.forEach(function(interaction) { + interaction.__count++; + }); } - // The request callback timer is already running. Don't start a new one. - } else { - startRequestCallbackTimer(); + + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID(root, expirationTime); + subscriber.onWorkScheduled(interactions, threadID); + } + } +} + +function startWorkOnPendingInteraction(root, expirationTime) { + // This is called when new work is started on a root. + if (!enableSchedulerTracing) { + return; } - callbackExpirationTime = expirationTime; - var currentMs = now$$1() - originalStartTimeMs; - var expirationTimeMs = expirationTimeToMs(expirationTime); - var timeout = expirationTimeMs - currentMs; - callbackID = scheduleDeferredCallback$$1(performAsyncWork, { - timeout: timeout + // Determine which interactions this batch of work currently includes, So that + // we can accurately attribute time spent working on it, And so that cascading + // work triggered during the render phase will be associated with it. + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if (scheduledExpirationTime >= expirationTime) { + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + } }); -} -// For every call to renderRoot, one of onFatal, onComplete, onSuspend, and -// onYield is called upon exiting. We use these in lieu of returning a tuple. -// I've also chosen not to inline them into renderRoot because these will -// eventually be lifted into the renderer. -function onFatal(root) { - root.finishedWork = null; -} + // Store the current set of interactions on the FiberRoot for a few reasons: + // We can re-use it in hot functions like renderRoot() without having to + // recalculate it. We will also use it in commitWork() to pass to any Profiler + // onRender() hooks. This also provides DevTools with a way to access it when + // the onCommitRoot() hook is called. + root.memoizedInteractions = interactions; -function onComplete(root, finishedWork, expirationTime) { - root.pendingCommitExpirationTime = expirationTime; - root.finishedWork = finishedWork; -} - -function onSuspend( - root, - finishedWork, - suspendedExpirationTime, - rootExpirationTime, - msUntilTimeout -) { - root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYield$$1()) { - // Don't wait an additional tick. Commit the tree immediately. - root.pendingCommitExpirationTime = suspendedExpirationTime; - root.finishedWork = finishedWork; - } else if (msUntilTimeout > 0) { - // Wait `msUntilTimeout` milliseconds before committing. - root.timeoutHandle = scheduleTimeout( - onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), - msUntilTimeout - ); - } -} - -function onYield(root) { - root.finishedWork = null; -} - -function onTimeout(root, finishedWork, suspendedExpirationTime) { - // The root timed out. Commit it. - root.pendingCommitExpirationTime = suspendedExpirationTime; - root.finishedWork = finishedWork; - // Read the current time before entering the commit phase. We can be - // certain this won't cause tearing related to batching of event updates - // because we're at the top of a timer event. - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - flushRoot(root, suspendedExpirationTime); -} - -function onCommit(root, expirationTime) { - root.expirationTime = expirationTime; - root.finishedWork = null; -} - -function requestCurrentTime() { - // requestCurrentTime is called by the scheduler to compute an expiration - // time. - // - // Expiration times are computed by adding to the current time (the start - // time). However, if two updates are scheduled within the same event, we - // should treat their start times as simultaneous, even if the actual clock - // time has advanced between the first and second call. - - // In other words, because expiration times determine how updates are batched, - // we want all updates of like priority that occur within the same event to - // receive the same expiration time. Otherwise we get tearing. - // - // We keep track of two separate times: the current "renderer" time and the - // current "scheduler" time. The renderer time can be updated whenever; it - // only exists to minimize the calls performance.now. - // - // But the scheduler time can only be updated if there's no pending work, or - // if we know for certain that we're not in the middle of an event. - - if (isRendering) { - // We're already rendering. Return the most recently read time. - return currentSchedulerTime; - } - // Check if there's pending work. - findHighestPriorityRoot(); - if ( - nextFlushedExpirationTime === NoWork || - nextFlushedExpirationTime === Never - ) { - // If there's no pending work, or if the pending work is offscreen, we can - // read the current time without risk of tearing. - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - return currentSchedulerTime; - } - // There's already pending work. We might be in the middle of a browser - // event. If we were to read the current time, it could cause multiple updates - // within the same event to receive different expiration times, leading to - // tearing. Return the last read time. During the next idle callback, the - // time will be updated. - return currentSchedulerTime; -} - -// requestWork is called by the scheduler whenever a root receives an update. -// It's up to the renderer to call renderRoot at some point in the future. -function requestWork(root, expirationTime) { - addRootToSchedule(root, expirationTime); - if (isRendering) { - // Prevent reentrancy. Remaining work will be scheduled at the end of - // the currently rendering batch. - return; - } - - if (isBatchingUpdates) { - // Flush work at the end of the batch. - if (isUnbatchingUpdates) { - // ...unless we're inside unbatchedUpdates, in which case we should - // flush it now. - nextFlushedRoot = root; - nextFlushedExpirationTime = Sync; - performWorkOnRoot(root, Sync, false); - } - return; - } - - // TODO: Get rid of Sync and use current time? - if (expirationTime === Sync) { - performSyncWork(); - } else { - scheduleCallbackWithExpirationTime(root, expirationTime); - } -} - -function addRootToSchedule(root, expirationTime) { - // Add the root to the schedule. - // Check if this root is already part of the schedule. - if (root.nextScheduledRoot === null) { - // This root is not already scheduled. Add it. - root.expirationTime = expirationTime; - if (lastScheduledRoot === null) { - firstScheduledRoot = lastScheduledRoot = root; - root.nextScheduledRoot = root; - } else { - lastScheduledRoot.nextScheduledRoot = root; - lastScheduledRoot = root; - lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; - } - } else { - // This root is already scheduled, but its priority may have increased. - var remainingExpirationTime = root.expirationTime; - if (expirationTime > remainingExpirationTime) { - // Update the priority. - root.expirationTime = expirationTime; - } - } -} - -function findHighestPriorityRoot() { - var highestPriorityWork = NoWork; - var highestPriorityRoot = null; - if (lastScheduledRoot !== null) { - var previousScheduledRoot = lastScheduledRoot; - var root = firstScheduledRoot; - while (root !== null) { - var remainingExpirationTime = root.expirationTime; - if (remainingExpirationTime === NoWork) { - // This root no longer has work. Remove it from the scheduler. - - // TODO: This check is redudant, but Flow is confused by the branch - // below where we set lastScheduledRoot to null, even though we break - // from the loop right after. - invariant( - previousScheduledRoot !== null && lastScheduledRoot !== null, - "Should have a previous and last root. This error is likely " + - "caused by a bug in React. Please file an issue." - ); - if (root === root.nextScheduledRoot) { - // This is the only root in the list. - root.nextScheduledRoot = null; - firstScheduledRoot = lastScheduledRoot = null; - break; - } else if (root === firstScheduledRoot) { - // This is the first root in the list. - var next = root.nextScheduledRoot; - firstScheduledRoot = next; - lastScheduledRoot.nextScheduledRoot = next; - root.nextScheduledRoot = null; - } else if (root === lastScheduledRoot) { - // This is the last root in the list. - lastScheduledRoot = previousScheduledRoot; - lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; - root.nextScheduledRoot = null; - break; - } else { - previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot; - root.nextScheduledRoot = null; - } - root = previousScheduledRoot.nextScheduledRoot; - } else { - if (remainingExpirationTime > highestPriorityWork) { - // Update the priority, if it's higher - highestPriorityWork = remainingExpirationTime; - highestPriorityRoot = root; - } - if (root === lastScheduledRoot) { - break; - } - if (highestPriorityWork === Sync) { - // Sync is highest priority by definition so - // we can stop searching. - break; - } - previousScheduledRoot = root; - root = root.nextScheduledRoot; - } - } - } - - nextFlushedRoot = highestPriorityRoot; - nextFlushedExpirationTime = highestPriorityWork; -} - -function performAsyncWork(didTimeout) { - if (didTimeout) { - // The callback timed out. That means at least one update has expired. - // Iterate through the root schedule. If they contain expired work, set - // the next render expiration time to the current time. This has the effect - // of flushing all expired work in a single batch, instead of flushing each - // level one at a time. - if (firstScheduledRoot !== null) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - didExpireAtExpirationTime(root, currentRendererTime); - // The root schedule is circular, so this is never null. - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); - } - } - performWork(NoWork, true); -} - -function performSyncWork() { - performWork(Sync, false); -} - -function performWork(minExpirationTime, isYieldy) { - // Keep working on roots until there's no more work, or until there's a higher - // priority event. - findHighestPriorityRoot(); - - if (isYieldy) { - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - - if (enableUserTimingAPI) { - var didExpire = nextFlushedExpirationTime > currentRendererTime; - var timeout = expirationTimeToMs(nextFlushedExpirationTime); - stopRequestCallbackTimer(didExpire, timeout); - } - - while ( - nextFlushedRoot !== null && - nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime && - !(shouldYield$$1() && currentRendererTime > nextFlushedExpirationTime) - ) { - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ); - findHighestPriorityRoot(); - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - } - } else { - while ( - nextFlushedRoot !== null && - nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime - ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); - findHighestPriorityRoot(); - } - } - - // We're done flushing work. Either we ran out of time in this callback, - // or there's no more work left with sufficient priority. - - // If we're inside a callback, set this to false since we just completed it. - if (isYieldy) { - callbackExpirationTime = NoWork; - callbackID = null; - } - // If there's work left over, schedule a new callback. - if (nextFlushedExpirationTime !== NoWork) { - scheduleCallbackWithExpirationTime( - nextFlushedRoot, - nextFlushedExpirationTime - ); - } - - // Clean-up. - finishRendering(); -} - -function flushRoot(root, expirationTime) { - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely " + - "means you attempted to commit from inside a lifecycle method." - ); - // Perform work on root as if the given expiration time is the current time. - // This has the effect of synchronously flushing all work up to and - // including the given time. - nextFlushedRoot = root; - nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, false); - // Flush any sync work that was scheduled by lifecycles - performSyncWork(); -} - -function finishRendering() { - nestedUpdateCount = 0; - lastCommittedRootDuringThisBatch = null; - - if (completedBatches !== null) { - var batches = completedBatches; - completedBatches = null; - for (var i = 0; i < batches.length; i++) { - var batch = batches[i]; + if (interactions.size > 0) { + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID(root, expirationTime); try { - batch._onComplete(); + subscriber.onWorkStarted(interactions, threadID); } catch (error) { - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); } } } - - if (hasUnhandledError) { - var error = unhandledError; - unhandledError = null; - hasUnhandledError = false; - throw error; - } } -function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused " + - "by a bug in React. Please file an issue." - ); - - isRendering = true; - - // Check if this is async work or sync/expired work. - if (!isYieldy) { - // Flush work without yielding. - // TODO: Non-yieldy work does not necessarily imply expired work. A renderer - // may want to perform some work without yielding, but also without - // requiring the root to complete (by triggering placeholders). - - var finishedWork = root.finishedWork; - if (finishedWork !== null) { - // This root is already complete. We can commit it. - completeRoot$1(root, finishedWork, expirationTime); - } else { - root.finishedWork = null; - // If this root previously suspended, clear its existing timeout, since - // we're about to try rendering again. - var timeoutHandle = root.timeoutHandle; - if (timeoutHandle !== noTimeout) { - root.timeoutHandle = noTimeout; - // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above - cancelTimeout(timeoutHandle); - } - renderRoot(root, isYieldy); - finishedWork = root.finishedWork; - if (finishedWork !== null) { - // We've completed the root. Commit it. - completeRoot$1(root, finishedWork, expirationTime); - } - } - } else { - // Flush async work. - var _finishedWork = root.finishedWork; - if (_finishedWork !== null) { - // This root is already complete. We can commit it. - completeRoot$1(root, _finishedWork, expirationTime); - } else { - root.finishedWork = null; - // If this root previously suspended, clear its existing timeout, since - // we're about to try rendering again. - var _timeoutHandle = root.timeoutHandle; - if (_timeoutHandle !== noTimeout) { - root.timeoutHandle = noTimeout; - // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above - cancelTimeout(_timeoutHandle); - } - renderRoot(root, isYieldy); - _finishedWork = root.finishedWork; - if (_finishedWork !== null) { - // We've completed the root. Check the if we should yield one more time - // before committing. - if (!shouldYield$$1()) { - // Still time left. Commit the root. - completeRoot$1(root, _finishedWork, expirationTime); - } else { - // There's no time left. Mark this root as complete. We'll come - // back and commit it later. - root.finishedWork = _finishedWork; - } - } - } +function finishPendingInteractions(root, committedExpirationTime) { + if (!enableSchedulerTracing) { + return; } - isRendering = false; -} + var earliestRemainingTimeAfterCommit = root.firstPendingTime; -function completeRoot$1(root, finishedWork, expirationTime) { - // Check if there's a batch that matches this expiration time. - var firstBatch = root.firstBatch; - if (firstBatch !== null && firstBatch._expirationTime >= expirationTime) { - if (completedBatches === null) { - completedBatches = [firstBatch]; - } else { - completedBatches.push(firstBatch); - } - if (firstBatch._defer) { - // This root is blocked from committing by a batch. Unschedule it until - // we receive another update. - root.finishedWork = finishedWork; - root.expirationTime = NoWork; - return; - } - } + var subscriber = void 0; - // Commit the root. - root.finishedWork = null; - - // Check if this is a nested update (a sync update scheduled during the - // commit phase). - if (root === lastCommittedRootDuringThisBatch) { - // If the next root is the same as the previous root, this is a nested - // update. To prevent an infinite loop, increment the nested update count. - nestedUpdateCount++; - } else { - // Reset whenever we switch roots. - lastCommittedRootDuringThisBatch = root; - nestedUpdateCount = 0; - } - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); - } - ); -} - -function onUncaughtError(error) { - invariant( - nextFlushedRoot !== null, - "Should be working on a root. This error is likely caused by a bug in " + - "React. Please file an issue." - ); - // Unschedule this root so we don't work on it again until there's - // another update. - nextFlushedRoot.expirationTime = NoWork; - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } -} - -// TODO: Batching should be implemented at the renderer level, not inside -// the reconciler. -function batchedUpdates$1(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = true; try { - return fn(a); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - if (!isBatchingUpdates && !isRendering) { - performSyncWork(); + subscriber = tracing.__subscriberRef.current; + if (subscriber !== null && root.memoizedInteractions.size > 0) { + var threadID = computeThreadID(root, committedExpirationTime); + subscriber.onWorkStopped(root.memoizedInteractions, threadID); } - } -} + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); + } finally { + // Clear completed interactions from the pending Map. + // Unless the render was suspended or cascading work was scheduled, + // In which case– leave pending interactions until the subsequent render. + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + // Only decrement the pending interaction count if we're done. + // If there's still work at the current priority, + // That indicates that we are waiting for suspense data. + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { + pendingInteractionMap.delete(scheduledExpirationTime); -function interactiveUpdates$1(fn, a, b) { - // If there are any pending interactive updates, synchronously flush them. - // This needs to happen before we read any handlers, because the effect of - // the previous event may influence which handlers are called during - // this event. - if ( - !isBatchingUpdates && - !isRendering && - lowestPriorityPendingInteractiveExpirationTime !== NoWork - ) { - // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); - lowestPriorityPendingInteractiveExpirationTime = NoWork; - } - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = true; - try { - return scheduler.unstable_runWithPriority( - scheduler.unstable_UserBlockingPriority, - function() { - return fn(a, b); + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); + } + } + }); } - ); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - if (!isBatchingUpdates && !isRendering) { - performSyncWork(); - } + }); } } -function flushInteractiveUpdates$1() { - if ( - !isRendering && - lowestPriorityPendingInteractiveExpirationTime !== NoWork - ) { - // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); - lowestPriorityPendingInteractiveExpirationTime = NoWork; - } -} +// This lets us hook into Fiber to debug what it's doing. +// See https://github.com/facebook/react/pull/8033. +// This is not part of the public API, not even for React DevTools. +// You may only inject a debugTool if you work on React Fiber itself. +var ReactFiberInstrumentation = { + debugTool: null +}; + +var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; // 0 is PROD, 1 is DEV. // Might add PROFILE later. @@ -18390,13 +18648,20 @@ function findHostInstance(component) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } else { - invariant( - false, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - ); + (function() { + { + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } + })(); } } var hostFiber = findCurrentHostFiber(fiber); @@ -18411,13 +18676,20 @@ function findHostInstanceWithWarning(component, methodName) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } else { - invariant( - false, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - ); + (function() { + { + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } + })(); } } var hostFiber = findCurrentHostFiber(fiber); @@ -18494,7 +18766,18 @@ function getPublicRootInstance(container) { } } +var shouldSuspendImpl = function(fiber) { + return false; +}; + +function shouldSuspend(fiber) { + return shouldSuspendImpl(fiber); +} + +var overrideHookState = null; var overrideProps = null; +var scheduleUpdate = null; +var setSuspenseHandler = null; { var copyWithSetImpl = function(obj, path, idx, value) { @@ -18512,6 +18795,33 @@ var overrideProps = null; return copyWithSetImpl(obj, path, 0, value); }; + // Support DevTools editable values for useState and useReducer. + overrideHookState = function(fiber, id, path, value) { + // For now, the "id" of stateful hooks is just the stateful hook index. + // This may change in the future with e.g. nested hooks. + var currentHook = fiber.memoizedState; + while (currentHook !== null && id > 0) { + currentHook = currentHook.next; + id--; + } + if (currentHook !== null) { + flushPassiveEffects(); + + var newState = copyWithSet(currentHook.memoizedState, path, value); + currentHook.memoizedState = newState; + currentHook.baseState = newState; + + // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + + scheduleWork(fiber, Sync); + } + }; + // Support DevTools props for function components, forwardRef, memo, host components, etc. overrideProps = function(fiber, path, value) { flushPassiveEffects(); @@ -18521,6 +18831,15 @@ var overrideProps = null; } scheduleWork(fiber, Sync); }; + + scheduleUpdate = function(fiber) { + flushPassiveEffects(); + scheduleWork(fiber, Sync); + }; + + setSuspenseHandler = function(newShouldSuspendImpl) { + shouldSuspendImpl = newShouldSuspendImpl; + }; } function injectIntoDevTools(devToolsConfig) { @@ -18529,7 +18848,10 @@ function injectIntoDevTools(devToolsConfig) { return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: overrideHookState, overrideProps: overrideProps, + setSuspenseHandler: setSuspenseHandler, + scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { var hostFiber = findCurrentHostFiber(fiber); @@ -18573,7 +18895,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.8.3"; +var ReactVersion = "16.8.6"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -18611,10 +18933,36 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * prop](docs/view.html#onlayout) instead. */ measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + // We can't call FabricUIManager here because it won't be loaded in paper + // at initialization time. See https://github.com/facebook/react/pull/15490 + // for more info. + nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }, /** @@ -18633,10 +18981,36 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * has been completed in native. */ measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + // We can't call FabricUIManager here because it won't be loaded in paper + // at initialization time. See https://github.com/facebook/react/pull/15490 + // for more info. + nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }, /** @@ -18652,12 +19026,56 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + return; + } else { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + + UIManager.measureLayout( + findNodeHandle(this), + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + } }, /** @@ -18667,17 +19085,6 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * Manipulation](docs/direct-manipulation.html)). */ setNativeProps: function(nativeProps) { - { - if (warnAboutDeprecatedSetNativeProps) { - warningWithoutStack$1( - false, - "Warning: Calling ref.setNativeProps(nativeProps) " + - "is deprecated and will be removed in a future release. " + - "Use the setNativeProps export from the react-native package instead." + - "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" - ); - } - } // Class components don't have viewConfig -> validateAttributes. // Nor does it make sense to set native props on a non-native component. // Instead, find the nearest host component and set props on it. @@ -18699,6 +19106,26 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { return; } + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + return; + } + + { + if (warnAboutDeprecatedSetNativeProps) { + warningWithoutStack$1( + false, + "Warning: Calling ref.setNativeProps(nativeProps) " + + "is deprecated and will be removed in a future release. " + + "Use the setNativeProps export from the react-native package instead." + + "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" + ); + } + } + var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; var viewConfig = @@ -18743,13 +19170,18 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { // true without actually implementing them (setting them to undefined // isn't allowed by ReactClass) var NativeMethodsMixin_DEV = NativeMethodsMixin; - invariant( - !NativeMethodsMixin_DEV.componentWillMount && - !NativeMethodsMixin_DEV.componentWillReceiveProps && - !NativeMethodsMixin_DEV.UNSAFE_componentWillMount && - !NativeMethodsMixin_DEV.UNSAFE_componentWillReceiveProps, - "Do not override existing functions." - ); + (function() { + if ( + !( + !NativeMethodsMixin_DEV.componentWillMount && + !NativeMethodsMixin_DEV.componentWillReceiveProps && + !NativeMethodsMixin_DEV.UNSAFE_componentWillMount && + !NativeMethodsMixin_DEV.UNSAFE_componentWillReceiveProps + ) + ) { + throw ReactError("Do not override existing functions."); + } + })(); // TODO (bvaughn) Remove cWM and cWRP in a future version of React Native, // Once these lifecycles have been remove from the reconciler. NativeMethodsMixin_DEV.componentWillMount = function() { @@ -18876,11 +19308,37 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { * [`onLayout` prop](docs/view.html#onlayout) instead. */ - ReactNativeComponent.prototype.measure = function measure(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + ReactNativeComponent.prototype.measure = function measure$$1(callback) { + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + // We can't call FabricUIManager here because it won't be loaded in paper + // at initialization time. See https://github.com/facebook/react/pull/15490 + // for more info. + nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }; /** @@ -18897,13 +19355,39 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { * These values are not available until after natives rendering completes. */ - ReactNativeComponent.prototype.measureInWindow = function measureInWindow( + ReactNativeComponent.prototype.measureInWindow = function measureInWindow$$1( callback ) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + // We can't call FabricUIManager here because it won't be loaded in paper + // at initialization time. See https://github.com/facebook/react/pull/15490 + // for more info. + nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }; /** @@ -18913,17 +19397,61 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { * Obtain a native node handle with `ReactNative.findNodeHandle(component)`. */ - ReactNativeComponent.prototype.measureLayout = function measureLayout( + ReactNativeComponent.prototype.measureLayout = function measureLayout$$1( relativeToNativeNode, onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + return; + } else { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + + UIManager.measureLayout( + findNodeHandle(this), + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + } }; /** @@ -18936,18 +19464,6 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { ReactNativeComponent.prototype.setNativeProps = function setNativeProps( nativeProps ) { - { - if (warnAboutDeprecatedSetNativeProps) { - warningWithoutStack$1( - false, - "Warning: Calling ref.setNativeProps(nativeProps) " + - "is deprecated and will be removed in a future release. " + - "Use the setNativeProps export from the react-native package instead." + - "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" - ); - } - } - // Class components don't have viewConfig -> validateAttributes. // Nor does it make sense to set native props on a non-native component. // Instead, find the nearest host component and set props on it. @@ -18969,6 +19485,26 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { return; } + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + return; + } + + { + if (warnAboutDeprecatedSetNativeProps) { + warningWithoutStack$1( + false, + "Warning: Calling ref.setNativeProps(nativeProps) " + + "is deprecated and will be removed in a future release. " + + "Use the setNativeProps export from the react-native package instead." + + "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" + ); + } + } + var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; var viewConfig = @@ -19109,36 +19645,6 @@ var getInspectorDataForViewTag = void 0; }; } -// Module provided by RN: -function setNativeProps(handle, nativeProps) { - if (handle._nativeTag == null) { - !(handle._nativeTag != null) - ? warningWithoutStack$1( - false, - "setNativeProps was called with a ref that isn't a " + - "native component. Use React.forwardRef to get access to the underlying native component" - ) - : void 0; - return; - } - - { - warnForStyleProps(nativeProps, handle.viewConfig.validAttributes); - } - - var updatePayload = create(nativeProps, handle.viewConfig.validAttributes); - // Avoid the overhead of bridge calls if there's no update. - // This is an expensive no-op for Android, and causes an unnecessary - // view invalidation for certain components (eg RCTTextInput) on iOS. - if (updatePayload != null) { - UIManager.updateView( - handle._nativeTag, - handle.viewConfig.uiViewClassName, - updatePayload - ); - } -} - var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function findNodeHandle(componentOrHandle) { @@ -19206,8 +19712,14 @@ var ReactFabric = { findNodeHandle: findNodeHandle, - setNativeProps: setNativeProps, + setNativeProps: function(handle, nativeProps) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + return; + }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index f77404ffb..afbbd4ce6 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -18,30 +18,93 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), - FabricUIManager = require("FabricUIManager"); -var scheduler = require("scheduler"), - ExceptionsManager = require("ExceptionsManager"); -function invariant(condition, format, a, b, c, d, e, f) { - if (!condition) { - condition = void 0; - if (void 0 === format) - condition = Error( - "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." - ); - else { - var args = [a, b, c, d, e, f], - argIndex = 0; - condition = Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - condition.name = "Invariant Violation"; - } - condition.framesToPop = 1; - throw condition; - } + FabricUIManager = require("FabricUIManager"), + Scheduler = require("scheduler"); +var ExceptionsManager = require("ExceptionsManager"); +function ReactError(message) { + message = Error(message); + message.name = "Invariant Violation"; + return message; } +var eventPluginOrder = null, + namesToPlugins = {}; +function recomputePluginOrdering() { + if (eventPluginOrder) + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName], + pluginIndex = eventPluginOrder.indexOf(pluginName); + if (!(-1 < pluginIndex)) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." + ); + if (!plugins[pluginIndex]) { + if (!pluginModule.extractEvents) + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); + plugins[pluginIndex] = pluginModule; + pluginIndex = pluginModule.eventTypes; + for (var eventName in pluginIndex) { + var JSCompiler_inline_result = void 0; + var dispatchConfig = pluginIndex[eventName], + pluginModule$jscomp$0 = pluginModule, + eventName$jscomp$0 = eventName; + if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName$jscomp$0 + + "`." + ); + eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + if (phasedRegistrationNames) { + for (JSCompiler_inline_result in phasedRegistrationNames) + phasedRegistrationNames.hasOwnProperty( + JSCompiler_inline_result + ) && + publishRegistrationName( + phasedRegistrationNames[JSCompiler_inline_result], + pluginModule$jscomp$0, + eventName$jscomp$0 + ); + JSCompiler_inline_result = !0; + } else + dispatchConfig.registrationName + ? (publishRegistrationName( + dispatchConfig.registrationName, + pluginModule$jscomp$0, + eventName$jscomp$0 + ), + (JSCompiler_inline_result = !0)) + : (JSCompiler_inline_result = !1); + if (!JSCompiler_inline_result) + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); + } + } + } +} +function publishRegistrationName(registrationName, pluginModule) { + if (registrationNameModules[registrationName]) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); + registrationNameModules[registrationName] = pluginModule; +} +var plugins = [], + eventNameDispatchConfigs = {}, + registrationNameModules = {}; function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -83,88 +146,13 @@ function invokeGuardedCallbackAndCatchFirstError( hasError = !1; caughtError = null; } else - invariant( - !1, + throw ReactError( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ), - (error = void 0); + ); hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); } } -var eventPluginOrder = null, - namesToPlugins = {}; -function recomputePluginOrdering() { - if (eventPluginOrder) - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName], - pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - -1 < pluginIndex, - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.", - pluginName - ); - if (!plugins[pluginIndex]) { - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.", - pluginName - ); - plugins[pluginIndex] = pluginModule; - pluginIndex = pluginModule.eventTypes; - for (var eventName in pluginIndex) { - var JSCompiler_inline_result = void 0; - var dispatchConfig = pluginIndex[eventName], - pluginModule$jscomp$0 = pluginModule, - eventName$jscomp$0 = eventName; - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0), - "EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.", - eventName$jscomp$0 - ); - eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - if (phasedRegistrationNames) { - for (JSCompiler_inline_result in phasedRegistrationNames) - phasedRegistrationNames.hasOwnProperty( - JSCompiler_inline_result - ) && - publishRegistrationName( - phasedRegistrationNames[JSCompiler_inline_result], - pluginModule$jscomp$0, - eventName$jscomp$0 - ); - JSCompiler_inline_result = !0; - } else - dispatchConfig.registrationName - ? (publishRegistrationName( - dispatchConfig.registrationName, - pluginModule$jscomp$0, - eventName$jscomp$0 - ), - (JSCompiler_inline_result = !0)) - : (JSCompiler_inline_result = !1); - invariant( - JSCompiler_inline_result, - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); - } - } - } -} -function publishRegistrationName(registrationName, pluginModule) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.", - registrationName - ); - registrationNameModules[registrationName] = pluginModule; -} -var plugins = [], - eventNameDispatchConfigs = {}, - registrationNameModules = {}, - getFiberCurrentPropsFromNode = null, +var getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; function executeDispatch(event, listener, inst) { @@ -176,10 +164,8 @@ function executeDispatch(event, listener, inst) { function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + if (Array.isArray(dispatchListener)) + throw ReactError("executeDirectDispatch(...): Invalid `event`."); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -190,10 +176,10 @@ function executeDirectDispatch(event) { return dispatchListener; } function accumulateInto(current, next) { - invariant( - null != next, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); if (null == current) return next; if (Array.isArray(current)) { if (Array.isArray(next)) return current.push.apply(current, next), current; @@ -227,10 +213,10 @@ function executeDispatchesAndReleaseTopLevel(e) { } var injection = { injectEventPluginOrder: function(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." - ); + if (eventPluginOrder) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); recomputePluginOrdering(); }, @@ -240,15 +226,19 @@ var injection = { for (pluginName in injectedNamesToPlugins) if (injectedNamesToPlugins.hasOwnProperty(pluginName)) { var pluginModule = injectedNamesToPlugins[pluginName]; - (namesToPlugins.hasOwnProperty(pluginName) && - namesToPlugins[pluginName] === pluginModule) || - (invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.", - pluginName - ), - (namesToPlugins[pluginName] = pluginModule), - (isOrderingDirty = !0)); + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + if (namesToPlugins[pluginName]) + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = !0; + } } isOrderingDirty && recomputePluginOrdering(); } @@ -284,12 +274,14 @@ function getListener(inst, registrationName) { inst = !1; } if (inst) return null; - invariant( - !listener || "function" === typeof listener, - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + if (listener && "function" !== typeof listener) + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); return listener; } function getParent(inst) { @@ -450,10 +442,10 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { return new this(dispatchConfig, targetInst, nativeEvent, nativeInst); } function releasePooledEvent(event) { - invariant( - event instanceof this, - "Trying to release an event instance into a pool of a different type." - ); + if (!(event instanceof this)) + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); event.destructor(); 10 > this.eventPool.length && this.eventPool.push(event); } @@ -488,7 +480,7 @@ function timestampForTouch(touch) { } function getTouchIdentifier(_ref) { _ref = _ref.identifier; - invariant(null != _ref, "Touch object is missing identifier."); + if (null == _ref) throw ReactError("Touch object is missing identifier."); return _ref; } function recordTouchStart(touch) { @@ -601,10 +593,10 @@ var ResponderTouchHistoryStore = { touchHistory: touchHistory }; function accumulate(current, next) { - invariant( - null != next, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulate(...): Accumulated items must not be null or undefined." + ); return null == current ? next : Array.isArray(current) @@ -969,11 +961,10 @@ var eventTypes$1 = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + if (!bubbleDispatchConfig && !directDispatchConfig) + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); topLevelType = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -1005,7 +996,7 @@ getFiberCurrentPropsFromNode = function(inst) { getInstanceFromNode = getInstanceFromInstance; getNodeFromInstance = function(inst) { inst = inst.stateNode.canonical._nativeTag; - invariant(inst, "All native instances should have a tag."); + if (!inst) throw ReactError("All native instances should have a tag."); return inst; }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ @@ -1036,8 +1027,11 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, - MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; +hasSymbol && Symbol.for("react.event_component"); +hasSymbol && Symbol.for("react.event_target"); +hasSymbol && Symbol.for("react.event_target.touch_hit"); +var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1095,80 +1089,83 @@ function isFiberMountedImpl(fiber) { return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { - invariant( - 2 === isFiberMountedImpl(fiber), - "Unable to find node on an unmounted component." - ); + if (2 !== isFiberMountedImpl(fiber)) + throw ReactError("Unable to find node on an unmounted component."); } function findCurrentFiberUsingSlowPath(fiber) { var alternate = fiber.alternate; - if (!alternate) - return ( - (alternate = isFiberMountedImpl(fiber)), - invariant( - 3 !== alternate, - "Unable to find node on an unmounted component." - ), - 1 === alternate ? null : fiber - ); + if (!alternate) { + alternate = isFiberMountedImpl(fiber); + if (3 === alternate) + throw ReactError("Unable to find node on an unmounted component."); + return 1 === alternate ? null : fiber; + } for (var a = fiber, b = alternate; ; ) { - var parentA = a.return, - parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) break; - if (parentA.child === parentB.child) { - for (var child = parentA.child; child; ) { - if (child === a) return assertIsMounted(parentA), fiber; - if (child === b) return assertIsMounted(parentA), alternate; - child = child.sibling; + var parentA = a.return; + if (null === parentA) break; + var parentB = parentA.alternate; + if (null === parentB) { + b = parentA.return; + if (null !== b) { + a = b; + continue; } - invariant(!1, "Unable to find node on an unmounted component."); + break; + } + if (parentA.child === parentB.child) { + for (parentB = parentA.child; parentB; ) { + if (parentB === a) return assertIsMounted(parentA), fiber; + if (parentB === b) return assertIsMounted(parentA), alternate; + parentB = parentB.sibling; + } + throw ReactError("Unable to find node on an unmounted component."); } if (a.return !== b.return) (a = parentA), (b = parentB); else { - child = !1; - for (var _child = parentA.child; _child; ) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentA; b = parentB; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentA; a = parentB; break; } _child = _child.sibling; } - if (!child) { + if (!didFindChild) { for (_child = parentB.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentB; b = parentA; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentB; a = parentA; break; } _child = _child.sibling; } - invariant( - child, - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." - ); + if (!didFindChild) + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." - ); + if (a.alternate !== b) + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + if (3 !== a.tag) + throw ReactError("Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { @@ -1416,37 +1413,13 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } -var now$1 = - "object" === typeof performance && "function" === typeof performance.now - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }, - scheduledCallback = null, - frameDeadline = 0; -function setTimeoutCallback() { - frameDeadline = now$1() + 5; - var callback = scheduledCallback; - scheduledCallback = null; - null !== callback && callback(); -} -function scheduleDeferredCallback$1(callback) { - scheduledCallback = callback; - return setTimeout(setTimeoutCallback, 1); -} var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { - if ((target = getInstanceFromNode(target))) { - invariant( - !1, + if (getInstanceFromNode(target)) + throw ReactError( "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." ); - var props = getFiberCurrentPropsFromNode(target.stateNode); - null(target.stateNode, target.type, props); - } } function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); @@ -1491,24 +1464,22 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - if ( - events && - (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ), - hasRethrowError) - ) - throw ((events = rethrowError), - (hasRethrowError = !1), - (rethrowError = null), - events); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasRethrowError) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); + } }); } function shim$1() { - invariant( - !1, + throw ReactError( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } @@ -1516,12 +1487,18 @@ var nextReactTag = 2; FabricUIManager.registerEventHandler && FabricUIManager.registerEventHandler(dispatchEvent); var ReactFabricHostComponent = (function() { - function ReactFabricHostComponent(tag, viewConfig, props) { + function ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ) { if (!(this instanceof ReactFabricHostComponent)) throw new TypeError("Cannot call a class as a function"); this._nativeTag = tag; this.viewConfig = viewConfig; this.currentProps = props; + this._internalInstanceHandle = internalInstanceHandle; } ReactFabricHostComponent.prototype.blur = function() { TextInputState.blurTextInput(this._nativeTag); @@ -1530,14 +1507,14 @@ var ReactFabricHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; ReactFabricHostComponent.prototype.measure = function(callback) { - UIManager.measure( - this._nativeTag, + FabricUIManager.measure( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactFabricHostComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - this._nativeTag, + FabricUIManager.measureInWindow( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -1546,27 +1523,16 @@ var ReactFabricHostComponent = (function() { onSuccess, onFail ) { - UIManager.measureLayout( - this._nativeTag, - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; - ReactFabricHostComponent.prototype.setNativeProps = function(nativeProps) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes - ); - null != nativeProps && - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps + "number" !== typeof relativeToNativeNode && + relativeToNativeNode instanceof ReactFabricHostComponent && + FabricUIManager.measureLayout( + this._internalInstanceHandle.stateNode.node, + relativeToNativeNode._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; + ReactFabricHostComponent.prototype.setNativeProps = function() {}; return ReactFabricHostComponent; })(); function createTextInstance( @@ -1575,10 +1541,10 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - invariant( - hostContext.isInAParentText, - "Text strings must be rendered within a component." - ); + if (!hostContext.isInAParentText) + throw ReactError( + "Text strings must be rendered within a component." + ); hostContext = nextReactTag; nextReactTag += 2; return { @@ -1606,18 +1572,6 @@ function cloneHiddenInstance(instance) { canonical: instance.canonical }; } -function cloneUnhiddenInstance(instance, type, props) { - var viewConfig = instance.canonical.viewConfig; - type = instance.node; - var prevProps = Object.assign({}, props, { - style: [props.style, { display: "none" }] - }); - props = diffProperties(null, prevProps, props, viewConfig.validAttributes); - return { - node: FabricUIManager.cloneNodeWithNewProps(type, props), - canonical: instance.canonical - }; -} var BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; @@ -1702,10 +1656,10 @@ function popTopLevelContextObject(fiber) { pop(contextStackCursor, fiber); } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." - ); + if (contextStackCursor.current !== emptyContextObject) + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } @@ -1715,12 +1669,13 @@ function processChildContext(fiber, type, parentContext) { if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) - invariant( - contextKey in fiber, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + if (!(contextKey in fiber)) + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { @@ -1739,10 +1694,10 @@ function pushContextProvider(workInProgress) { } function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." - ); + if (!instance) + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); didChange ? ((type = processChildContext(workInProgress, type, previousContext)), (instance.__reactInternalMemoizedMergedChildContext = type), @@ -1776,6 +1731,122 @@ function injectInternals(internals) { } catch (err) {} return !0; } +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, + Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, + Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, + Scheduler_now = Scheduler.unstable_now, + Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel, + Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, + Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, + Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, + Scheduler_LowPriority = Scheduler.unstable_LowPriority, + Scheduler_IdlePriority = Scheduler.unstable_IdlePriority, + fakeCallbackNode = {}, + shouldYield = Scheduler.unstable_shouldYield, + immediateQueue = null, + immediateQueueCallbackNode = null, + isFlushingImmediate = !1, + initialTimeMs = Scheduler_now(), + now = + 1e4 > initialTimeMs + ? Scheduler_now + : function() { + return Scheduler_now() - initialTimeMs; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return 99; + case Scheduler_UserBlockingPriority: + return 98; + case Scheduler_NormalPriority: + return 97; + case Scheduler_LowPriority: + return 96; + case Scheduler_IdlePriority: + return 95; + default: + throw ReactError("Unknown priority level."); + } +} +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case 99: + return Scheduler_ImmediatePriority; + case 98: + return Scheduler_UserBlockingPriority; + case 97: + return Scheduler_NormalPriority; + case 96: + return Scheduler_LowPriority; + case 95: + return Scheduler_IdlePriority; + default: + throw ReactError("Unknown priority level."); + } +} +function runWithPriority(reactPriorityLevel, fn) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(reactPriorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + if (99 === reactPriorityLevel) + return ( + null === immediateQueue + ? ((immediateQueue = [callback]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueueImpl + ))) + : immediateQueue.push(callback), + fakeCallbackNode + ); + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); +} +function flushImmediateQueue() { + null !== immediateQueueCallbackNode && + Scheduler_cancelCallback(immediateQueueCallbackNode); + flushImmediateQueueImpl(); +} +function flushImmediateQueueImpl() { + if (!isFlushingImmediate && null !== immediateQueue) { + isFlushingImmediate = !0; + var i = 0; + try { + for (; i < immediateQueue.length; i++) { + var callback = immediateQueue[i]; + do callback = callback(!0); + while (null !== callback); + } + immediateQueue = null; + } catch (error) { + throw (null !== immediateQueue && + (immediateQueue = immediateQueue.slice(i + 1)), + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueue + ), + error); + } finally { + isFlushingImmediate = !1; + } + } +} +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (1073741823 === expirationTime) return 99; + if (1 === expirationTime) return 95; + currentTime = + 10 * (1073741822 - expirationTime) - 10 * (1073741822 - currentTime); + return 0 >= currentTime + ? 99 + : 250 >= currentTime + ? 98 + : 5250 >= currentTime + ? 97 + : 95; +} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -1899,11 +1970,10 @@ function createFiberFromTypeAndProps( owner = null; break a; } - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (null == type ? type : typeof type) + + "." ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -1945,94 +2015,17 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } -function markPendingPriorityLevel(root, expirationTime) { - root.didError = !1; - var earliestPendingTime = root.earliestPendingTime; - 0 === earliestPendingTime - ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime < expirationTime - ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime > expirationTime && - (root.latestPendingTime = expirationTime); - findNextExpirationTimeToWorkOn(expirationTime, root); -} -function markCommittedPriorityLevels(root, earliestRemainingTime) { - root.didError = !1; - if (0 === earliestRemainingTime) - (root.earliestPendingTime = 0), - (root.latestPendingTime = 0), - (root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0); - else { - earliestRemainingTime < root.latestPingedTime && - (root.latestPingedTime = 0); - var latestPendingTime = root.latestPendingTime; - 0 !== latestPendingTime && - (latestPendingTime > earliestRemainingTime - ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime > earliestRemainingTime && - (root.earliestPendingTime = root.latestPendingTime)); - latestPendingTime = root.earliestSuspendedTime; - 0 === latestPendingTime - ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime < root.latestSuspendedTime - ? ((root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0), - markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime > latestPendingTime && - markPendingPriorityLevel(root, earliestRemainingTime); - } - findNextExpirationTimeToWorkOn(0, root); -} -function markSuspendedPriorityLevel(root, suspendedTime) { - root.didError = !1; - root.latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); - var earliestPendingTime = root.earliestPendingTime, - latestPendingTime = root.latestPendingTime; - earliestPendingTime === suspendedTime - ? (root.earliestPendingTime = - latestPendingTime === suspendedTime - ? (root.latestPendingTime = 0) - : latestPendingTime) - : latestPendingTime === suspendedTime && - (root.latestPendingTime = earliestPendingTime); - earliestPendingTime = root.earliestSuspendedTime; - latestPendingTime = root.latestSuspendedTime; - 0 === earliestPendingTime - ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : earliestPendingTime < suspendedTime - ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime > suspendedTime && - (root.latestSuspendedTime = suspendedTime); - findNextExpirationTimeToWorkOn(suspendedTime, root); -} -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestPendingTime = root.earliestPendingTime; - root = root.earliestSuspendedTime; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); - return renderExpirationTime; -} -function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { - var earliestSuspendedTime = root.earliestSuspendedTime, - latestSuspendedTime = root.latestSuspendedTime, - earliestPendingTime = root.earliestPendingTime, - latestPingedTime = root.latestPingedTime; - earliestPendingTime = - 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; - 0 === earliestPendingTime && - (0 === completedExpirationTime || - latestSuspendedTime < completedExpirationTime) && - (earliestPendingTime = latestSuspendedTime); - completedExpirationTime = earliestPendingTime; - 0 !== completedExpirationTime && - earliestSuspendedTime > completedExpirationTime && - (completedExpirationTime = earliestSuspendedTime); - root.nextExpirationTimeToWorkOn = earliestPendingTime; - root.expirationTime = completedExpirationTime; +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pingCache = this.pendingChildren = null; + this.pendingCommitExpirationTime = 0; + this.finishedWork = null; + this.timeoutHandle = -1; + this.pendingContext = this.context = null; + this.hydrate = hydrate; + this.callbackNode = this.firstBatch = null; + this.pingTime = this.lastPendingTime = this.firstPendingTime = this.callbackExpirationTime = 0; } function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); @@ -2103,6 +2096,285 @@ function readLazyComponentType(lazyComponent) { throw result; } } +var valueCursor = { current: null }, + currentlyRenderingFiber = null, + lastContextDependency = null, + lastContextWithAllBitsObserved = null; +function resetContextDependences() { + lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; +} +function pushProvider(providerFiber, nextValue) { + var context = providerFiber.type._context; + push(valueCursor, context._currentValue2, providerFiber); + context._currentValue2 = nextValue; +} +function popProvider(providerFiber) { + var currentValue = valueCursor.current; + pop(valueCursor, providerFiber); + providerFiber.type._context._currentValue2 = currentValue; +} +function prepareToReadContext(workInProgress, renderExpirationTime) { + currentlyRenderingFiber = workInProgress; + lastContextWithAllBitsObserved = lastContextDependency = null; + var currentDependencies = workInProgress.contextDependencies; + null !== currentDependencies && + currentDependencies.expirationTime >= renderExpirationTime && + (didReceiveUpdate = !0); + workInProgress.contextDependencies = null; +} +function readContext(context, observedBits) { + if ( + lastContextWithAllBitsObserved !== context && + !1 !== observedBits && + 0 !== observedBits + ) { + if ("number" !== typeof observedBits || 1073741823 === observedBits) + (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); + observedBits = { context: context, observedBits: observedBits, next: null }; + if (null === lastContextDependency) { + if (null === currentlyRenderingFiber) + throw ReactError( + "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()." + ); + lastContextDependency = observedBits; + currentlyRenderingFiber.contextDependencies = { + first: observedBits, + expirationTime: 0 + }; + } else lastContextDependency = lastContextDependency.next = observedBits; + } + return context._currentValue2; +} +var hasForceUpdate = !1; +function createUpdateQueue(baseState) { + return { + baseState: baseState, + firstUpdate: null, + lastUpdate: null, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; +} +function cloneUpdateQueue(currentQueue) { + return { + baseState: currentQueue.baseState, + firstUpdate: currentQueue.firstUpdate, + lastUpdate: currentQueue.lastUpdate, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; +} +function createUpdate(expirationTime) { + return { + expirationTime: expirationTime, + tag: 0, + payload: null, + callback: null, + next: null, + nextEffect: null + }; +} +function appendUpdateToQueue(queue, update) { + null === queue.lastUpdate + ? (queue.firstUpdate = queue.lastUpdate = update) + : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); +} +function enqueueUpdate(fiber, update) { + var alternate = fiber.alternate; + if (null === alternate) { + var queue1 = fiber.updateQueue; + var queue2 = null; + null === queue1 && + (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); + } else + (queue1 = fiber.updateQueue), + (queue2 = alternate.updateQueue), + null === queue1 + ? null === queue2 + ? ((queue1 = fiber.updateQueue = createUpdateQueue( + fiber.memoizedState + )), + (queue2 = alternate.updateQueue = createUpdateQueue( + alternate.memoizedState + ))) + : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) + : null === queue2 && + (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); + null === queue2 || queue1 === queue2 + ? appendUpdateToQueue(queue1, update) + : null === queue1.lastUpdate || null === queue2.lastUpdate + ? (appendUpdateToQueue(queue1, update), + appendUpdateToQueue(queue2, update)) + : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); +} +function enqueueCapturedUpdate(workInProgress, update) { + var workInProgressQueue = workInProgress.updateQueue; + workInProgressQueue = + null === workInProgressQueue + ? (workInProgress.updateQueue = createUpdateQueue( + workInProgress.memoizedState + )) + : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); + null === workInProgressQueue.lastCapturedUpdate + ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) + : ((workInProgressQueue.lastCapturedUpdate.next = update), + (workInProgressQueue.lastCapturedUpdate = update)); +} +function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { + var current = workInProgress.alternate; + null !== current && + queue === current.updateQueue && + (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); + return queue; +} +function getStateFromUpdate( + workInProgress, + queue, + update, + prevState, + nextProps, + instance +) { + switch (update.tag) { + case 1: + return ( + (workInProgress = update.payload), + "function" === typeof workInProgress + ? workInProgress.call(instance, prevState, nextProps) + : workInProgress + ); + case 3: + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; + case 0: + workInProgress = update.payload; + nextProps = + "function" === typeof workInProgress + ? workInProgress.call(instance, prevState, nextProps) + : workInProgress; + if (null === nextProps || void 0 === nextProps) break; + return Object.assign({}, prevState, nextProps); + case 2: + hasForceUpdate = !0; + } + return prevState; +} +function processUpdateQueue( + workInProgress, + queue, + props, + instance, + renderExpirationTime +) { + hasForceUpdate = !1; + queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); + for ( + var newBaseState = queue.baseState, + newFirstUpdate = null, + newExpirationTime = 0, + update = queue.firstUpdate, + resultState = newBaseState; + null !== update; + + ) { + var updateExpirationTime = update.expirationTime; + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && + ((newFirstUpdate = update), (newBaseState = resultState)), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : (updateExpirationTime < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = updateExpirationTime), + (resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), + null !== update.callback && + ((workInProgress.effectTag |= 32), + (update.nextEffect = null), + null === queue.lastEffect + ? (queue.firstEffect = queue.lastEffect = update) + : ((queue.lastEffect.nextEffect = update), + (queue.lastEffect = update)))); + update = update.next; + } + updateExpirationTime = null; + for (update = queue.firstCapturedUpdate; null !== update; ) { + var _updateExpirationTime = update.expirationTime; + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && + ((updateExpirationTime = update), + null === newFirstUpdate && (newBaseState = resultState)), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), + null !== update.callback && + ((workInProgress.effectTag |= 32), + (update.nextEffect = null), + null === queue.lastCapturedEffect + ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) + : ((queue.lastCapturedEffect.nextEffect = update), + (queue.lastCapturedEffect = update)))); + update = update.next; + } + null === newFirstUpdate && (queue.lastUpdate = null); + null === updateExpirationTime + ? (queue.lastCapturedUpdate = null) + : (workInProgress.effectTag |= 32); + null === newFirstUpdate && + null === updateExpirationTime && + (newBaseState = resultState); + queue.baseState = newBaseState; + queue.firstUpdate = newFirstUpdate; + queue.firstCapturedUpdate = updateExpirationTime; + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = resultState; +} +function commitUpdateQueue(finishedWork, finishedQueue, instance) { + null !== finishedQueue.firstCapturedUpdate && + (null !== finishedQueue.lastUpdate && + ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), + (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), + (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} +function commitUpdateEffects(effect, instance) { + for (; null !== effect; ) { + var _callback3 = effect.callback; + if (null !== _callback3) { + effect.callback = null; + var context = instance; + if ("function" !== typeof _callback3) + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + _callback3 + ); + _callback3.call(context); + } + effect = effect.nextEffect; + } +} var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, @@ -2137,30 +2409,30 @@ var classComponentUpdater = { void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternalFiber; var currentTime = requestCurrentTime(); currentTime = computeExpirationForFiber(currentTime, inst); var update = createUpdate(currentTime); - update.tag = ReplaceState; + update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternalFiber; var currentTime = requestCurrentTime(); currentTime = computeExpirationForFiber(currentTime, inst); var update = createUpdate(currentTime); - update.tag = ForceUpdate; + update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2285,17 +2557,19 @@ function coerceRef(returnFiber, current$$1, element) { if (element._owner) { element = element._owner; var inst = void 0; - element && - (invariant( - 1 === element.tag, - "Function components cannot have refs. Did you mean to use React.forwardRef()?" - ), - (inst = element.stateNode)); - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.", - returnFiber - ); + if (element) { + if (1 !== element.tag) + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + inst = element.stateNode; + } + if (!inst) + throw ReactError( + "Missing owner for string ref " + + returnFiber + + ". This error is likely caused by a bug in React. Please file an issue." + ); var stringRef = "" + returnFiber; if ( null !== current$$1 && @@ -2312,27 +2586,27 @@ function coerceRef(returnFiber, current$$1, element) { current$$1._stringRef = stringRef; return current$$1; } - invariant( - "string" === typeof returnFiber, - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) 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://fb.me/react-refs-must-have-owner for more information.", - returnFiber - ); + if ("string" !== typeof returnFiber) + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + if (!element._owner) + throw ReactError( + "Element ref was specified as a string (" + + returnFiber + + ") 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://fb.me/react-refs-must-have-owner for more information." + ); } return returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { - "textarea" !== returnFiber.type && - invariant( - !1, - "Objects are not valid as a React child (found: %s).%s", - "[object Object]" === Object.prototype.toString.call(newChild) - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - "" + if ("textarea" !== returnFiber.type) + throw ReactError( + "Objects are not valid as a React child (found: " + + ("[object Object]" === Object.prototype.toString.call(newChild) + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2676,18 +2950,21 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - if ( - (oldFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - )) - ) - (currentFirstChild = placeChild(oldFiber, currentFirstChild, newIdx)), + (oldFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + )), + null !== oldFiber && + ((currentFirstChild = placeChild( + oldFiber, + currentFirstChild, + newIdx + )), null === previousNewFiber ? (resultingFirstChild = oldFiber) : (previousNewFiber.sibling = oldFiber), - (previousNewFiber = oldFiber); + (previousNewFiber = oldFiber)); return resultingFirstChild; } for ( @@ -2695,20 +2972,19 @@ function ChildReconciler(shouldTrackSideEffects) { newIdx < newChildren.length; newIdx++ ) - if ( - (nextOldFiber = updateFromMap( - oldFiber, - returnFiber, - newIdx, - newChildren[newIdx], - expirationTime - )) - ) - shouldTrackSideEffects && - null !== nextOldFiber.alternate && - oldFiber.delete( - null === nextOldFiber.key ? newIdx : nextOldFiber.key - ), + (nextOldFiber = updateFromMap( + oldFiber, + returnFiber, + newIdx, + newChildren[newIdx], + expirationTime + )), + null !== nextOldFiber && + (shouldTrackSideEffects && + null !== nextOldFiber.alternate && + oldFiber.delete( + null === nextOldFiber.key ? newIdx : nextOldFiber.key + ), (currentFirstChild = placeChild( nextOldFiber, currentFirstChild, @@ -2717,7 +2993,7 @@ function ChildReconciler(shouldTrackSideEffects) { null === previousNewFiber ? (resultingFirstChild = nextOldFiber) : (previousNewFiber.sibling = nextOldFiber), - (previousNewFiber = nextOldFiber); + (previousNewFiber = nextOldFiber)); shouldTrackSideEffects && oldFiber.forEach(function(child) { return deleteChild(returnFiber, child); @@ -2731,15 +3007,13 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - "function" === typeof iteratorFn, - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." - ); + if ("function" !== typeof iteratorFn) + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); newChildrenIterable = iteratorFn.call(newChildrenIterable); - invariant( - null != newChildrenIterable, - "An iterable object provided no iterator." - ); + if (null == newChildrenIterable) + throw ReactError("An iterable object provided no iterator."); for ( var previousNewFiber = (iteratorFn = null), oldFiber = currentFirstChild, @@ -2759,7 +3033,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ); if (null === newFiber) { - oldFiber || (oldFiber = nextOldFiber); + null === oldFiber && (oldFiber = nextOldFiber); break; } shouldTrackSideEffects && @@ -2831,7 +3105,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) + if (isUnkeyedTopLevelFragment.key === isObject) { if ( 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE @@ -2856,14 +3130,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -2899,7 +3169,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== currentFirstChild; ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + if (currentFirstChild.key === isUnkeyedTopLevelFragment) { if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -2919,11 +3189,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren(returnFiber, currentFirstChild); - break; } - else deleteChild(returnFiber, currentFirstChild); + deleteRemainingChildren(returnFiber, currentFirstChild); + break; + } else deleteChild(returnFiber, currentFirstChild); currentFirstChild = currentFirstChild.sibling; } currentFirstChild = createFiberFromPortal( @@ -2977,12 +3246,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (returnFiber.tag) { case 1: case 0: - (expirationTime = returnFiber.type), - invariant( - !1, - "%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.", - expirationTime.displayName || expirationTime.name || "Component" - ); + throw ((returnFiber = returnFiber.type), + ReactError( + (returnFiber.displayName || returnFiber.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + )); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -2994,10 +3262,10 @@ var reconcileChildFibers = ChildReconciler(!0), contextFiberStackCursor = { current: NO_CONTEXT }, rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." - ); + if (c === NO_CONTEXT) + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); return c; } function pushHostContainer(fiber, nextRootInstance) { @@ -3043,7 +3311,7 @@ var NoEffect$1 = 0, MountPassive = 64, UnmountPassive = 128, ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, - renderExpirationTime = 0, + renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, nextCurrentHook = null, @@ -3057,9 +3325,8 @@ var NoEffect$1 = 0, renderPhaseUpdates = null, numberOfReRenders = 0; function throwInvalidHookError() { - invariant( - !1, - "Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)" + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3076,7 +3343,7 @@ function renderWithHooks( refOrContext, nextRenderExpirationTime ) { - renderExpirationTime = nextRenderExpirationTime; + renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; nextCurrentHook = null !== current ? current.memoizedState : null; ReactCurrentDispatcher$1.current = @@ -3102,20 +3369,20 @@ function renderWithHooks( current.updateQueue = componentUpdateQueue; current.effectTag |= sideEffectTag; current = null !== currentHook && null !== currentHook.next; - renderExpirationTime = 0; + renderExpirationTime$1 = 0; nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; remainingExpirationTime = 0; componentUpdateQueue = null; sideEffectTag = 0; - invariant( - !current, - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." - ); + if (current) + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); return workInProgress; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - renderExpirationTime = 0; + renderExpirationTime$1 = 0; nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; remainingExpirationTime = 0; componentUpdateQueue = null; @@ -3144,10 +3411,8 @@ function updateWorkInProgressHook() { (currentHook = nextCurrentHook), (nextCurrentHook = null !== currentHook ? currentHook.next : null); else { - invariant( - null !== nextCurrentHook, - "Rendered more hooks than during the previous render." - ); + if (null === nextCurrentHook) + throw ReactError("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; var newHook = { memoizedState: currentHook.memoizedState, @@ -3170,10 +3435,11 @@ function basicStateReducer(state, action) { function updateReducer(reducer) { var hook = updateWorkInProgressHook(), queue = hook.queue; - invariant( - null !== queue, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + if (null === queue) + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + queue.lastRenderedReducer = reducer; if (0 < numberOfReRenders) { var _dispatch = queue.dispatch; if (null !== renderPhaseUpdates) { @@ -3188,8 +3454,7 @@ function updateReducer(reducer) { is(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; hook.baseUpdate === queue.last && (hook.baseState = newState); - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; return [newState, _dispatch]; } } @@ -3208,17 +3473,19 @@ function updateReducer(reducer) { didSkip = !1; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime + updateExpirationTime < renderExpirationTime$1 ? (didSkip || ((didSkip = !0), (newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)), updateExpirationTime > remainingExpirationTime && (remainingExpirationTime = updateExpirationTime)) - : (newState = + : (updateExpirationTime < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = updateExpirationTime), + (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action)); + : reducer(newState, _update.action))); baseUpdate = _update; _update = _update.next; } while (null !== _update && _update !== _dispatch); @@ -3228,8 +3495,7 @@ function updateReducer(reducer) { hook.memoizedState = newState; hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; } @@ -3292,10 +3558,10 @@ function imperativeHandleEffect(create, ref) { } function mountDebugValue() {} function dispatchAction(fiber, queue, action) { - invariant( - 25 > numberOfReRenders, - "Too many re-renders. React limits the number of renders to prevent an infinite loop." - ); + if (!(25 > numberOfReRenders)) + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); var alternate = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3304,7 +3570,7 @@ function dispatchAction(fiber, queue, action) { if ( ((didScheduleRenderPhaseUpdate = !0), (fiber = { - expirationTime: renderExpirationTime, + expirationTime: renderExpirationTime$1, action: action, eagerReducer: null, eagerState: null, @@ -3341,10 +3607,10 @@ function dispatchAction(fiber, queue, action) { if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && - ((alternate = queue.eagerReducer), null !== alternate) + ((alternate = queue.lastRenderedReducer), null !== alternate) ) try { - var currentState = queue.eagerState, + var currentState = queue.lastRenderedState, _eagerState = alternate(currentState, action); _update2.eagerReducer = alternate; _update2.eagerState = _eagerState; @@ -3352,7 +3618,7 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleUpdateOnFiber(fiber, currentTime); } } var ContextOnlyDispatcher = { @@ -3407,8 +3673,8 @@ var ContextOnlyDispatcher = { reducer = hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialArg + lastRenderedReducer: reducer, + lastRenderedState: initialArg }; reducer = reducer.dispatch = dispatchAction.bind( null, @@ -3429,8 +3695,8 @@ var ContextOnlyDispatcher = { initialState = hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }; initialState = initialState.dispatch = dispatchAction.bind( null, @@ -4046,7 +4312,10 @@ function updateSuspenseComponent( nextState = null; var nextDidTimeout = !1; } else - (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextState = { + fallbackExpirationTime: + null !== nextState ? nextState.fallbackExpirationTime : 0 + }), (nextDidTimeout = !0), (workInProgress.effectTag &= -65); if (null === current$$1) @@ -4141,10 +4410,8 @@ function bailoutOnAlreadyFinishedWork( null !== current$$1 && (workInProgress.contextDependencies = current$$1.contextDependencies); if (workInProgress.childExpirationTime < renderExpirationTime) return null; - invariant( - null === current$$1 || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + if (null !== current$$1 && workInProgress.child !== current$$1.child) + throw ReactError("Resuming work not yet implemented."); if (null !== workInProgress.child) { current$$1 = workInProgress.child; renderExpirationTime = createWorkInProgress( @@ -4169,7 +4436,1579 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime) { +var appendAllChildren = void 0, + updateHostContainer = void 0, + updateHostComponent$1 = void 0, + updateHostText$1 = void 0; +appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden +) { + for (var node = workInProgress.child; null !== node; ) { + if (5 === node.tag) { + var instance = node.stateNode; + needsVisibilityToggle && + isHidden && + (instance = cloneHiddenInstance( + instance, + node.type, + node.memoizedProps, + node + )); + FabricUIManager.appendChild(parent.node, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle && isHidden) + throw Error("Not yet implemented."); + FabricUIManager.appendChild(parent.node, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + 0 !== (node.effectTag & 4) && + (instance = null !== node.memoizedState) + ) { + var primaryChildParent = node.child; + if ( + null !== primaryChildParent && + (null !== primaryChildParent.child && + ((primaryChildParent.child.return = primaryChildParent), + appendAllChildren(parent, primaryChildParent, !0, instance)), + (instance = primaryChildParent.sibling), + null !== instance) + ) { + instance.return = node; + node = instance; + continue; + } + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +}; +function appendAllChildrenToContainer( + containerChildSet, + workInProgress, + needsVisibilityToggle, + isHidden +) { + for (var node = workInProgress.child; null !== node; ) { + if (5 === node.tag) { + var instance = node.stateNode; + needsVisibilityToggle && + isHidden && + (instance = cloneHiddenInstance( + instance, + node.type, + node.memoizedProps, + node + )); + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle && isHidden) + throw Error("Not yet implemented."); + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + 0 !== (node.effectTag & 4) && + (instance = null !== node.memoizedState) + ) { + var primaryChildParent = node.child; + if ( + null !== primaryChildParent && + (null !== primaryChildParent.child && + ((primaryChildParent.child.return = primaryChildParent), + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + !0, + instance + )), + (instance = primaryChildParent.sibling), + null !== instance) + ) { + instance.return = node; + node = instance; + continue; + } + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +} +updateHostContainer = function(workInProgress) { + var portalOrRoot = workInProgress.stateNode; + if (null !== workInProgress.firstEffect) { + var container = portalOrRoot.containerInfo, + newChildSet = FabricUIManager.createChildSet(container); + appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); + portalOrRoot.pendingChildren = newChildSet; + workInProgress.effectTag |= 4; + FabricUIManager.completeRoot(container, newChildSet); + } +}; +updateHostComponent$1 = function(current, workInProgress, type, newProps) { + type = current.stateNode; + var oldProps = current.memoizedProps; + if ((current = null === workInProgress.firstEffect) && oldProps === newProps) + workInProgress.stateNode = type; + else { + var recyclableInstance = workInProgress.stateNode; + requiredContext(contextStackCursor$1.current); + var updatePayload = null; + oldProps !== newProps && + ((oldProps = diffProperties( + null, + oldProps, + newProps, + recyclableInstance.canonical.viewConfig.validAttributes + )), + (recyclableInstance.canonical.currentProps = newProps), + (updatePayload = oldProps)); + current && null === updatePayload + ? (workInProgress.stateNode = type) + : ((newProps = updatePayload), + (recyclableInstance = type.node), + (type = { + node: current + ? null !== newProps + ? FabricUIManager.cloneNodeWithNewProps( + recyclableInstance, + newProps + ) + : FabricUIManager.cloneNode(recyclableInstance) + : null !== newProps + ? FabricUIManager.cloneNodeWithNewChildrenAndProps( + recyclableInstance, + newProps + ) + : FabricUIManager.cloneNodeWithNewChildren(recyclableInstance), + canonical: type.canonical + }), + (workInProgress.stateNode = type), + current + ? (workInProgress.effectTag |= 4) + : appendAllChildren(type, workInProgress, !1, !1)); + } +}; +updateHostText$1 = function(current, workInProgress, oldText, newText) { + oldText !== newText && + ((current = requiredContext(rootInstanceStackCursor.current)), + (oldText = requiredContext(contextStackCursor$1.current)), + (workInProgress.stateNode = createTextInstance( + newText, + current, + oldText, + workInProgress + )), + (workInProgress.effectTag |= 4)); +}; +function createCapturedValue(value, source) { + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; +} +function logCapturedError(capturedError) { + var componentStack = capturedError.componentStack, + error = capturedError.error; + if (error instanceof Error) { + capturedError = error.message; + var name = error.name; + try { + error.message = + (capturedError ? name + ": " + capturedError : name) + + "\n\nThis error is located at:" + + componentStack; + } catch (e) {} + } else + error = + "string" === typeof error + ? Error(error + "\n\nThis error is located at:" + componentStack) + : Error("Unspecified error at:" + componentStack); + ExceptionsManager.handleException(error, !1); +} +var PossiblyWeakSet$1 = "function" === typeof WeakSet ? WeakSet : Set; +function logError(boundary, errorInfo) { + var source = errorInfo.source, + stack = errorInfo.stack; + null === stack && + null !== source && + (stack = getStackByFiberInDevAndProd(source)); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 1 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); + try { + logCapturedError(errorInfo); + } catch (e) { + setTimeout(function() { + throw e; + }); + } +} +function safelyDetachRef(current$$1) { + var ref = current$$1.ref; + if (null !== ref) + if ("function" === typeof ref) + try { + ref(null); + } catch (refError) { + captureCommitPhaseError(current$$1, refError); + } + else ref.current = null; +} +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & unmountTag) !== NoEffect$1) { + var destroy = effect.destroy; + effect.destroy = void 0; + void 0 !== destroy && destroy(); + } + (effect.tag & mountTag) !== NoEffect$1 && + ((destroy = effect.create), (effect.destroy = destroy())); + effect = effect.next; + } while (effect !== finishedWork); + } +} +function commitWork(current$$1, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 14: + case 15: + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + case 12: + return; + case 13: + commitSuspenseComponent(finishedWork); + return; + } + switch (finishedWork.tag) { + case 1: + case 5: + case 6: + case 20: + case 19: + break; + case 3: + case 4: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } +} +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + null !== newState && + 0 === newState.fallbackExpirationTime && + (newState.fallbackExpirationTime = requestCurrentTime() - 500); + newState = finishedWork.updateQueue; + if (null !== newState) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + null === retryCache && + (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); + newState.forEach(function(thenable) { + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + (retryCache.add(thenable), thenable.then(retry, retry)); + }); + } +} +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime); + expirationTime.tag = 3; + expirationTime.payload = { element: null }; + var error = errorInfo.value; + expirationTime.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logError(fiber, errorInfo); + }; + return expirationTime; +} +function createClassErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime); + expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error$jscomp$0 = errorInfo.value; + expirationTime.payload = function() { + return getDerivedStateFromError(error$jscomp$0); + }; + } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (expirationTime.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this)); + var error = errorInfo.value, + stack = errorInfo.stack; + logError(fiber, errorInfo); + this.componentDidCatch(error, { + componentStack: null !== stack ? stack : "" + }); + }); + return expirationTime; +} +function unwindWork(workInProgress) { + switch (workInProgress.tag) { + case 1: + isContextProvider(workInProgress.type) && popContext(workInProgress); + var effectTag = workInProgress.effectTag; + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), + workInProgress) + : null; + case 3: + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw ReactError( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + workInProgress.effectTag = (effectTag & -2049) | 64; + return workInProgress; + case 5: + return popHostContext(workInProgress), null; + case 13: + return ( + (effectTag = workInProgress.effectTag), + effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), + workInProgress) + : null + ); + case 18: + return null; + case 4: + return popHostContainer(workInProgress), null; + case 10: + return popProvider(workInProgress), null; + case 19: + case 20: + return null; + default: + return null; + } +} +var ceil = Math.ceil, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, + LegacyUnbatchedPhase = 2, + RenderPhase = 4, + CommitPhase = 5, + RootIncomplete = 0, + RootErrored = 1, + RootSuspended = 2, + RootCompleted = 3, + workPhase = 0, + workInProgressRoot = null, + workInProgress = null, + renderExpirationTime = 0, + workInProgressRootExitStatus = RootIncomplete, + workInProgressRootMostRecentEventTime = 1073741823, + nextEffect = null, + hasUncaughtError = !1, + firstUncaughtError = null, + legacyErrorBoundariesThatAlreadyFailed = null, + rootDoesHavePassiveEffects = !1, + rootWithPendingPassiveEffects = null, + rootsWithPendingDiscreteUpdates = null, + nestedUpdateCount = 0, + rootWithNestedUpdates = null, + currentEventTime = 0; +function requestCurrentTime() { + return workPhase === RenderPhase || workPhase === CommitPhase + ? 1073741822 - ((now() / 10) | 0) + : 0 !== currentEventTime + ? currentEventTime + : (currentEventTime = 1073741822 - ((now() / 10) | 0)); +} +function computeExpirationForFiber(currentTime, fiber) { + if (0 === (fiber.mode & 1)) return 1073741823; + if (workPhase === RenderPhase) return renderExpirationTime; + switch (getCurrentPriorityLevel()) { + case 99: + currentTime = 1073741823; + break; + case 98: + currentTime = + 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); + break; + case 97: + case 96: + currentTime = + 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); + break; + case 95: + currentTime = 1; + break; + default: + throw ReactError("Expected a valid priority level"); + } + null !== workInProgressRoot && + currentTime === renderExpirationTime && + --currentTime; + return currentTime; +} +function scheduleUpdateOnFiber(fiber, expirationTime) { + if (50 < nestedUpdateCount) + throw ((nestedUpdateCount = 0), + (rootWithNestedUpdates = null), + ReactError( + "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." + )); + fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (null !== fiber) + if (((fiber.pingTime = 0), 1073741823 === expirationTime)) + if (workPhase === LegacyUnbatchedPhase) + for ( + expirationTime = renderRoot(fiber, 1073741823, !0); + null !== expirationTime; + + ) + expirationTime = expirationTime(!0); + else + scheduleCallbackForRoot(fiber, 99, 1073741823), + 0 === workPhase && flushImmediateQueue(); + else { + var priorityLevel = getCurrentPriorityLevel(); + if (98 === priorityLevel) + if (null === rootsWithPendingDiscreteUpdates) + rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]]); + else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(fiber); + (void 0 === lastDiscreteTime || lastDiscreteTime > expirationTime) && + rootsWithPendingDiscreteUpdates.set(fiber, expirationTime); + } + scheduleCallbackForRoot(fiber, priorityLevel, expirationTime); + } +} +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); + var alternate = fiber.alternate; + null !== alternate && + alternate.expirationTime < expirationTime && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); + null !== alternate && + alternate.childExpirationTime < expirationTime && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 3 === node.tag) { + root = node.stateNode; + break; + } + node = node.return; + } + null !== root && + (expirationTime > root.firstPendingTime && + (root.firstPendingTime = expirationTime), + (fiber = root.lastPendingTime), + 0 === fiber || expirationTime < fiber) && + (root.lastPendingTime = expirationTime); + return root; +} +function scheduleCallbackForRoot(root, priorityLevel, expirationTime) { + if (root.callbackExpirationTime < expirationTime) { + var existingCallbackNode = root.callbackNode; + null !== existingCallbackNode && + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); + root.callbackExpirationTime = expirationTime; + existingCallbackNode = null; + 1073741823 !== expirationTime && + 1 !== expirationTime && + ((existingCallbackNode = 10 * (1073741822 - expirationTime) - now()), + 5e3 < existingCallbackNode && (existingCallbackNode = 5e3), + (existingCallbackNode = { timeout: existingCallbackNode })); + root.callbackNode = scheduleCallback( + priorityLevel, + runRootCallback.bind( + null, + root, + renderRoot.bind(null, root, expirationTime) + ), + existingCallbackNode + ); + } +} +function runRootCallback(root, callback, isSync) { + var prevCallbackNode = root.callbackNode, + continuation = null; + try { + return ( + (continuation = callback(isSync)), + null !== continuation + ? runRootCallback.bind(null, root, continuation) + : null + ); + } finally { + null === continuation && + prevCallbackNode === root.callbackNode && + ((root.callbackNode = null), (root.callbackExpirationTime = 0)); + } +} +function resolveLocksOnRoot(root, expirationTime) { + var firstBatch = root.firstBatch; + return null !== firstBatch && + firstBatch._defer && + firstBatch._expirationTime >= expirationTime + ? ((root.finishedWork = root.current.alternate), + (root.pendingCommitExpirationTime = expirationTime), + scheduleCallback(97, function() { + firstBatch._onComplete(); + return null; + }), + !0) + : !1; +} +function flushPendingDiscreteUpdates() { + if (null !== rootsWithPendingDiscreteUpdates) { + var roots = rootsWithPendingDiscreteUpdates; + rootsWithPendingDiscreteUpdates = null; + roots.forEach(function(expirationTime, root) { + scheduleCallback(99, renderRoot.bind(null, root, expirationTime)); + }); + flushImmediateQueue(); + } +} +function prepareFreshStack(root, expirationTime) { + root.pendingCommitExpirationTime = 0; + var timeoutHandle = root.timeoutHandle; + -1 !== timeoutHandle && + ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); + if (null !== workInProgress) + for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) { + var interruptedWork = timeoutHandle; + switch (interruptedWork.tag) { + case 1: + var childContextTypes = interruptedWork.type.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork); + break; + case 3: + popHostContainer(interruptedWork); + popTopLevelContextObject(interruptedWork); + break; + case 5: + popHostContext(interruptedWork); + break; + case 4: + popHostContainer(interruptedWork); + break; + case 10: + popProvider(interruptedWork); + } + timeoutHandle = timeoutHandle.return; + } + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null, expirationTime); + renderExpirationTime = expirationTime; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootMostRecentEventTime = 1073741823; +} +function renderRoot(root$jscomp$0, expirationTime, isSync) { + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Should not already be working."); + if (root$jscomp$0.firstPendingTime < expirationTime) return null; + if (root$jscomp$0.pendingCommitExpirationTime === expirationTime) + return ( + (root$jscomp$0.pendingCommitExpirationTime = 0), + commitRoot.bind(null, root$jscomp$0, expirationTime) + ); + flushPassiveEffects(); + (root$jscomp$0 === workInProgressRoot && + expirationTime === renderExpirationTime) || + prepareFreshStack(root$jscomp$0, expirationTime); + if (null !== workInProgress) { + var prevWorkPhase = workPhase; + workPhase = RenderPhase; + var prevDispatcher = ReactCurrentDispatcher.current; + null === prevDispatcher && (prevDispatcher = ContextOnlyDispatcher); + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + if (isSync) { + if (1073741823 !== expirationTime) { + var currentTime = requestCurrentTime(); + if (currentTime < expirationTime) + return ( + (workPhase = prevWorkPhase), + resetContextDependences(), + (ReactCurrentDispatcher.current = prevDispatcher), + renderRoot.bind(null, root$jscomp$0, currentTime) + ); + } + } else currentEventTime = 0; + do + try { + if (isSync) + for (; null !== workInProgress; ) + workInProgress = performUnitOfWork(workInProgress); + else + for (; null !== workInProgress && !shouldYield(); ) + workInProgress = performUnitOfWork(workInProgress); + break; + } catch (thrownValue) { + resetContextDependences(); + resetHooks(); + currentTime = workInProgress; + if (null === currentTime || null === currentTime.return) + throw (prepareFreshStack(root$jscomp$0, expirationTime), + (workPhase = prevWorkPhase), + thrownValue); + a: { + var root = root$jscomp$0, + returnFiber = currentTime.return, + sourceFiber = currentTime, + value = thrownValue, + renderExpirationTime$jscomp$0 = renderExpirationTime; + sourceFiber.effectTag |= 1024; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; + if ( + null !== value && + "object" === typeof value && + "function" === typeof value.then + ) { + var thenable = value; + value = returnFiber; + do { + if ( + 13 === value.tag && + (void 0 === value.memoizedProps.fallback + ? 0 + : null === value.memoizedState) + ) { + returnFiber = value.updateQueue; + null === returnFiber + ? ((returnFiber = new Set()), + returnFiber.add(thenable), + (value.updateQueue = returnFiber)) + : returnFiber.add(thenable); + if (0 === (value.mode & 1)) { + value.effectTag |= 64; + sourceFiber.effectTag &= -1957; + 1 === sourceFiber.tag && + (null === sourceFiber.alternate + ? (sourceFiber.tag = 17) + : ((renderExpirationTime$jscomp$0 = createUpdate( + 1073741823 + )), + (renderExpirationTime$jscomp$0.tag = 2), + enqueueUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ))); + sourceFiber.expirationTime = 1073741823; + break a; + } + sourceFiber = root; + root = renderExpirationTime$jscomp$0; + var pingCache = sourceFiber.pingCache; + null === pingCache + ? ((pingCache = sourceFiber.pingCache = new PossiblyWeakMap()), + (returnFiber = new Set()), + pingCache.set(thenable, returnFiber)) + : ((returnFiber = pingCache.get(thenable)), + void 0 === returnFiber && + ((returnFiber = new Set()), + pingCache.set(thenable, returnFiber))); + returnFiber.has(root) || + (returnFiber.add(root), + (sourceFiber = pingSuspendedRoot.bind( + null, + sourceFiber, + thenable, + root + )), + thenable.then(sourceFiber, sourceFiber)); + value.effectTag |= 2048; + value.expirationTime = renderExpirationTime$jscomp$0; + break a; + } + value = value.return; + } while (null !== value); + value = Error( + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) + ); + } + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) + workInProgressRootExitStatus = RootErrored; + value = createCapturedValue(value, sourceFiber); + sourceFiber = returnFiber; + do { + switch (sourceFiber.tag) { + case 3: + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime$jscomp$0; + renderExpirationTime$jscomp$0 = createRootErrorUpdate( + sourceFiber, + value, + renderExpirationTime$jscomp$0 + ); + enqueueCapturedUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ); + break a; + case 1: + if ( + ((thenable = value), + (root = sourceFiber.type), + (returnFiber = sourceFiber.stateNode), + 0 === (sourceFiber.effectTag & 64) && + ("function" === typeof root.getDerivedStateFromError || + (null !== returnFiber && + "function" === typeof returnFiber.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has( + returnFiber + ))))) + ) { + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime$jscomp$0; + renderExpirationTime$jscomp$0 = createClassErrorUpdate( + sourceFiber, + thenable, + renderExpirationTime$jscomp$0 + ); + enqueueCapturedUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ); + break a; + } + } + sourceFiber = sourceFiber.return; + } while (null !== sourceFiber); + } + workInProgress = completeUnitOfWork(currentTime); + } + while (1); + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher.current = prevDispatcher; + if (null !== workInProgress) + return renderRoot.bind(null, root$jscomp$0, expirationTime); + } + if (resolveLocksOnRoot(root$jscomp$0, expirationTime)) return null; + workInProgressRoot = null; + switch (workInProgressRootExitStatus) { + case RootIncomplete: + throw ReactError("Should have a work-in-progress."); + case RootErrored: + return ( + (prevWorkPhase = root$jscomp$0.lastPendingTime), + root$jscomp$0.lastPendingTime < expirationTime + ? renderRoot.bind(null, root$jscomp$0, prevWorkPhase) + : isSync + ? commitRoot.bind(null, root$jscomp$0, expirationTime) + : (prepareFreshStack(root$jscomp$0, expirationTime), + scheduleCallback( + 99, + renderRoot.bind(null, root$jscomp$0, expirationTime) + ), + null) + ); + case RootSuspended: + if (!isSync) { + isSync = root$jscomp$0.lastPendingTime; + if (root$jscomp$0.lastPendingTime < expirationTime) + return renderRoot.bind(null, root$jscomp$0, isSync); + if ( + 1073741823 !== workInProgressRootMostRecentEventTime && + ((prevWorkPhase = + 10 * (1073741822 - workInProgressRootMostRecentEventTime) - 5e3), + (isSync = now()), + (prevWorkPhase = isSync - prevWorkPhase), + (prevWorkPhase = + (120 > prevWorkPhase + ? 120 + : 480 > prevWorkPhase + ? 480 + : 1080 > prevWorkPhase + ? 1080 + : 1920 > prevWorkPhase + ? 1920 + : 3e3 > prevWorkPhase + ? 3e3 + : 4320 > prevWorkPhase + ? 4320 + : 1960 * ceil(prevWorkPhase / 1960)) - prevWorkPhase), + (isSync = 10 * (1073741822 - expirationTime) - isSync), + isSync < prevWorkPhase && (prevWorkPhase = isSync), + (isSync = prevWorkPhase), + 10 < isSync) + ) + return ( + (root$jscomp$0.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root$jscomp$0, expirationTime), + isSync + )), + null + ); + } + return commitRoot.bind(null, root$jscomp$0, expirationTime); + case RootCompleted: + return commitRoot.bind(null, root$jscomp$0, expirationTime); + default: + throw ReactError("Unknown root exit status."); + } +} +function performUnitOfWork(unitOfWork) { + var next = beginWork$$1( + unitOfWork.alternate, + unitOfWork, + renderExpirationTime + ); + unitOfWork.memoizedProps = unitOfWork.pendingProps; + null === next && (next = completeUnitOfWork(unitOfWork)); + ReactCurrentOwner$2.current = null; + return next; +} +function completeUnitOfWork(unitOfWork) { + workInProgress = unitOfWork; + do { + var current$$1 = workInProgress.alternate; + unitOfWork = workInProgress.return; + if (0 === (workInProgress.effectTag & 1024)) { + a: { + var current = current$$1; + current$$1 = workInProgress; + var renderExpirationTime$jscomp$0 = renderExpirationTime, + newProps = current$$1.pendingProps; + switch (current$$1.tag) { + case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 1: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + case 3: + popHostContainer(current$$1); + popTopLevelContextObject(current$$1); + newProps = current$$1.stateNode; + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)); + if (null === current || null === current.child) + current$$1.effectTag &= -3; + updateHostContainer(current$$1); + break; + case 5: + popHostContext(current$$1); + renderExpirationTime$jscomp$0 = requiredContext( + rootInstanceStackCursor.current + ); + var type = current$$1.type; + if (null !== current && null != current$$1.stateNode) + updateHostComponent$1( + current, + current$$1, + type, + newProps, + renderExpirationTime$jscomp$0 + ), + current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + else if (newProps) { + requiredContext(contextStackCursor$1.current); + current = newProps; + var rootContainerInstance = renderExpirationTime$jscomp$0; + newProps = current$$1; + renderExpirationTime$jscomp$0 = nextReactTag; + nextReactTag += 2; + type = ReactNativeViewConfigRegistry.get(type); + var updatePayload = diffProperties( + null, + emptyObject, + current, + type.validAttributes + ); + rootContainerInstance = FabricUIManager.createNode( + renderExpirationTime$jscomp$0, + type.uiViewClassName, + rootContainerInstance, + updatePayload, + newProps + ); + current = new ReactFabricHostComponent( + renderExpirationTime$jscomp$0, + type, + current, + newProps + ); + current = { node: rootContainerInstance, canonical: current }; + appendAllChildren(current, current$$1, !1, !1); + current$$1.stateNode = current; + null !== current$$1.ref && (current$$1.effectTag |= 128); + } else if (null === current$$1.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + if (current && null != current$$1.stateNode) + updateHostText$1( + current, + current$$1, + current.memoizedProps, + newProps + ); + else { + if ("string" !== typeof newProps && null === current$$1.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + current = requiredContext(rootInstanceStackCursor.current); + renderExpirationTime$jscomp$0 = requiredContext( + contextStackCursor$1.current + ); + current$$1.stateNode = createTextInstance( + newProps, + current, + renderExpirationTime$jscomp$0, + current$$1 + ); + } + break; + case 11: + break; + case 13: + newProps = current$$1.memoizedState; + if (0 !== (current$$1.effectTag & 64)) { + current$$1.expirationTime = renderExpirationTime$jscomp$0; + break a; + } + newProps = null !== newProps; + renderExpirationTime$jscomp$0 = !1; + null !== current && + ((type = current.memoizedState), + (renderExpirationTime$jscomp$0 = null !== type), + newProps || + null === type || + ((type = type.fallbackExpirationTime), + type < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = type), + (current = current.child.sibling), + null !== current && + ((type = current$$1.firstEffect), + null !== type + ? ((current$$1.firstEffect = current), + (current.nextEffect = type)) + : ((current$$1.firstEffect = current$$1.lastEffect = current), + (current.nextEffect = null)), + (current.effectTag = 8)))); + newProps && + !renderExpirationTime$jscomp$0 && + 0 !== (current$$1.mode & 1) && + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); + newProps && (current$$1.effectTag |= 4); + break; + case 7: + break; + case 8: + break; + case 12: + break; + case 4: + popHostContainer(current$$1); + updateHostContainer(current$$1); + break; + case 10: + popProvider(current$$1); + break; + case 9: + break; + case 14: + break; + case 17: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + case 18: + break; + case 19: + break; + case 20: + break; + default: + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + current$$1 = null; + } + current = workInProgress; + if (1 === renderExpirationTime || 1 !== current.childExpirationTime) { + newProps = 0; + for ( + renderExpirationTime$jscomp$0 = current.child; + null !== renderExpirationTime$jscomp$0; + + ) + (type = renderExpirationTime$jscomp$0.expirationTime), + (rootContainerInstance = + renderExpirationTime$jscomp$0.childExpirationTime), + type > newProps && (newProps = type), + rootContainerInstance > newProps && + (newProps = rootContainerInstance), + (renderExpirationTime$jscomp$0 = + renderExpirationTime$jscomp$0.sibling); + current.childExpirationTime = newProps; + } + if (null !== current$$1) return current$$1; + null !== unitOfWork && + 0 === (unitOfWork.effectTag & 1024) && + (null === unitOfWork.firstEffect && + (unitOfWork.firstEffect = workInProgress.firstEffect), + null !== workInProgress.lastEffect && + (null !== unitOfWork.lastEffect && + (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), + (unitOfWork.lastEffect = workInProgress.lastEffect)), + 1 < workInProgress.effectTag && + (null !== unitOfWork.lastEffect + ? (unitOfWork.lastEffect.nextEffect = workInProgress) + : (unitOfWork.firstEffect = workInProgress), + (unitOfWork.lastEffect = workInProgress))); + } else { + current$$1 = unwindWork(workInProgress, renderExpirationTime); + if (null !== current$$1) + return (current$$1.effectTag &= 1023), current$$1; + null !== unitOfWork && + ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), + (unitOfWork.effectTag |= 1024)); + } + current$$1 = workInProgress.sibling; + if (null !== current$$1) return current$$1; + workInProgress = unitOfWork; + } while (null !== workInProgress); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootCompleted); + return null; +} +function commitRoot(root, expirationTime) { + runWithPriority(99, commitRootImpl.bind(null, root, expirationTime)); + null !== rootWithPendingPassiveEffects && + ((root = getCurrentPriorityLevel()), + scheduleCallback(root, function() { + flushPassiveEffects(); + return null; + })); + return null; +} +function commitRootImpl(root, expirationTime) { + flushPassiveEffects(); + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Should not already be working."); + var finishedWork = root.current.alternate; + if (null === finishedWork) + throw ReactError("Should have a work-in-progress root."); + root.callbackNode = null; + root.callbackExpirationTime = 0; + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, + childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + updateExpirationTimeBeforeCommit = + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit; + root.firstPendingTime = updateExpirationTimeBeforeCommit; + updateExpirationTimeBeforeCommit < root.lastPendingTime && + (root.lastPendingTime = updateExpirationTimeBeforeCommit); + root === workInProgressRoot && + ((workInProgress = workInProgressRoot = null), (renderExpirationTime = 0)); + 1 < finishedWork.effectTag + ? null !== finishedWork.lastEffect + ? ((finishedWork.lastEffect.nextEffect = finishedWork), + (childExpirationTimeBeforeCommit = finishedWork.firstEffect)) + : (childExpirationTimeBeforeCommit = finishedWork) + : (childExpirationTimeBeforeCommit = finishedWork.firstEffect); + if (null !== childExpirationTimeBeforeCommit) { + updateExpirationTimeBeforeCommit = workPhase; + workPhase = CommitPhase; + ReactCurrentOwner$2.current = null; + nextEffect = childExpirationTimeBeforeCommit; + do + try { + for (; null !== nextEffect; ) { + if (0 !== (nextEffect.effectTag & 256)) { + var current$$1 = nextEffect.alternate, + finishedWork$jscomp$0 = nextEffect; + switch (finishedWork$jscomp$0.tag) { + case 0: + case 11: + case 15: + commitHookEffectList( + UnmountSnapshot, + NoEffect$1, + finishedWork$jscomp$0 + ); + break; + case 1: + if ( + finishedWork$jscomp$0.effectTag & 256 && + null !== current$$1 + ) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState, + instance = finishedWork$jscomp$0.stateNode, + snapshot = instance.getSnapshotBeforeUpdate( + finishedWork$jscomp$0.elementType === + finishedWork$jscomp$0.type + ? prevProps + : resolveDefaultProps( + finishedWork$jscomp$0.type, + prevProps + ), + prevState + ); + instance.__reactInternalSnapshotBeforeUpdate = snapshot; + } + break; + case 3: + case 5: + case 6: + case 4: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + nextEffect = childExpirationTimeBeforeCommit; + do + try { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 128) { + var current$$1$jscomp$0 = nextEffect.alternate; + if (null !== current$$1$jscomp$0) { + var currentRef = current$$1$jscomp$0.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (effectTag & 14) { + case 2: + nextEffect.effectTag &= -3; + break; + case 6: + nextEffect.effectTag &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + current$$1 = nextEffect; + a: for (prevState = prevProps = current$$1; ; ) { + instance = prevState; + "function" === typeof onCommitFiberUnmount && + onCommitFiberUnmount(instance); + switch (instance.tag) { + case 0: + case 11: + case 14: + case 15: + var updateQueue = instance.updateQueue; + if (null !== updateQueue) { + var lastEffect = updateQueue.lastEffect; + if (null !== lastEffect) { + var firstEffect = lastEffect.next; + snapshot = firstEffect; + do { + var destroy = snapshot.destroy; + if (void 0 !== destroy) { + finishedWork$jscomp$0 = instance; + try { + destroy(); + } catch (error) { + captureCommitPhaseError( + finishedWork$jscomp$0, + error + ); + } + } + snapshot = snapshot.next; + } while (snapshot !== firstEffect); + } + } + break; + case 1: + safelyDetachRef(instance); + var instance$jscomp$0 = instance.stateNode; + if ( + "function" === + typeof instance$jscomp$0.componentWillUnmount + ) + try { + (instance$jscomp$0.props = instance.memoizedProps), + (instance$jscomp$0.state = instance.memoizedState), + instance$jscomp$0.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(instance, unmountError); + } + break; + case 5: + safelyDetachRef(instance); + break; + case 4: + FabricUIManager.createChildSet( + instance.stateNode.containerInfo + ); + } + if (null !== prevState.child) + (prevState.child.return = prevState), + (prevState = prevState.child); + else { + if (prevState === prevProps) break; + for (; null === prevState.sibling; ) { + if ( + null === prevState.return || + prevState.return === prevProps + ) + break a; + prevState = prevState.return; + } + prevState.sibling.return = prevState.return; + prevState = prevState.sibling; + } + } + current$$1.return = null; + current$$1.child = null; + current$$1.memoizedState = null; + current$$1.updateQueue = null; + var alternate = current$$1.alternate; + null !== alternate && + ((alternate.return = null), + (alternate.child = null), + (alternate.memoizedState = null), + (alternate.updateQueue = null)); + } + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + root.current = finishedWork; + nextEffect = childExpirationTimeBeforeCommit; + do + try { + for (effectTag = expirationTime; null !== nextEffect; ) { + var effectTag$jscomp$0 = nextEffect.effectTag; + if (effectTag$jscomp$0 & 36) { + var current$$1$jscomp$1 = nextEffect.alternate; + current$$1$jscomp$0 = nextEffect; + currentRef = effectTag; + switch (current$$1$jscomp$0.tag) { + case 0: + case 11: + case 15: + commitHookEffectList( + UnmountLayout, + MountLayout, + current$$1$jscomp$0 + ); + break; + case 1: + var instance$jscomp$1 = current$$1$jscomp$0.stateNode; + if (current$$1$jscomp$0.effectTag & 4) + if (null === current$$1$jscomp$1) + instance$jscomp$1.componentDidMount(); + else { + var prevProps$jscomp$0 = + current$$1$jscomp$0.elementType === + current$$1$jscomp$0.type + ? current$$1$jscomp$1.memoizedProps + : resolveDefaultProps( + current$$1$jscomp$0.type, + current$$1$jscomp$1.memoizedProps + ); + instance$jscomp$1.componentDidUpdate( + prevProps$jscomp$0, + current$$1$jscomp$1.memoizedState, + instance$jscomp$1.__reactInternalSnapshotBeforeUpdate + ); + } + var updateQueue$jscomp$0 = current$$1$jscomp$0.updateQueue; + null !== updateQueue$jscomp$0 && + commitUpdateQueue( + current$$1$jscomp$0, + updateQueue$jscomp$0, + instance$jscomp$1, + currentRef + ); + break; + case 3: + var _updateQueue = current$$1$jscomp$0.updateQueue; + if (null !== _updateQueue) { + updateQueue = null; + if (null !== current$$1$jscomp$0.child) + switch (current$$1$jscomp$0.child.tag) { + case 5: + updateQueue = + current$$1$jscomp$0.child.stateNode.canonical; + break; + case 1: + updateQueue = current$$1$jscomp$0.child.stateNode; + } + commitUpdateQueue( + current$$1$jscomp$0, + _updateQueue, + updateQueue, + currentRef + ); + } + break; + case 5: + if ( + null === current$$1$jscomp$1 && + current$$1$jscomp$0.effectTag & 4 + ) + throw ReactError( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + break; + case 4: + break; + case 12: + break; + case 13: + case 17: + break; + case 20: + break; + case 19: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + if (effectTag$jscomp$0 & 128) { + var ref = nextEffect.ref; + if (null !== ref) { + var instance$jscomp$2 = nextEffect.stateNode; + switch (nextEffect.tag) { + case 5: + var instanceToUse = instance$jscomp$2.canonical; + break; + default: + instanceToUse = instance$jscomp$2; + } + "function" === typeof ref + ? ref(instanceToUse) + : (ref.current = instanceToUse); + } + } + effectTag$jscomp$0 & 512 && (rootDoesHavePassiveEffects = !0); + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + nextEffect = null; + workPhase = updateExpirationTimeBeforeCommit; + } else root.current = finishedWork; + rootDoesHavePassiveEffects && + ((rootDoesHavePassiveEffects = !1), (rootWithPendingPassiveEffects = root)); + expirationTime = root.firstPendingTime; + 0 !== expirationTime + ? ((effectTag$jscomp$0 = requestCurrentTime()), + (effectTag$jscomp$0 = inferPriorityFromExpirationTime( + effectTag$jscomp$0, + expirationTime + )), + scheduleCallbackForRoot(root, effectTag$jscomp$0, expirationTime)) + : (legacyErrorBoundariesThatAlreadyFailed = null); + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode); + 1073741823 === expirationTime + ? root === rootWithNestedUpdates + ? nestedUpdateCount++ + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) + : (nestedUpdateCount = 0); + if (hasUncaughtError) + throw ((hasUncaughtError = !1), + (root = firstUncaughtError), + (firstUncaughtError = null), + root); + if (workPhase === LegacyUnbatchedPhase) return null; + flushImmediateQueue(); + return null; +} +function flushPassiveEffects() { + if (null === rootWithPendingPassiveEffects) return !1; + var root = rootWithPendingPassiveEffects; + rootWithPendingPassiveEffects = null; + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Cannot flush passive effects while already rendering."); + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + for (root = root.current.firstEffect; null !== root; ) { + try { + var finishedWork = root; + commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); + commitHookEffectList(NoEffect$1, MountPassive, finishedWork); + } catch (error) { + if (null === root) throw ReactError("Should be working on an effect."); + captureCommitPhaseError(root, error); + } + root = root.nextEffect; + } + workPhase = prevWorkPhase; + flushImmediateQueue(); + return !0; +} +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + sourceFiber = createCapturedValue(error, sourceFiber); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); + enqueueUpdate(rootFiber, sourceFiber); + rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); + null !== rootFiber && scheduleCallbackForRoot(rootFiber, 99, 1073741823); +} +function captureCommitPhaseError(sourceFiber, error) { + if (3 === sourceFiber.tag) + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + else + for (var fiber = sourceFiber.return; null !== fiber; ) { + if (3 === fiber.tag) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + break; + } else if (1 === fiber.tag) { + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(error, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); + null !== fiber && scheduleCallbackForRoot(fiber, 99, 1073741823); + break; + } + } + fiber = fiber.return; + } +} +function pingSuspendedRoot(root, thenable, suspendedTime) { + var pingCache = root.pingCache; + null !== pingCache && pingCache.delete(thenable); + workInProgressRoot === root && renderExpirationTime === suspendedTime + ? prepareFreshStack(root, renderExpirationTime) + : root.lastPendingTime < suspendedTime || + ((thenable = root.pingTime), + (0 !== thenable && thenable < suspendedTime) || + ((root.pingTime = suspendedTime), + (thenable = requestCurrentTime()), + (thenable = inferPriorityFromExpirationTime(thenable, suspendedTime)), + scheduleCallbackForRoot(root, thenable, suspendedTime))); +} +function resolveRetryThenable(boundaryFiber, thenable) { + var retryCache = boundaryFiber.stateNode; + null !== retryCache && retryCache.delete(thenable); + retryCache = requestCurrentTime(); + thenable = computeExpirationForFiber(retryCache, boundaryFiber); + retryCache = inferPriorityFromExpirationTime(retryCache, thenable); + boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); + null !== boundaryFiber && + scheduleCallbackForRoot(boundaryFiber, retryCache, thenable); +} +var beginWork$$1 = void 0; +beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if (null !== current$$1) if ( @@ -4309,59 +6148,57 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ((current$$1.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); - hasContext = workInProgress.pendingProps; - current$$1 = readLazyComponentType(context); - workInProgress.type = current$$1; - context = workInProgress.tag = resolveLazyComponentTag(current$$1); - hasContext = resolveDefaultProps(current$$1, hasContext); - getDerivedStateFromProps = void 0; - switch (context) { + current$$1 = workInProgress.pendingProps; + context = readLazyComponentType(context); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current$$1 = resolveDefaultProps(context, current$$1); + switch (hasContext) { case 0: - getDerivedStateFromProps = updateFunctionComponent( + workInProgress = updateFunctionComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 1: - getDerivedStateFromProps = updateClassComponent( + workInProgress = updateClassComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 11: - getDerivedStateFromProps = updateForwardRef( + workInProgress = updateForwardRef( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 14: - getDerivedStateFromProps = updateMemoComponent( + workInProgress = updateMemoComponent( null, workInProgress, - current$$1, - resolveDefaultProps(current$$1.type, hasContext), + context, + resolveDefaultProps(context.type, current$$1), updateExpirationTime, renderExpirationTime ); break; default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", - current$$1, - "" + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + context + + ". Lazy element type must resolve to a class or function." ); } - return getDerivedStateFromProps; + return workInProgress; case 0: return ( (updateExpirationTime = workInProgress.type), @@ -4395,38 +6232,36 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) ); case 3: - return ( - pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), - invariant( - null !== updateExpirationTime, + pushHostRootContext(workInProgress); + updateExpirationTime = workInProgress.updateQueue; + if (null === updateExpirationTime) + throw ReactError( "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." - ), - (context = workInProgress.memoizedState), - (context = null !== context ? context.element : null), - processUpdateQueue( - workInProgress, - updateExpirationTime, - workInProgress.pendingProps, - null, - renderExpirationTime - ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === context - ? (workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )) - : (reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child)), - workInProgress + ); + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; + processUpdateQueue( + workInProgress, + updateExpirationTime, + workInProgress.pendingProps, + null, + renderExpirationTime ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context + ? (workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + )) + : (reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child)); + return workInProgress; case 5: return ( pushHostContext(workInProgress), @@ -4439,8 +6274,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (workInProgress = workInProgress.child), - workInProgress + workInProgress.child ); case 6: return ( @@ -4567,7 +6401,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) { 1 === oldValue.tag && ((dependency = createUpdate(renderExpirationTime)), - (dependency.tag = ForceUpdate), + (dependency.tag = 2), enqueueUpdate(oldValue, dependency)); oldValue.expirationTime < renderExpirationTime && (oldValue.expirationTime = renderExpirationTime); @@ -4718,2025 +6552,20 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) ); } - invariant( - !1, + throw ReactError( "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); -} -var valueCursor = { current: null }, - currentlyRenderingFiber = null, - lastContextDependency = null, - lastContextWithAllBitsObserved = null; -function pushProvider(providerFiber, nextValue) { - var context = providerFiber.type._context; - push(valueCursor, context._currentValue2, providerFiber); - context._currentValue2 = nextValue; -} -function popProvider(providerFiber) { - var currentValue = valueCursor.current; - pop(valueCursor, providerFiber); - providerFiber.type._context._currentValue2 = currentValue; -} -function prepareToReadContext(workInProgress, renderExpirationTime) { - currentlyRenderingFiber = workInProgress; - lastContextWithAllBitsObserved = lastContextDependency = null; - var currentDependencies = workInProgress.contextDependencies; - null !== currentDependencies && - currentDependencies.expirationTime >= renderExpirationTime && - (didReceiveUpdate = !0); - workInProgress.contextDependencies = null; -} -function readContext(context, observedBits) { - if ( - lastContextWithAllBitsObserved !== context && - !1 !== observedBits && - 0 !== observedBits - ) { - if ("number" !== typeof observedBits || 1073741823 === observedBits) - (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); - observedBits = { context: context, observedBits: observedBits, next: null }; - null === lastContextDependency - ? (invariant( - null !== currentlyRenderingFiber, - "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()." - ), - (lastContextDependency = observedBits), - (currentlyRenderingFiber.contextDependencies = { - first: observedBits, - expirationTime: 0 - })) - : (lastContextDependency = lastContextDependency.next = observedBits); - } - return context._currentValue2; -} -var UpdateState = 0, - ReplaceState = 1, - ForceUpdate = 2, - CaptureUpdate = 3, - hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; -} -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; -} -function createUpdate(expirationTime) { - return { - expirationTime: expirationTime, - tag: UpdateState, - payload: null, - callback: null, - next: null, - nextEffect: null - }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); -} -function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); -} -function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case ReplaceState: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case CaptureUpdate: - workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; - case UpdateState: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case ForceUpdate: - hasForceUpdate = !0; - } - return prevState; -} -function processUpdateQueue( - workInProgress, - queue, - props, - instance, - renderExpirationTime -) { - hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; - } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; - } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; -} -function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var _callback3 = effect.callback; - if (null !== _callback3) { - effect.callback = null; - var context = instance; - invariant( - "function" === typeof _callback3, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - _callback3 - ); - _callback3.call(context); - } - effect = effect.nextEffect; - } -} -function createCapturedValue(value, source) { - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; -} -var appendAllChildren = void 0, - updateHostContainer = void 0, - updateHostComponent$1 = void 0, - updateHostText$1 = void 0; -appendAllChildren = function( - parent, - workInProgress, - needsVisibilityToggle, - isHidden -) { - for (var node = workInProgress.child; null !== node; ) { - a: if (5 === node.tag) { - var instance = node.stateNode; - if (needsVisibilityToggle) { - var props = node.memoizedProps, - type = node.type; - instance = isHidden - ? cloneHiddenInstance(instance, type, props, node) - : cloneUnhiddenInstance(instance, type, props, node); - node.stateNode = instance; - } - FabricUIManager.appendChild(parent.node, instance.node); - } else if (6 === node.tag) { - instance = node.stateNode; - if (needsVisibilityToggle) { - instance = node.memoizedProps; - props = requiredContext(rootInstanceStackCursor.current); - type = requiredContext(contextStackCursor$1.current); - if (isHidden) throw Error("Not yet implemented."); - instance = createTextInstance(instance, props, type, workInProgress); - node.stateNode = instance; - } - FabricUIManager.appendChild(parent.node, instance.node); - } else if (4 !== node.tag) { - if ( - 13 === node.tag && - ((props = node.alternate), - null !== props && - ((instance = null !== node.memoizedState), - (null !== props.memoizedState) !== instance)) - ) { - props = instance ? node.child : node; - null !== props && appendAllChildren(parent, props, !0, instance); - break a; - } - if (null !== node.child) { - node.child.return = node; - node = node.child; - continue; - } - } - if (node === workInProgress) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === workInProgress) return; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } }; -function appendAllChildrenToContainer( - containerChildSet, - workInProgress, - needsVisibilityToggle, - isHidden -) { - for (var node = workInProgress.child; null !== node; ) { - a: if (5 === node.tag) { - var instance = node.stateNode; - if (needsVisibilityToggle) { - var props = node.memoizedProps, - type = node.type; - instance = isHidden - ? cloneHiddenInstance(instance, type, props, node) - : cloneUnhiddenInstance(instance, type, props, node); - node.stateNode = instance; - } - FabricUIManager.appendChildToSet(containerChildSet, instance.node); - } else if (6 === node.tag) { - instance = node.stateNode; - if (needsVisibilityToggle) { - instance = node.memoizedProps; - props = requiredContext(rootInstanceStackCursor.current); - type = requiredContext(contextStackCursor$1.current); - if (isHidden) throw Error("Not yet implemented."); - instance = createTextInstance(instance, props, type, workInProgress); - node.stateNode = instance; - } - FabricUIManager.appendChildToSet(containerChildSet, instance.node); - } else if (4 !== node.tag) { - if ( - 13 === node.tag && - ((props = node.alternate), - null !== props && - ((instance = null !== node.memoizedState), - (null !== props.memoizedState) !== instance)) - ) { - props = instance ? node.child : node; - null !== props && - appendAllChildrenToContainer(containerChildSet, props, !0, instance); - break a; - } - if (null !== node.child) { - node.child.return = node; - node = node.child; - continue; - } - } - if (node === workInProgress) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === workInProgress) return; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } -} -updateHostContainer = function(workInProgress) { - var portalOrRoot = workInProgress.stateNode; - if (null !== workInProgress.firstEffect) { - var container = portalOrRoot.containerInfo, - newChildSet = FabricUIManager.createChildSet(container); - appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); - portalOrRoot.pendingChildren = newChildSet; - workInProgress.effectTag |= 4; - FabricUIManager.completeRoot(container, newChildSet); - } -}; -updateHostComponent$1 = function(current, workInProgress, type, newProps) { - type = current.stateNode; - var oldProps = current.memoizedProps; - if ((current = null === workInProgress.firstEffect) && oldProps === newProps) - workInProgress.stateNode = type; - else { - var recyclableInstance = workInProgress.stateNode; - requiredContext(contextStackCursor$1.current); - var updatePayload = null; - oldProps !== newProps && - ((oldProps = diffProperties( - null, - oldProps, - newProps, - recyclableInstance.canonical.viewConfig.validAttributes - )), - (recyclableInstance.canonical.currentProps = newProps), - (updatePayload = oldProps)); - current && null === updatePayload - ? (workInProgress.stateNode = type) - : ((newProps = updatePayload), - (recyclableInstance = type.node), - (type = { - node: current - ? null !== newProps - ? FabricUIManager.cloneNodeWithNewProps( - recyclableInstance, - newProps - ) - : FabricUIManager.cloneNode(recyclableInstance) - : null !== newProps - ? FabricUIManager.cloneNodeWithNewChildrenAndProps( - recyclableInstance, - newProps - ) - : FabricUIManager.cloneNodeWithNewChildren(recyclableInstance), - canonical: type.canonical - }), - (workInProgress.stateNode = type), - current - ? (workInProgress.effectTag |= 4) - : appendAllChildren(type, workInProgress, !1, !1)); - } -}; -updateHostText$1 = function(current, workInProgress, oldText, newText) { - oldText !== newText && - ((current = requiredContext(rootInstanceStackCursor.current)), - (oldText = requiredContext(contextStackCursor$1.current)), - (workInProgress.stateNode = createTextInstance( - newText, - current, - oldText, - workInProgress - )), - (workInProgress.effectTag |= 4)); -}; -function logCapturedError(capturedError) { - var componentStack = capturedError.componentStack, - error = capturedError.error; - if (error instanceof Error) { - capturedError = error.message; - var name = error.name; - try { - error.message = - (capturedError ? name + ": " + capturedError : name) + - "\n\nThis error is located at:" + - componentStack; - } catch (e) {} - } else - error = - "string" === typeof error - ? Error(error + "\n\nThis error is located at:" + componentStack) - : Error("Unspecified error at:" + componentStack); - ExceptionsManager.handleException(error, !1); -} -function logError(boundary, errorInfo) { - var source = errorInfo.source, - stack = errorInfo.stack; - null === stack && - null !== source && - (stack = getStackByFiberInDevAndProd(source)); - errorInfo = { - componentName: null !== source ? getComponentName(source.type) : null, - componentStack: null !== stack ? stack : "", - error: errorInfo.value, - errorBoundary: null, - errorBoundaryName: null, - errorBoundaryFound: !1, - willRetry: !1 - }; - null !== boundary && - 1 === boundary.tag && - ((errorInfo.errorBoundary = boundary.stateNode), - (errorInfo.errorBoundaryName = getComponentName(boundary.type)), - (errorInfo.errorBoundaryFound = !0), - (errorInfo.willRetry = !0)); - try { - logCapturedError(errorInfo); - } catch (e) { - setTimeout(function() { - throw e; - }); - } -} -function safelyDetachRef(current$$1) { - var ref = current$$1.ref; - if (null !== ref) - if ("function" === typeof ref) - try { - ref(null); - } catch (refError) { - captureCommitPhaseError(current$$1, refError); - } - else ref.current = null; -} -function commitHookEffectList(unmountTag, mountTag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & unmountTag) !== NoEffect$1) { - var destroy = effect.destroy; - effect.destroy = void 0; - void 0 !== destroy && destroy(); - } - (effect.tag & mountTag) !== NoEffect$1 && - ((destroy = effect.create), (effect.destroy = destroy())); - effect = effect.next; - } while (effect !== finishedWork); - } -} -function commitWork(current$$1, finishedWork) { - switch (finishedWork.tag) { - case 0: - case 11: - case 14: - case 15: - commitHookEffectList(UnmountMutation, MountMutation, finishedWork); - return; - } - switch (finishedWork.tag) { - case 1: - break; - case 5: - break; - case 6: - break; - case 3: - case 4: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } -} -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime); - expirationTime.tag = CaptureUpdate; - expirationTime.payload = { element: null }; - var error = errorInfo.value; - expirationTime.callback = function() { - onUncaughtError(error); - logError(fiber, errorInfo); - }; - return expirationTime; -} -function createClassErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime); - expirationTime.tag = CaptureUpdate; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error$jscomp$0 = errorInfo.value; - expirationTime.payload = function() { - return getDerivedStateFromError(error$jscomp$0); - }; - } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (expirationTime.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this)); - var error = errorInfo.value, - stack = errorInfo.stack; - logError(fiber, errorInfo); - this.componentDidCatch(error, { - componentStack: null !== stack ? stack : "" - }); - }); - return expirationTime; -} -function unwindWork(workInProgress) { - switch (workInProgress.tag) { - case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - var effectTag = workInProgress.effectTag; - return effectTag & 2048 - ? ((workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress) - : null; - case 3: - return ( - popHostContainer(workInProgress), - popTopLevelContextObject(workInProgress), - (effectTag = workInProgress.effectTag), - invariant( - 0 === (effectTag & 64), - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ), - (workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress - ); - case 5: - return popHostContext(workInProgress), null; - case 13: - return ( - (effectTag = workInProgress.effectTag), - effectTag & 2048 - ? ((workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress) - : null - ); - case 18: - return null; - case 4: - return popHostContainer(workInProgress), null; - case 10: - return popProvider(workInProgress), null; - default: - return null; - } -} -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, - ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - isWorking = !1, - nextUnitOfWork = null, - nextRoot = null, - nextRenderExpirationTime = 0, - nextLatestAbsoluteTimeoutMs = -1, - nextRenderDidError = !1, - nextEffect = null, - isCommitting$1 = !1, - rootWithPendingPassiveEffects = null, - passiveEffectCallbackHandle = null, - passiveEffectCallback = null, - legacyErrorBoundariesThatAlreadyFailed = null; -function resetStack() { - if (null !== nextUnitOfWork) - for ( - var interruptedWork = nextUnitOfWork.return; - null !== interruptedWork; - - ) { - var interruptedWork$jscomp$0 = interruptedWork; - switch (interruptedWork$jscomp$0.tag) { - case 1: - var childContextTypes = - interruptedWork$jscomp$0.type.childContextTypes; - null !== childContextTypes && - void 0 !== childContextTypes && - popContext(interruptedWork$jscomp$0); - break; - case 3: - popHostContainer(interruptedWork$jscomp$0); - popTopLevelContextObject(interruptedWork$jscomp$0); - break; - case 5: - popHostContext(interruptedWork$jscomp$0); - break; - case 4: - popHostContainer(interruptedWork$jscomp$0); - break; - case 10: - popProvider(interruptedWork$jscomp$0); - } - interruptedWork = interruptedWork.return; - } - nextRoot = null; - nextRenderExpirationTime = 0; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = !1; - nextUnitOfWork = null; -} -function commitAllHostEffects() { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { - var current$$1 = nextEffect.alternate; - null !== current$$1 && - ((current$$1 = current$$1.ref), - null !== current$$1 && - ("function" === typeof current$$1 - ? current$$1(null) - : (current$$1.current = null))); - } - switch (effectTag & 14) { - case 2: - nextEffect.effectTag &= -3; - break; - case 6: - nextEffect.effectTag &= -3; - commitWork(nextEffect.alternate, nextEffect); - break; - case 4: - commitWork(nextEffect.alternate, nextEffect); - break; - case 8: - effectTag = nextEffect; - a: for (var node = (current$$1 = effectTag); ; ) { - var current$$1$jscomp$0 = node; - "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$$1$jscomp$0); - switch (current$$1$jscomp$0.tag) { - case 0: - case 11: - case 14: - case 15: - var updateQueue = current$$1$jscomp$0.updateQueue; - if ( - null !== updateQueue && - ((updateQueue = updateQueue.lastEffect), null !== updateQueue) - ) { - var effect = (updateQueue = updateQueue.next); - do { - var destroy = effect.destroy; - if (void 0 !== destroy) { - var current$$1$jscomp$1 = current$$1$jscomp$0; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(current$$1$jscomp$1, error); - } - } - effect = effect.next; - } while (effect !== updateQueue); - } - break; - case 1: - safelyDetachRef(current$$1$jscomp$0); - updateQueue = current$$1$jscomp$0.stateNode; - if ("function" === typeof updateQueue.componentWillUnmount) - try { - (updateQueue.props = current$$1$jscomp$0.memoizedProps), - (updateQueue.state = current$$1$jscomp$0.memoizedState), - updateQueue.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current$$1$jscomp$0, unmountError); - } - break; - case 5: - safelyDetachRef(current$$1$jscomp$0); - break; - case 4: - FabricUIManager.createChildSet( - current$$1$jscomp$0.stateNode.containerInfo - ); - } - if (null !== node.child) - (node.child.return = node), (node = node.child); - else { - if (node === current$$1) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === current$$1) break a; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - effectTag.return = null; - effectTag.child = null; - effectTag.memoizedState = null; - effectTag.updateQueue = null; - effectTag = effectTag.alternate; - null !== effectTag && - ((effectTag.return = null), - (effectTag.child = null), - (effectTag.memoizedState = null), - (effectTag.updateQueue = null)); - } - nextEffect = nextEffect.nextEffect; - } -} -function commitBeforeMutationLifecycles() { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) - a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - break a; - case 1: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState; - current$$1 = finishedWork.stateNode; - finishedWork = current$$1.getSnapshotBeforeUpdate( - finishedWork.elementType === finishedWork.type - ? prevProps - : resolveDefaultProps(finishedWork.type, prevProps), - prevState - ); - current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; - } - break a; - case 3: - case 5: - case 6: - case 4: - case 17: - break a; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } -} -function commitAllLifeCycles(finishedRoot, committedExpirationTime$jscomp$0) { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 36) { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect, - committedExpirationTime = committedExpirationTime$jscomp$0; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; - case 1: - var instance = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current$$1) instance.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current$$1.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current$$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - current$$1 = finishedWork.updateQueue; - null !== current$$1 && - commitUpdateQueue( - finishedWork, - current$$1, - instance, - committedExpirationTime - ); - break; - case 3: - instance = finishedWork.updateQueue; - if (null !== instance) { - current$$1 = null; - if (null !== finishedWork.child) - switch (finishedWork.child.tag) { - case 5: - current$$1 = finishedWork.child.stateNode.canonical; - break; - case 1: - current$$1 = finishedWork.child.stateNode; - } - commitUpdateQueue( - finishedWork, - instance, - current$$1, - committedExpirationTime - ); - } - break; - case 5: - null === current$$1 && - finishedWork.effectTag & 4 && - invariant( - !1, - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 17: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - if ( - effectTag & 128 && - ((finishedWork = nextEffect.ref), null !== finishedWork) - ) { - committedExpirationTime = nextEffect.stateNode; - switch (nextEffect.tag) { - case 5: - committedExpirationTime = committedExpirationTime.canonical; - } - "function" === typeof finishedWork - ? finishedWork(committedExpirationTime) - : (finishedWork.current = committedExpirationTime); - } - effectTag & 512 && (rootWithPendingPassiveEffects = finishedRoot); - nextEffect = nextEffect.nextEffect; - } -} -function commitPassiveEffects(root, firstEffect) { - passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; - var previousIsRendering = isRendering; - isRendering = !0; - do { - if (firstEffect.effectTag & 512) { - var didError = !1, - error = void 0; - try { - var finishedWork = firstEffect; - commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); - commitHookEffectList(NoEffect$1, MountPassive, finishedWork); - } catch (e) { - (didError = !0), (error = e); - } - didError && captureCommitPhaseError(firstEffect, error); - } - firstEffect = firstEffect.nextEffect; - } while (null !== firstEffect); - isRendering = previousIsRendering; - previousIsRendering = root.expirationTime; - 0 !== previousIsRendering && requestWork(root, previousIsRendering); - isBatchingUpdates || isRendering || performWork(1073741823, !1); -} -function flushPassiveEffects() { - if (null !== passiveEffectCallbackHandle) { - var callbackID = passiveEffectCallbackHandle; - scheduledCallback = null; - clearTimeout(callbackID); - } - null !== passiveEffectCallback && passiveEffectCallback(); -} -function commitRoot(root, finishedWork) { - isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); - var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== committedExpirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.pendingCommitExpirationTime = 0; - var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, - childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; - markCommittedPriorityLevels( - root, - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit - ? childExpirationTimeBeforeCommit - : updateExpirationTimeBeforeCommit - ); - ReactCurrentOwner$2.current = null; - updateExpirationTimeBeforeCommit = void 0; - 1 < finishedWork.effectTag - ? null !== finishedWork.lastEffect - ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (updateExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (updateExpirationTimeBeforeCommit = finishedWork) - : (updateExpirationTimeBeforeCommit = finishedWork.firstEffect); - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - var error = void 0; - try { - commitBeforeMutationLifecycles(); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - error = void 0; - try { - commitAllHostEffects(); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - root.current = finishedWork; - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - error = void 0; - try { - commitAllLifeCycles(root, committedExpirationTime); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - if ( - null !== updateExpirationTimeBeforeCommit && - null !== rootWithPendingPassiveEffects - ) { - var callback = commitPassiveEffects.bind( - null, - root, - updateExpirationTimeBeforeCommit - ); - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return scheduleDeferredCallback$1(callback); - } - ); - passiveEffectCallback = callback; - } - isWorking = isCommitting$1 = !1; - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode); - committedExpirationTime = finishedWork.expirationTime; - finishedWork = finishedWork.childExpirationTime; - finishedWork = - finishedWork > committedExpirationTime - ? finishedWork - : committedExpirationTime; - 0 === finishedWork && (legacyErrorBoundariesThatAlreadyFailed = null); - onCommit(root, finishedWork); -} -function completeUnitOfWork(workInProgress) { - for (;;) { - var current$$1 = workInProgress.alternate, - returnFiber = workInProgress.return, - siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 1024)) { - nextUnitOfWork = workInProgress; - a: { - var current = current$$1; - current$$1 = workInProgress; - var renderExpirationTime = nextRenderExpirationTime; - var instance = current$$1.pendingProps; - switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: - case 0: - break; - case 1: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 3: - popHostContainer(current$$1); - popTopLevelContextObject(current$$1); - instance = current$$1.stateNode; - instance.pendingContext && - ((instance.context = instance.pendingContext), - (instance.pendingContext = null)); - if (null === current || null === current.child) - current$$1.effectTag &= -3; - updateHostContainer(current$$1); - break; - case 5: - popHostContext(current$$1); - renderExpirationTime = requiredContext( - rootInstanceStackCursor.current - ); - var type = current$$1.type; - if (null !== current && null != current$$1.stateNode) - updateHostComponent$1( - current, - current$$1, - type, - instance, - renderExpirationTime - ), - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - else if (instance) { - var currentHostContext = requiredContext( - contextStackCursor$1.current - ), - internalInstanceHandle = current$$1; - current = nextReactTag; - nextReactTag += 2; - var viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !currentHostContext.isInAParentText, - "Nesting of within is not currently supported." - ); - type = diffProperties( - null, - emptyObject, - instance, - viewConfig.validAttributes - ); - renderExpirationTime = FabricUIManager.createNode( - current, - viewConfig.uiViewClassName, - renderExpirationTime, - type, - internalInstanceHandle - ); - instance = new ReactFabricHostComponent( - current, - viewConfig, - instance - ); - instance = { node: renderExpirationTime, canonical: instance }; - appendAllChildren(instance, current$$1, !1, !1); - current$$1.stateNode = instance; - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - current && null != current$$1.stateNode - ? updateHostText$1( - current, - current$$1, - current.memoizedProps, - instance - ) - : ("string" !== typeof instance && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ), - (current = requiredContext(rootInstanceStackCursor.current)), - (renderExpirationTime = requiredContext( - contextStackCursor$1.current - )), - (current$$1.stateNode = createTextInstance( - instance, - current, - renderExpirationTime, - current$$1 - ))); - break; - case 11: - break; - case 13: - instance = current$$1.memoizedState; - if (0 !== (current$$1.effectTag & 64)) { - current$$1.expirationTime = renderExpirationTime; - nextUnitOfWork = current$$1; - break a; - } - instance = null !== instance; - renderExpirationTime = - null !== current && null !== current.memoizedState; - null !== current && - !instance && - renderExpirationTime && - ((current = current.child.sibling), - null !== current && - ((viewConfig = current$$1.firstEffect), - null !== viewConfig - ? ((current$$1.firstEffect = current), - (current.nextEffect = viewConfig)) - : ((current$$1.firstEffect = current$$1.lastEffect = current), - (current.nextEffect = null)), - (current.effectTag = 8))); - if (instance || renderExpirationTime) current$$1.effectTag |= 4; - break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); - break; - case 9: - break; - case 14: - break; - case 17: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 18: - break; - default: - invariant( - !1, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); - } - nextUnitOfWork = null; - } - current$$1 = workInProgress; - if ( - 1 === nextRenderExpirationTime || - 1 !== current$$1.childExpirationTime - ) { - instance = 0; - for (current = current$$1.child; null !== current; ) - (renderExpirationTime = current.expirationTime), - (viewConfig = current.childExpirationTime), - renderExpirationTime > instance && - (instance = renderExpirationTime), - viewConfig > instance && (instance = viewConfig), - (current = current.sibling); - current$$1.childExpirationTime = instance; - } - if (null !== nextUnitOfWork) return nextUnitOfWork; - null !== returnFiber && - 0 === (returnFiber.effectTag & 1024) && - (null === returnFiber.firstEffect && - (returnFiber.firstEffect = workInProgress.firstEffect), - null !== workInProgress.lastEffect && - (null !== returnFiber.lastEffect && - (returnFiber.lastEffect.nextEffect = workInProgress.firstEffect), - (returnFiber.lastEffect = workInProgress.lastEffect)), - 1 < workInProgress.effectTag && - (null !== returnFiber.lastEffect - ? (returnFiber.lastEffect.nextEffect = workInProgress) - : (returnFiber.firstEffect = workInProgress), - (returnFiber.lastEffect = workInProgress))); - } else { - workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); - if (null !== workInProgress) - return (workInProgress.effectTag &= 1023), workInProgress; - null !== returnFiber && - ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 1024)); - } - if (null !== siblingFiber) return siblingFiber; - if (null !== returnFiber) workInProgress = returnFiber; - else break; - } - return null; -} -function performUnitOfWork(workInProgress) { - var next = beginWork( - workInProgress.alternate, - workInProgress, - nextRenderExpirationTime - ); - workInProgress.memoizedProps = workInProgress.pendingProps; - null === next && (next = completeUnitOfWork(workInProgress)); - ReactCurrentOwner$2.current = null; - return next; -} -function renderRoot(root$jscomp$0, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - flushPassiveEffects(); - isWorking = !0; - var previousDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - var expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn; - if ( - expirationTime !== nextRenderExpirationTime || - root$jscomp$0 !== nextRoot || - null === nextUnitOfWork - ) - resetStack(), - (nextRoot = root$jscomp$0), - (nextRenderExpirationTime = expirationTime), - (nextUnitOfWork = createWorkInProgress( - nextRoot.current, - null, - nextRenderExpirationTime - )), - (root$jscomp$0.pendingCommitExpirationTime = 0); - var didFatal = !1; - do { - try { - if (isYieldy) - for (; null !== nextUnitOfWork && !(frameDeadline <= now$1()); ) - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - else - for (; null !== nextUnitOfWork; ) - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - } catch (thrownValue) { - if ( - ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), - resetHooks(), - null === nextUnitOfWork) - ) - (didFatal = !0), onUncaughtError(thrownValue); - else { - invariant( - null !== nextUnitOfWork, - "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." - ); - var sourceFiber = nextUnitOfWork, - returnFiber = sourceFiber.return; - if (null === returnFiber) (didFatal = !0), onUncaughtError(thrownValue); - else { - a: { - var root = root$jscomp$0, - returnFiber$jscomp$0 = returnFiber, - sourceFiber$jscomp$0 = sourceFiber, - value = thrownValue; - returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 1024; - sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; - if ( - null !== value && - "object" === typeof value && - "function" === typeof value.then - ) { - var thenable = value; - value = returnFiber$jscomp$0; - var earliestTimeoutMs = -1, - startTimeMs = -1; - do { - if (13 === value.tag) { - var current$$1 = value.alternate; - if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), - null !== current$$1) - ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); - break; - } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; - else if ( - -1 === earliestTimeoutMs || - current$$1 < earliestTimeoutMs - ) - earliestTimeoutMs = current$$1; - } - value = value.return; - } while (null !== value); - value = returnFiber$jscomp$0; - do { - if ((current$$1 = 13 === value.tag)) - current$$1 = - void 0 === value.memoizedProps.fallback - ? !1 - : null === value.memoizedState; - if (current$$1) { - returnFiber$jscomp$0 = value.updateQueue; - null === returnFiber$jscomp$0 - ? ((returnFiber$jscomp$0 = new Set()), - returnFiber$jscomp$0.add(thenable), - (value.updateQueue = returnFiber$jscomp$0)) - : returnFiber$jscomp$0.add(thenable); - if (0 === (value.mode & 1)) { - value.effectTag |= 64; - sourceFiber$jscomp$0.effectTag &= -1957; - 1 === sourceFiber$jscomp$0.tag && - (null === sourceFiber$jscomp$0.alternate - ? (sourceFiber$jscomp$0.tag = 17) - : ((returnFiber = createUpdate(1073741823)), - (returnFiber.tag = ForceUpdate), - enqueueUpdate(sourceFiber$jscomp$0, returnFiber))); - sourceFiber$jscomp$0.expirationTime = 1073741823; - break a; - } - sourceFiber$jscomp$0 = root; - returnFiber$jscomp$0 = returnFiber; - var pingCache = sourceFiber$jscomp$0.pingCache; - null === pingCache - ? ((pingCache = sourceFiber$jscomp$0.pingCache = new PossiblyWeakMap()), - (current$$1 = new Set()), - pingCache.set(thenable, current$$1)) - : ((current$$1 = pingCache.get(thenable)), - void 0 === current$$1 && - ((current$$1 = new Set()), - pingCache.set(thenable, current$$1))); - current$$1.has(returnFiber$jscomp$0) || - (current$$1.add(returnFiber$jscomp$0), - (sourceFiber$jscomp$0 = pingSuspendedRoot.bind( - null, - sourceFiber$jscomp$0, - thenable, - returnFiber$jscomp$0 - )), - thenable.then(sourceFiber$jscomp$0, sourceFiber$jscomp$0)); - -1 === earliestTimeoutMs - ? (root = 1073741823) - : (-1 === startTimeMs && - (startTimeMs = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - returnFiber - )) - - 5e3), - (root = startTimeMs + earliestTimeoutMs)); - 0 <= root && - nextLatestAbsoluteTimeoutMs < root && - (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 2048; - value.expirationTime = returnFiber; - break a; - } - value = value.return; - } while (null !== value); - value = Error( - (getComponentName(sourceFiber$jscomp$0.type) || - "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber$jscomp$0) - ); - } - nextRenderDidError = !0; - value = createCapturedValue(value, sourceFiber$jscomp$0); - root = returnFiber$jscomp$0; - do { - switch (root.tag) { - case 3: - root.effectTag |= 2048; - root.expirationTime = returnFiber; - returnFiber = createRootErrorUpdate(root, value, returnFiber); - enqueueCapturedUpdate(root, returnFiber); - break a; - case 1: - if ( - ((earliestTimeoutMs = value), - (startTimeMs = root.type), - (sourceFiber$jscomp$0 = root.stateNode), - 0 === (root.effectTag & 64) && - ("function" === - typeof startTimeMs.getDerivedStateFromError || - (null !== sourceFiber$jscomp$0 && - "function" === - typeof sourceFiber$jscomp$0.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - sourceFiber$jscomp$0 - ))))) - ) { - root.effectTag |= 2048; - root.expirationTime = returnFiber; - returnFiber = createClassErrorUpdate( - root, - earliestTimeoutMs, - returnFiber - ); - enqueueCapturedUpdate(root, returnFiber); - break a; - } - } - root = root.return; - } while (null !== root); - } - nextUnitOfWork = completeUnitOfWork(sourceFiber); - continue; - } - } - } - break; - } while (1); - isWorking = !1; - ReactCurrentDispatcher.current = previousDispatcher; - lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; - resetHooks(); - if (didFatal) (nextRoot = null), (root$jscomp$0.finishedWork = null); - else if (null !== nextUnitOfWork) root$jscomp$0.finishedWork = null; - else { - previousDispatcher = root$jscomp$0.current.alternate; - invariant( - null !== previousDispatcher, - "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." - ); - nextRoot = null; - if (nextRenderDidError) { - didFatal = root$jscomp$0.latestPendingTime; - sourceFiber = root$jscomp$0.latestSuspendedTime; - returnFiber = root$jscomp$0.latestPingedTime; - if ( - (0 !== didFatal && didFatal < expirationTime) || - (0 !== sourceFiber && sourceFiber < expirationTime) || - (0 !== returnFiber && returnFiber < expirationTime) - ) { - markSuspendedPriorityLevel(root$jscomp$0, expirationTime); - onSuspend( - root$jscomp$0, - previousDispatcher, - expirationTime, - root$jscomp$0.expirationTime, - -1 - ); - return; - } - if (!root$jscomp$0.didError && isYieldy) { - root$jscomp$0.didError = !0; - expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn = expirationTime; - isYieldy = root$jscomp$0.expirationTime = 1073741823; - onSuspend( - root$jscomp$0, - previousDispatcher, - expirationTime, - isYieldy, - -1 - ); - return; - } - } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs - ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), - (isYieldy = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root$jscomp$0, - expirationTime - ))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), - onSuspend( - root$jscomp$0, - previousDispatcher, - expirationTime, - root$jscomp$0.expirationTime, - 0 > isYieldy ? 0 : isYieldy - )) - : ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), - (root$jscomp$0.finishedWork = previousDispatcher)); - } -} -function captureCommitPhaseError(sourceFiber, value) { - for (var fiber = sourceFiber.return; null !== fiber; ) { - switch (fiber.tag) { - case 1: - var instance = fiber.stateNode; - if ( - "function" === typeof fiber.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - sourceFiber = createCapturedValue(value, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); - return; - } - break; - case 3: - sourceFiber = createCapturedValue(value, sourceFiber); - sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); - return; - } - fiber = fiber.return; - } - 3 === sourceFiber.tag && - ((fiber = createCapturedValue(value, sourceFiber)), - (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), - enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); -} -function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(), - expirationTime = void 0; - if (0 === (fiber.mode & 1)) expirationTime = 1073741823; - else if (isWorking && !isCommitting$1) - expirationTime = nextRenderExpirationTime; - else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = 1073741823; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = - 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); - break; - case scheduler.unstable_NormalPriority: - expirationTime = - 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = 1; - break; - default: - invariant( - !1, - "Unknown priority level. This error is likely caused by a bug in React. Please file an issue." - ); - } - null !== nextRoot && - expirationTime === nextRenderExpirationTime && - --expirationTime; - } - priorityLevel === scheduler.unstable_UserBlockingPriority && - (0 === lowestPriorityPendingInteractiveExpirationTime || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) && - (lowestPriorityPendingInteractiveExpirationTime = expirationTime); - return expirationTime; -} -function pingSuspendedRoot(root, thenable, pingTime) { - var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - if (null !== nextRoot && nextRenderExpirationTime === pingTime) - nextRoot = null; - else if ( - ((thenable = root.earliestSuspendedTime), - (pingCache = root.latestSuspendedTime), - 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) - ) { - root.didError = !1; - thenable = root.latestPingedTime; - if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; - findNextExpirationTimeToWorkOn(pingTime, root); - pingTime = root.expirationTime; - 0 !== pingTime && requestWork(root, pingTime); - } -} -function scheduleWork(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); - var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < expirationTime && - (alternate.expirationTime = expirationTime); - var node = fiber.return, - root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; - else - for (; null !== node; ) { - alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); - null !== alternate && - alternate.childExpirationTime < expirationTime && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { - root = node.stateNode; - break; - } - node = node.return; - } - fiber = root; - null !== fiber && - (!isWorking && - 0 !== nextRenderExpirationTime && - expirationTime > nextRenderExpirationTime && - resetStack(), - markPendingPriorityLevel(fiber, expirationTime), - (isWorking && !isCommitting$1 && nextRoot === fiber) || - requestWork(fiber, fiber.expirationTime), - nestedUpdateCount > NESTED_UPDATE_LIMIT && - ((nestedUpdateCount = 0), - invariant( - !1, - "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." - ))); -} -var firstScheduledRoot = null, - lastScheduledRoot = null, - callbackExpirationTime = 0, - callbackID = void 0, - isRendering = !1, - nextFlushedRoot = null, - nextFlushedExpirationTime = 0, - lowestPriorityPendingInteractiveExpirationTime = 0, - hasUnhandledError = !1, - unhandledError = null, - isBatchingUpdates = !1, - isUnbatchingUpdates = !1, - completedBatches = null, - originalStartTimeMs = now$1(), - currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), - currentSchedulerTime = currentRendererTime, - NESTED_UPDATE_LIMIT = 50, - nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null; -function recomputeCurrentRendererTime() { - currentRendererTime = - 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); -} -function scheduleCallbackWithExpirationTime(root, expirationTime) { - if (0 !== callbackExpirationTime) { - if (expirationTime < callbackExpirationTime) return; - null !== callbackID && - ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); - } - callbackExpirationTime = expirationTime; - root = now$1() - originalStartTimeMs; - callbackID = scheduleDeferredCallback$1(performAsyncWork, { - timeout: 10 * (1073741822 - expirationTime) - root - }); -} -function onSuspend( - root, - finishedWork, - suspendedExpirationTime, - rootExpirationTime, - msUntilTimeout -) { - root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || frameDeadline <= now$1() - ? 0 < msUntilTimeout && - (root.timeoutHandle = scheduleTimeout( - onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), - msUntilTimeout - )) - : ((root.pendingCommitExpirationTime = suspendedExpirationTime), - (root.finishedWork = finishedWork)); -} -function onTimeout(root, finishedWork, suspendedExpirationTime) { - root.pendingCommitExpirationTime = suspendedExpirationTime; - root.finishedWork = finishedWork; - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); - nextFlushedRoot = root; - nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); -} -function onCommit(root, expirationTime) { - root.expirationTime = expirationTime; - root.finishedWork = null; -} -function requestCurrentTime() { - if (isRendering) return currentSchedulerTime; - findHighestPriorityRoot(); - if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - return currentSchedulerTime; -} -function requestWork(root, expirationTime) { - null === root.nextScheduledRoot - ? ((root.expirationTime = expirationTime), - null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = root), - (root.nextScheduledRoot = root)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) - : expirationTime > root.expirationTime && - (root.expirationTime = expirationTime); - isRendering || - (isBatchingUpdates - ? isUnbatchingUpdates && - ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1073741823), - performWorkOnRoot(root, 1073741823, !1)) - : 1073741823 === expirationTime - ? performWork(1073741823, !1) - : scheduleCallbackWithExpirationTime(root, expirationTime)); -} -function findHighestPriorityRoot() { - var highestPriorityWork = 0, - highestPriorityRoot = null; - if (null !== lastScheduledRoot) - for ( - var previousScheduledRoot = lastScheduledRoot, root = firstScheduledRoot; - null !== root; - - ) { - var remainingExpirationTime = root.expirationTime; - if (0 === remainingExpirationTime) { - invariant( - null !== previousScheduledRoot && null !== lastScheduledRoot, - "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." - ); - if (root === root.nextScheduledRoot) { - firstScheduledRoot = lastScheduledRoot = root.nextScheduledRoot = null; - break; - } else if (root === firstScheduledRoot) - (firstScheduledRoot = remainingExpirationTime = - root.nextScheduledRoot), - (lastScheduledRoot.nextScheduledRoot = remainingExpirationTime), - (root.nextScheduledRoot = null); - else if (root === lastScheduledRoot) { - lastScheduledRoot = previousScheduledRoot; - lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; - root.nextScheduledRoot = null; - break; - } else - (previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot), - (root.nextScheduledRoot = null); - root = previousScheduledRoot.nextScheduledRoot; - } else { - remainingExpirationTime > highestPriorityWork && - ((highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root)); - if (root === lastScheduledRoot) break; - if (1073741823 === highestPriorityWork) break; - previousScheduledRoot = root; - root = root.nextScheduledRoot; - } - } - nextFlushedRoot = highestPriorityRoot; - nextFlushedExpirationTime = highestPriorityWork; -} -function performAsyncWork(didTimeout) { - if (didTimeout && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - didTimeout = firstScheduledRoot; - do { - var expirationTime = didTimeout.expirationTime; - 0 !== expirationTime && - currentRendererTime <= expirationTime && - (didTimeout.nextExpirationTimeToWorkOn = currentRendererTime); - didTimeout = didTimeout.nextScheduledRoot; - } while (didTimeout !== firstScheduledRoot); - } - performWork(0, !0); -} -function performWork(minExpirationTime, isYieldy) { - findHighestPriorityRoot(); - if (isYieldy) - for ( - recomputeCurrentRendererTime(), - currentSchedulerTime = currentRendererTime; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !( - frameDeadline <= now$1() && - currentRendererTime > nextFlushedExpirationTime - ); - - ) - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ), - findHighestPriorityRoot(), - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - else - for ( - ; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; - - ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), - findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); - 0 !== nextFlushedExpirationTime && - scheduleCallbackWithExpirationTime( - nextFlushedRoot, - nextFlushedExpirationTime - ); - nestedUpdateCount = 0; - lastCommittedRootDuringThisBatch = null; - if (null !== completedBatches) - for ( - minExpirationTime = completedBatches, - completedBatches = null, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ - ) { - var batch = minExpirationTime[isYieldy]; - try { - batch._onComplete(); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - } - if (hasUnhandledError) - throw ((minExpirationTime = unhandledError), - (unhandledError = null), - (hasUnhandledError = !1), - minExpirationTime); -} -function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - isRendering = !0; - if (isYieldy) { - var _finishedWork = root.finishedWork; - null !== _finishedWork - ? completeRoot$1(root, _finishedWork, expirationTime) - : ((root.finishedWork = null), - (_finishedWork = root.timeoutHandle), - -1 !== _finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), - renderRoot(root, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - (frameDeadline <= now$1() - ? (root.finishedWork = _finishedWork) - : completeRoot$1(root, _finishedWork, expirationTime))); - } else - (_finishedWork = root.finishedWork), - null !== _finishedWork - ? completeRoot$1(root, _finishedWork, expirationTime) - : ((root.finishedWork = null), - (_finishedWork = root.timeoutHandle), - -1 !== _finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), - renderRoot(root, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - completeRoot$1(root, _finishedWork, expirationTime)); - isRendering = !1; -} -function completeRoot$1(root, finishedWork, expirationTime) { - var firstBatch = root.firstBatch; - if ( - null !== firstBatch && - firstBatch._expirationTime >= expirationTime && - (null === completedBatches - ? (completedBatches = [firstBatch]) - : completedBatches.push(firstBatch), - firstBatch._defer) - ) { - root.finishedWork = finishedWork; - root.expirationTime = 0; - return; - } - root.finishedWork = null; - root === lastCommittedRootDuringThisBatch - ? nestedUpdateCount++ - : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); - } - ); -} -function onUncaughtError(error) { - invariant( - null !== nextFlushedRoot, - "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." - ); - nextFlushedRoot.expirationTime = 0; - hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); -} function findHostInstance(component) { var fiber = component._reactInternalFiber; - void 0 === fiber && - ("function" === typeof component.render - ? invariant(!1, "Unable to find node on an unmounted component.") - : invariant( - !1, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - )); + if (void 0 === fiber) { + if ("function" === typeof component.render) + throw ReactError("Unable to find node on an unmounted component."); + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } component = findCurrentHostFiber(fiber); return null === component ? null : component.stateNode; } @@ -6748,10 +6577,13 @@ function updateContainer(element, container, parentComponent, callback) { a: if (parentComponent) { parentComponent = parentComponent._reactInternalFiber; b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); + if ( + 2 !== isFiberMountedImpl(parentComponent) || + 1 !== parentComponent.tag + ) + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); var parentContext = parentComponent; do { switch (parentContext.tag) { @@ -6768,11 +6600,9 @@ function updateContainer(element, container, parentComponent, callback) { } parentContext = parentContext.return; } while (null !== parentContext); - invariant( - !1, + throw ReactError( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); - parentContext = void 0; } if (1 === parentComponent.tag) { var Component = parentComponent.type; @@ -6797,7 +6627,7 @@ function updateContainer(element, container, parentComponent, callback) { null !== container && (callback.callback = container); flushPassiveEffects(); enqueueUpdate(currentTime, callback); - scheduleWork(currentTime, current$$1); + scheduleUpdateOnFiber(currentTime, current$$1); return current$$1; } function createPortal(children, containerInfo, implementation) { @@ -6832,7 +6662,9 @@ function _inherits(subClass, superClass) { } var getInspectorDataForViewTag = void 0; getInspectorDataForViewTag = function() { - invariant(!1, "getInspectorDataForViewTag() is not available in production"); + throw ReactError( + "getInspectorDataForViewTag() is not available in production" + ); }; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -6848,21 +6680,18 @@ function findNodeHandle(componentOrHandle) { : componentOrHandle._nativeTag; } _batchedUpdatesImpl = function(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; + if (0 !== workPhase) return fn(a); + workPhase = 1; try { return fn(a); } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1073741823, !1); + (workPhase = 0), flushImmediateQueue(); } }; _flushInteractiveUpdatesImpl = function() { - isRendering || - 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), - (lowestPriorityPendingInteractiveExpirationTime = 0)); + workPhase !== RenderPhase && + workPhase !== CommitPhase && + flushPendingDiscreteUpdates(); }; var roots = new Map(), ReactFabric = { @@ -6889,35 +6718,67 @@ var roots = new Map(), TextInputState.focusTextInput(findNodeHandle(this)); }; ReactNativeComponent.prototype.measure = function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureLayout = function( relativeToNativeNode, onSuccess, onFail ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { + if (null != maybeInstance && !maybeInstance.canonical) { var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; maybeInstance = @@ -6940,48 +6801,14 @@ var roots = new Map(), })(React.Component); })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, - setNativeProps: function(handle, nativeProps) { - null != handle._nativeTag && - ((nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - handle.viewConfig.validAttributes - )), - null != nativeProps && - UIManager.updateView( - handle._nativeTag, - handle.viewConfig.uiViewClassName, - nativeProps - )); - }, + setNativeProps: function() {}, render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = createFiber(3, null, null, 0); - var root$jscomp$0 = { - current: root, - containerInfo: containerTag, - pendingChildren: null, - pingCache: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: !1, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null - }; - root = root.stateNode = root$jscomp$0; + root = new FiberRootNode(containerTag, !1); + var uninitializedFiber = createFiber(3, null, null, 0); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -7015,31 +6842,63 @@ var roots = new Map(), NativeMethodsMixin: (function(findNodeHandle, findHostInstance) { return { measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }, setNativeProps: function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { + if (null != maybeInstance && !maybeInstance.canonical) { var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; maybeInstance = @@ -7072,7 +6931,10 @@ var roots = new Map(), var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: null, overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { fiber = findCurrentHostFiber(fiber); @@ -7089,7 +6951,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.8.3", + version: "16.8.6", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/oss/ReactFabric-profiling.js b/Libraries/Renderer/oss/ReactFabric-profiling.js index ab75b165f..74761df87 100644 --- a/Libraries/Renderer/oss/ReactFabric-profiling.js +++ b/Libraries/Renderer/oss/ReactFabric-profiling.js @@ -19,30 +19,93 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), FabricUIManager = require("FabricUIManager"), + Scheduler = require("scheduler"), tracing = require("scheduler/tracing"), - scheduler = require("scheduler"), ExceptionsManager = require("ExceptionsManager"); -function invariant(condition, format, a, b, c, d, e, f) { - if (!condition) { - condition = void 0; - if (void 0 === format) - condition = Error( - "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." - ); - else { - var args = [a, b, c, d, e, f], - argIndex = 0; - condition = Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - condition.name = "Invariant Violation"; - } - condition.framesToPop = 1; - throw condition; - } +function ReactError(message) { + message = Error(message); + message.name = "Invariant Violation"; + return message; } +var eventPluginOrder = null, + namesToPlugins = {}; +function recomputePluginOrdering() { + if (eventPluginOrder) + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName], + pluginIndex = eventPluginOrder.indexOf(pluginName); + if (!(-1 < pluginIndex)) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." + ); + if (!plugins[pluginIndex]) { + if (!pluginModule.extractEvents) + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); + plugins[pluginIndex] = pluginModule; + pluginIndex = pluginModule.eventTypes; + for (var eventName in pluginIndex) { + var JSCompiler_inline_result = void 0; + var dispatchConfig = pluginIndex[eventName], + pluginModule$jscomp$0 = pluginModule, + eventName$jscomp$0 = eventName; + if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName$jscomp$0 + + "`." + ); + eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + if (phasedRegistrationNames) { + for (JSCompiler_inline_result in phasedRegistrationNames) + phasedRegistrationNames.hasOwnProperty( + JSCompiler_inline_result + ) && + publishRegistrationName( + phasedRegistrationNames[JSCompiler_inline_result], + pluginModule$jscomp$0, + eventName$jscomp$0 + ); + JSCompiler_inline_result = !0; + } else + dispatchConfig.registrationName + ? (publishRegistrationName( + dispatchConfig.registrationName, + pluginModule$jscomp$0, + eventName$jscomp$0 + ), + (JSCompiler_inline_result = !0)) + : (JSCompiler_inline_result = !1); + if (!JSCompiler_inline_result) + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); + } + } + } +} +function publishRegistrationName(registrationName, pluginModule) { + if (registrationNameModules[registrationName]) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); + registrationNameModules[registrationName] = pluginModule; +} +var plugins = [], + eventNameDispatchConfigs = {}, + registrationNameModules = {}; function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -84,88 +147,13 @@ function invokeGuardedCallbackAndCatchFirstError( hasError = !1; caughtError = null; } else - invariant( - !1, + throw ReactError( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ), - (error = void 0); + ); hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); } } -var eventPluginOrder = null, - namesToPlugins = {}; -function recomputePluginOrdering() { - if (eventPluginOrder) - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName], - pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - -1 < pluginIndex, - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.", - pluginName - ); - if (!plugins[pluginIndex]) { - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.", - pluginName - ); - plugins[pluginIndex] = pluginModule; - pluginIndex = pluginModule.eventTypes; - for (var eventName in pluginIndex) { - var JSCompiler_inline_result = void 0; - var dispatchConfig = pluginIndex[eventName], - pluginModule$jscomp$0 = pluginModule, - eventName$jscomp$0 = eventName; - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0), - "EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.", - eventName$jscomp$0 - ); - eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - if (phasedRegistrationNames) { - for (JSCompiler_inline_result in phasedRegistrationNames) - phasedRegistrationNames.hasOwnProperty( - JSCompiler_inline_result - ) && - publishRegistrationName( - phasedRegistrationNames[JSCompiler_inline_result], - pluginModule$jscomp$0, - eventName$jscomp$0 - ); - JSCompiler_inline_result = !0; - } else - dispatchConfig.registrationName - ? (publishRegistrationName( - dispatchConfig.registrationName, - pluginModule$jscomp$0, - eventName$jscomp$0 - ), - (JSCompiler_inline_result = !0)) - : (JSCompiler_inline_result = !1); - invariant( - JSCompiler_inline_result, - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); - } - } - } -} -function publishRegistrationName(registrationName, pluginModule) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.", - registrationName - ); - registrationNameModules[registrationName] = pluginModule; -} -var plugins = [], - eventNameDispatchConfigs = {}, - registrationNameModules = {}, - getFiberCurrentPropsFromNode = null, +var getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; function executeDispatch(event, listener, inst) { @@ -177,10 +165,8 @@ function executeDispatch(event, listener, inst) { function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + if (Array.isArray(dispatchListener)) + throw ReactError("executeDirectDispatch(...): Invalid `event`."); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -191,10 +177,10 @@ function executeDirectDispatch(event) { return dispatchListener; } function accumulateInto(current, next) { - invariant( - null != next, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); if (null == current) return next; if (Array.isArray(current)) { if (Array.isArray(next)) return current.push.apply(current, next), current; @@ -228,10 +214,10 @@ function executeDispatchesAndReleaseTopLevel(e) { } var injection = { injectEventPluginOrder: function(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." - ); + if (eventPluginOrder) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); recomputePluginOrdering(); }, @@ -241,15 +227,19 @@ var injection = { for (pluginName in injectedNamesToPlugins) if (injectedNamesToPlugins.hasOwnProperty(pluginName)) { var pluginModule = injectedNamesToPlugins[pluginName]; - (namesToPlugins.hasOwnProperty(pluginName) && - namesToPlugins[pluginName] === pluginModule) || - (invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.", - pluginName - ), - (namesToPlugins[pluginName] = pluginModule), - (isOrderingDirty = !0)); + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + if (namesToPlugins[pluginName]) + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = !0; + } } isOrderingDirty && recomputePluginOrdering(); } @@ -285,12 +275,14 @@ function getListener(inst, registrationName) { inst = !1; } if (inst) return null; - invariant( - !listener || "function" === typeof listener, - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + if (listener && "function" !== typeof listener) + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); return listener; } function getParent(inst) { @@ -451,10 +443,10 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { return new this(dispatchConfig, targetInst, nativeEvent, nativeInst); } function releasePooledEvent(event) { - invariant( - event instanceof this, - "Trying to release an event instance into a pool of a different type." - ); + if (!(event instanceof this)) + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); event.destructor(); 10 > this.eventPool.length && this.eventPool.push(event); } @@ -489,7 +481,7 @@ function timestampForTouch(touch) { } function getTouchIdentifier(_ref) { _ref = _ref.identifier; - invariant(null != _ref, "Touch object is missing identifier."); + if (null == _ref) throw ReactError("Touch object is missing identifier."); return _ref; } function recordTouchStart(touch) { @@ -602,10 +594,10 @@ var ResponderTouchHistoryStore = { touchHistory: touchHistory }; function accumulate(current, next) { - invariant( - null != next, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulate(...): Accumulated items must not be null or undefined." + ); return null == current ? next : Array.isArray(current) @@ -970,11 +962,10 @@ var eventTypes$1 = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + if (!bubbleDispatchConfig && !directDispatchConfig) + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); topLevelType = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -1006,7 +997,7 @@ getFiberCurrentPropsFromNode = function(inst) { getInstanceFromNode = getInstanceFromInstance; getNodeFromInstance = function(inst) { inst = inst.stateNode.canonical._nativeTag; - invariant(inst, "All native instances should have a tag."); + if (!inst) throw ReactError("All native instances should have a tag."); return inst; }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ @@ -1037,8 +1028,11 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, - MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; +hasSymbol && Symbol.for("react.event_component"); +hasSymbol && Symbol.for("react.event_target"); +hasSymbol && Symbol.for("react.event_target.touch_hit"); +var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1096,80 +1090,83 @@ function isFiberMountedImpl(fiber) { return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { - invariant( - 2 === isFiberMountedImpl(fiber), - "Unable to find node on an unmounted component." - ); + if (2 !== isFiberMountedImpl(fiber)) + throw ReactError("Unable to find node on an unmounted component."); } function findCurrentFiberUsingSlowPath(fiber) { var alternate = fiber.alternate; - if (!alternate) - return ( - (alternate = isFiberMountedImpl(fiber)), - invariant( - 3 !== alternate, - "Unable to find node on an unmounted component." - ), - 1 === alternate ? null : fiber - ); + if (!alternate) { + alternate = isFiberMountedImpl(fiber); + if (3 === alternate) + throw ReactError("Unable to find node on an unmounted component."); + return 1 === alternate ? null : fiber; + } for (var a = fiber, b = alternate; ; ) { - var parentA = a.return, - parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) break; - if (parentA.child === parentB.child) { - for (var child = parentA.child; child; ) { - if (child === a) return assertIsMounted(parentA), fiber; - if (child === b) return assertIsMounted(parentA), alternate; - child = child.sibling; + var parentA = a.return; + if (null === parentA) break; + var parentB = parentA.alternate; + if (null === parentB) { + b = parentA.return; + if (null !== b) { + a = b; + continue; } - invariant(!1, "Unable to find node on an unmounted component."); + break; + } + if (parentA.child === parentB.child) { + for (parentB = parentA.child; parentB; ) { + if (parentB === a) return assertIsMounted(parentA), fiber; + if (parentB === b) return assertIsMounted(parentA), alternate; + parentB = parentB.sibling; + } + throw ReactError("Unable to find node on an unmounted component."); } if (a.return !== b.return) (a = parentA), (b = parentB); else { - child = !1; - for (var _child = parentA.child; _child; ) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentA; b = parentB; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentA; a = parentB; break; } _child = _child.sibling; } - if (!child) { + if (!didFindChild) { for (_child = parentB.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentB; b = parentA; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentB; a = parentA; break; } _child = _child.sibling; } - invariant( - child, - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." - ); + if (!didFindChild) + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." - ); + if (a.alternate !== b) + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + if (3 !== a.tag) + throw ReactError("Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { @@ -1417,37 +1414,13 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } -var now$1 = - "object" === typeof performance && "function" === typeof performance.now - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }, - scheduledCallback = null, - frameDeadline = 0; -function setTimeoutCallback() { - frameDeadline = now$1() + 5; - var callback = scheduledCallback; - scheduledCallback = null; - null !== callback && callback(); -} -function scheduleDeferredCallback$1(callback) { - scheduledCallback = callback; - return setTimeout(setTimeoutCallback, 1); -} var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { - if ((target = getInstanceFromNode(target))) { - invariant( - !1, + if (getInstanceFromNode(target)) + throw ReactError( "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." ); - var props = getFiberCurrentPropsFromNode(target.stateNode); - null(target.stateNode, target.type, props); - } } function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); @@ -1492,24 +1465,22 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - if ( - events && - (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ), - hasRethrowError) - ) - throw ((events = rethrowError), - (hasRethrowError = !1), - (rethrowError = null), - events); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasRethrowError) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); + } }); } function shim$1() { - invariant( - !1, + throw ReactError( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } @@ -1517,12 +1488,18 @@ var nextReactTag = 2; FabricUIManager.registerEventHandler && FabricUIManager.registerEventHandler(dispatchEvent); var ReactFabricHostComponent = (function() { - function ReactFabricHostComponent(tag, viewConfig, props) { + function ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ) { if (!(this instanceof ReactFabricHostComponent)) throw new TypeError("Cannot call a class as a function"); this._nativeTag = tag; this.viewConfig = viewConfig; this.currentProps = props; + this._internalInstanceHandle = internalInstanceHandle; } ReactFabricHostComponent.prototype.blur = function() { TextInputState.blurTextInput(this._nativeTag); @@ -1531,14 +1508,14 @@ var ReactFabricHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; ReactFabricHostComponent.prototype.measure = function(callback) { - UIManager.measure( - this._nativeTag, + FabricUIManager.measure( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactFabricHostComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - this._nativeTag, + FabricUIManager.measureInWindow( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -1547,27 +1524,16 @@ var ReactFabricHostComponent = (function() { onSuccess, onFail ) { - UIManager.measureLayout( - this._nativeTag, - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; - ReactFabricHostComponent.prototype.setNativeProps = function(nativeProps) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes - ); - null != nativeProps && - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps + "number" !== typeof relativeToNativeNode && + relativeToNativeNode instanceof ReactFabricHostComponent && + FabricUIManager.measureLayout( + this._internalInstanceHandle.stateNode.node, + relativeToNativeNode._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; + ReactFabricHostComponent.prototype.setNativeProps = function() {}; return ReactFabricHostComponent; })(); function createTextInstance( @@ -1576,10 +1542,10 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - invariant( - hostContext.isInAParentText, - "Text strings must be rendered within a component." - ); + if (!hostContext.isInAParentText) + throw ReactError( + "Text strings must be rendered within a component." + ); hostContext = nextReactTag; nextReactTag += 2; return { @@ -1607,18 +1573,6 @@ function cloneHiddenInstance(instance) { canonical: instance.canonical }; } -function cloneUnhiddenInstance(instance, type, props) { - var viewConfig = instance.canonical.viewConfig; - type = instance.node; - var prevProps = Object.assign({}, props, { - style: [props.style, { display: "none" }] - }); - props = diffProperties(null, prevProps, props, viewConfig.validAttributes); - return { - node: FabricUIManager.cloneNodeWithNewProps(type, props), - canonical: instance.canonical - }; -} var BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; @@ -1703,10 +1657,10 @@ function popTopLevelContextObject(fiber) { pop(contextStackCursor, fiber); } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." - ); + if (contextStackCursor.current !== emptyContextObject) + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } @@ -1716,12 +1670,13 @@ function processChildContext(fiber, type, parentContext) { if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) - invariant( - contextKey in fiber, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + if (!(contextKey in fiber)) + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { @@ -1740,10 +1695,10 @@ function pushContextProvider(workInProgress) { } function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." - ); + if (!instance) + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); didChange ? ((type = processChildContext(workInProgress, type, previousContext)), (instance.__reactInternalMemoizedMergedChildContext = type), @@ -1778,6 +1733,129 @@ function injectInternals(internals) { } catch (err) {} return !0; } +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, + Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, + Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, + Scheduler_shouldYield = Scheduler.unstable_shouldYield, + Scheduler_now = Scheduler.unstable_now, + Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel, + Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, + Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, + Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, + Scheduler_LowPriority = Scheduler.unstable_LowPriority, + Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; +if ( + null == tracing.__interactionsRef || + null == tracing.__interactionsRef.current +) + throw ReactError( + "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 http://fb.me/react-profiling" + ); +var fakeCallbackNode = {}, + immediateQueue = null, + immediateQueueCallbackNode = null, + isFlushingImmediate = !1, + initialTimeMs = Scheduler_now(), + now = + 1e4 > initialTimeMs + ? Scheduler_now + : function() { + return Scheduler_now() - initialTimeMs; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return 99; + case Scheduler_UserBlockingPriority: + return 98; + case Scheduler_NormalPriority: + return 97; + case Scheduler_LowPriority: + return 96; + case Scheduler_IdlePriority: + return 95; + default: + throw ReactError("Unknown priority level."); + } +} +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case 99: + return Scheduler_ImmediatePriority; + case 98: + return Scheduler_UserBlockingPriority; + case 97: + return Scheduler_NormalPriority; + case 96: + return Scheduler_LowPriority; + case 95: + return Scheduler_IdlePriority; + default: + throw ReactError("Unknown priority level."); + } +} +function runWithPriority(reactPriorityLevel, fn) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(reactPriorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + if (99 === reactPriorityLevel) + return ( + null === immediateQueue + ? ((immediateQueue = [callback]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueueImpl + ))) + : immediateQueue.push(callback), + fakeCallbackNode + ); + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); +} +function flushImmediateQueue() { + null !== immediateQueueCallbackNode && + Scheduler_cancelCallback(immediateQueueCallbackNode); + flushImmediateQueueImpl(); +} +function flushImmediateQueueImpl() { + if (!isFlushingImmediate && null !== immediateQueue) { + isFlushingImmediate = !0; + var i = 0; + try { + for (; i < immediateQueue.length; i++) { + var callback = immediateQueue[i]; + do callback = callback(!0); + while (null !== callback); + } + immediateQueue = null; + } catch (error) { + throw (null !== immediateQueue && + (immediateQueue = immediateQueue.slice(i + 1)), + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueue + ), + error); + } finally { + isFlushingImmediate = !1; + } + } +} +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (1073741823 === expirationTime) return 99; + if (1 === expirationTime) return 95; + currentTime = + 10 * (1073741822 - expirationTime) - 10 * (1073741822 - currentTime); + return 0 >= currentTime + ? 99 + : 250 >= currentTime + ? 98 + : 5250 >= currentTime + ? 97 + : 95; +} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -1908,11 +1986,10 @@ function createFiberFromTypeAndProps( owner = null; break a; } - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (null == type ? type : typeof type) + + "." ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -1954,105 +2031,20 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } -function markPendingPriorityLevel(root, expirationTime) { - root.didError = !1; - var earliestPendingTime = root.earliestPendingTime; - 0 === earliestPendingTime - ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime < expirationTime - ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime > expirationTime && - (root.latestPendingTime = expirationTime); - findNextExpirationTimeToWorkOn(expirationTime, root); -} -function markCommittedPriorityLevels(root, earliestRemainingTime) { - root.didError = !1; - if (0 === earliestRemainingTime) - (root.earliestPendingTime = 0), - (root.latestPendingTime = 0), - (root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0); - else { - earliestRemainingTime < root.latestPingedTime && - (root.latestPingedTime = 0); - var latestPendingTime = root.latestPendingTime; - 0 !== latestPendingTime && - (latestPendingTime > earliestRemainingTime - ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime > earliestRemainingTime && - (root.earliestPendingTime = root.latestPendingTime)); - latestPendingTime = root.earliestSuspendedTime; - 0 === latestPendingTime - ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime < root.latestSuspendedTime - ? ((root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0), - markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime > latestPendingTime && - markPendingPriorityLevel(root, earliestRemainingTime); - } - findNextExpirationTimeToWorkOn(0, root); -} -function hasLowerPriorityWork(root, erroredExpirationTime) { - var latestPendingTime = root.latestPendingTime, - latestSuspendedTime = root.latestSuspendedTime; - root = root.latestPingedTime; - return ( - (0 !== latestPendingTime && latestPendingTime < erroredExpirationTime) || - (0 !== latestSuspendedTime && - latestSuspendedTime < erroredExpirationTime) || - (0 !== root && root < erroredExpirationTime) - ); -} -function markSuspendedPriorityLevel(root, suspendedTime) { - root.didError = !1; - root.latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); - var earliestPendingTime = root.earliestPendingTime, - latestPendingTime = root.latestPendingTime; - earliestPendingTime === suspendedTime - ? (root.earliestPendingTime = - latestPendingTime === suspendedTime - ? (root.latestPendingTime = 0) - : latestPendingTime) - : latestPendingTime === suspendedTime && - (root.latestPendingTime = earliestPendingTime); - earliestPendingTime = root.earliestSuspendedTime; - latestPendingTime = root.latestSuspendedTime; - 0 === earliestPendingTime - ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : earliestPendingTime < suspendedTime - ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime > suspendedTime && - (root.latestSuspendedTime = suspendedTime); - findNextExpirationTimeToWorkOn(suspendedTime, root); -} -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestPendingTime = root.earliestPendingTime; - root = root.earliestSuspendedTime; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); - return renderExpirationTime; -} -function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { - var earliestSuspendedTime = root.earliestSuspendedTime, - latestSuspendedTime = root.latestSuspendedTime, - earliestPendingTime = root.earliestPendingTime, - latestPingedTime = root.latestPingedTime; - earliestPendingTime = - 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; - 0 === earliestPendingTime && - (0 === completedExpirationTime || - latestSuspendedTime < completedExpirationTime) && - (earliestPendingTime = latestSuspendedTime); - completedExpirationTime = earliestPendingTime; - 0 !== completedExpirationTime && - earliestSuspendedTime > completedExpirationTime && - (completedExpirationTime = earliestSuspendedTime); - root.nextExpirationTimeToWorkOn = earliestPendingTime; - root.expirationTime = completedExpirationTime; +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pingCache = this.pendingChildren = null; + this.pendingCommitExpirationTime = 0; + this.finishedWork = null; + this.timeoutHandle = -1; + this.pendingContext = this.context = null; + this.hydrate = hydrate; + this.callbackNode = this.firstBatch = null; + this.pingTime = this.lastPendingTime = this.firstPendingTime = this.callbackExpirationTime = 0; + this.interactionThreadID = tracing.unstable_getThreadID(); + this.memoizedInteractions = new Set(); + this.pendingInteractionMap = new Map(); } function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); @@ -2123,6 +2115,285 @@ function readLazyComponentType(lazyComponent) { throw result; } } +var valueCursor = { current: null }, + currentlyRenderingFiber = null, + lastContextDependency = null, + lastContextWithAllBitsObserved = null; +function resetContextDependences() { + lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; +} +function pushProvider(providerFiber, nextValue) { + var context = providerFiber.type._context; + push(valueCursor, context._currentValue2, providerFiber); + context._currentValue2 = nextValue; +} +function popProvider(providerFiber) { + var currentValue = valueCursor.current; + pop(valueCursor, providerFiber); + providerFiber.type._context._currentValue2 = currentValue; +} +function prepareToReadContext(workInProgress, renderExpirationTime) { + currentlyRenderingFiber = workInProgress; + lastContextWithAllBitsObserved = lastContextDependency = null; + var currentDependencies = workInProgress.contextDependencies; + null !== currentDependencies && + currentDependencies.expirationTime >= renderExpirationTime && + (didReceiveUpdate = !0); + workInProgress.contextDependencies = null; +} +function readContext(context, observedBits) { + if ( + lastContextWithAllBitsObserved !== context && + !1 !== observedBits && + 0 !== observedBits + ) { + if ("number" !== typeof observedBits || 1073741823 === observedBits) + (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); + observedBits = { context: context, observedBits: observedBits, next: null }; + if (null === lastContextDependency) { + if (null === currentlyRenderingFiber) + throw ReactError( + "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()." + ); + lastContextDependency = observedBits; + currentlyRenderingFiber.contextDependencies = { + first: observedBits, + expirationTime: 0 + }; + } else lastContextDependency = lastContextDependency.next = observedBits; + } + return context._currentValue2; +} +var hasForceUpdate = !1; +function createUpdateQueue(baseState) { + return { + baseState: baseState, + firstUpdate: null, + lastUpdate: null, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; +} +function cloneUpdateQueue(currentQueue) { + return { + baseState: currentQueue.baseState, + firstUpdate: currentQueue.firstUpdate, + lastUpdate: currentQueue.lastUpdate, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; +} +function createUpdate(expirationTime) { + return { + expirationTime: expirationTime, + tag: 0, + payload: null, + callback: null, + next: null, + nextEffect: null + }; +} +function appendUpdateToQueue(queue, update) { + null === queue.lastUpdate + ? (queue.firstUpdate = queue.lastUpdate = update) + : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); +} +function enqueueUpdate(fiber, update) { + var alternate = fiber.alternate; + if (null === alternate) { + var queue1 = fiber.updateQueue; + var queue2 = null; + null === queue1 && + (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); + } else + (queue1 = fiber.updateQueue), + (queue2 = alternate.updateQueue), + null === queue1 + ? null === queue2 + ? ((queue1 = fiber.updateQueue = createUpdateQueue( + fiber.memoizedState + )), + (queue2 = alternate.updateQueue = createUpdateQueue( + alternate.memoizedState + ))) + : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) + : null === queue2 && + (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); + null === queue2 || queue1 === queue2 + ? appendUpdateToQueue(queue1, update) + : null === queue1.lastUpdate || null === queue2.lastUpdate + ? (appendUpdateToQueue(queue1, update), + appendUpdateToQueue(queue2, update)) + : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); +} +function enqueueCapturedUpdate(workInProgress, update) { + var workInProgressQueue = workInProgress.updateQueue; + workInProgressQueue = + null === workInProgressQueue + ? (workInProgress.updateQueue = createUpdateQueue( + workInProgress.memoizedState + )) + : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); + null === workInProgressQueue.lastCapturedUpdate + ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) + : ((workInProgressQueue.lastCapturedUpdate.next = update), + (workInProgressQueue.lastCapturedUpdate = update)); +} +function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { + var current = workInProgress.alternate; + null !== current && + queue === current.updateQueue && + (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); + return queue; +} +function getStateFromUpdate( + workInProgress, + queue, + update, + prevState, + nextProps, + instance +) { + switch (update.tag) { + case 1: + return ( + (workInProgress = update.payload), + "function" === typeof workInProgress + ? workInProgress.call(instance, prevState, nextProps) + : workInProgress + ); + case 3: + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; + case 0: + workInProgress = update.payload; + nextProps = + "function" === typeof workInProgress + ? workInProgress.call(instance, prevState, nextProps) + : workInProgress; + if (null === nextProps || void 0 === nextProps) break; + return Object.assign({}, prevState, nextProps); + case 2: + hasForceUpdate = !0; + } + return prevState; +} +function processUpdateQueue( + workInProgress, + queue, + props, + instance, + renderExpirationTime +) { + hasForceUpdate = !1; + queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); + for ( + var newBaseState = queue.baseState, + newFirstUpdate = null, + newExpirationTime = 0, + update = queue.firstUpdate, + resultState = newBaseState; + null !== update; + + ) { + var updateExpirationTime = update.expirationTime; + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && + ((newFirstUpdate = update), (newBaseState = resultState)), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : (updateExpirationTime < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = updateExpirationTime), + (resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), + null !== update.callback && + ((workInProgress.effectTag |= 32), + (update.nextEffect = null), + null === queue.lastEffect + ? (queue.firstEffect = queue.lastEffect = update) + : ((queue.lastEffect.nextEffect = update), + (queue.lastEffect = update)))); + update = update.next; + } + updateExpirationTime = null; + for (update = queue.firstCapturedUpdate; null !== update; ) { + var _updateExpirationTime = update.expirationTime; + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && + ((updateExpirationTime = update), + null === newFirstUpdate && (newBaseState = resultState)), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), + null !== update.callback && + ((workInProgress.effectTag |= 32), + (update.nextEffect = null), + null === queue.lastCapturedEffect + ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) + : ((queue.lastCapturedEffect.nextEffect = update), + (queue.lastCapturedEffect = update)))); + update = update.next; + } + null === newFirstUpdate && (queue.lastUpdate = null); + null === updateExpirationTime + ? (queue.lastCapturedUpdate = null) + : (workInProgress.effectTag |= 32); + null === newFirstUpdate && + null === updateExpirationTime && + (newBaseState = resultState); + queue.baseState = newBaseState; + queue.firstUpdate = newFirstUpdate; + queue.firstCapturedUpdate = updateExpirationTime; + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = resultState; +} +function commitUpdateQueue(finishedWork, finishedQueue, instance) { + null !== finishedQueue.firstCapturedUpdate && + (null !== finishedQueue.lastUpdate && + ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), + (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), + (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} +function commitUpdateEffects(effect, instance) { + for (; null !== effect; ) { + var _callback3 = effect.callback; + if (null !== _callback3) { + effect.callback = null; + var context = instance; + if ("function" !== typeof _callback3) + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + _callback3 + ); + _callback3.call(context); + } + effect = effect.nextEffect; + } +} var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, @@ -2157,30 +2428,30 @@ var classComponentUpdater = { void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternalFiber; var currentTime = requestCurrentTime(); currentTime = computeExpirationForFiber(currentTime, inst); var update = createUpdate(currentTime); - update.tag = ReplaceState; + update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternalFiber; var currentTime = requestCurrentTime(); currentTime = computeExpirationForFiber(currentTime, inst); var update = createUpdate(currentTime); - update.tag = ForceUpdate; + update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2305,17 +2576,19 @@ function coerceRef(returnFiber, current$$1, element) { if (element._owner) { element = element._owner; var inst = void 0; - element && - (invariant( - 1 === element.tag, - "Function components cannot have refs. Did you mean to use React.forwardRef()?" - ), - (inst = element.stateNode)); - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.", - returnFiber - ); + if (element) { + if (1 !== element.tag) + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + inst = element.stateNode; + } + if (!inst) + throw ReactError( + "Missing owner for string ref " + + returnFiber + + ". This error is likely caused by a bug in React. Please file an issue." + ); var stringRef = "" + returnFiber; if ( null !== current$$1 && @@ -2332,27 +2605,27 @@ function coerceRef(returnFiber, current$$1, element) { current$$1._stringRef = stringRef; return current$$1; } - invariant( - "string" === typeof returnFiber, - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) 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://fb.me/react-refs-must-have-owner for more information.", - returnFiber - ); + if ("string" !== typeof returnFiber) + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + if (!element._owner) + throw ReactError( + "Element ref was specified as a string (" + + returnFiber + + ") 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://fb.me/react-refs-must-have-owner for more information." + ); } return returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { - "textarea" !== returnFiber.type && - invariant( - !1, - "Objects are not valid as a React child (found: %s).%s", - "[object Object]" === Object.prototype.toString.call(newChild) - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - "" + if ("textarea" !== returnFiber.type) + throw ReactError( + "Objects are not valid as a React child (found: " + + ("[object Object]" === Object.prototype.toString.call(newChild) + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2696,18 +2969,21 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - if ( - (oldFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - )) - ) - (currentFirstChild = placeChild(oldFiber, currentFirstChild, newIdx)), + (oldFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + )), + null !== oldFiber && + ((currentFirstChild = placeChild( + oldFiber, + currentFirstChild, + newIdx + )), null === previousNewFiber ? (resultingFirstChild = oldFiber) : (previousNewFiber.sibling = oldFiber), - (previousNewFiber = oldFiber); + (previousNewFiber = oldFiber)); return resultingFirstChild; } for ( @@ -2715,20 +2991,19 @@ function ChildReconciler(shouldTrackSideEffects) { newIdx < newChildren.length; newIdx++ ) - if ( - (nextOldFiber = updateFromMap( - oldFiber, - returnFiber, - newIdx, - newChildren[newIdx], - expirationTime - )) - ) - shouldTrackSideEffects && - null !== nextOldFiber.alternate && - oldFiber.delete( - null === nextOldFiber.key ? newIdx : nextOldFiber.key - ), + (nextOldFiber = updateFromMap( + oldFiber, + returnFiber, + newIdx, + newChildren[newIdx], + expirationTime + )), + null !== nextOldFiber && + (shouldTrackSideEffects && + null !== nextOldFiber.alternate && + oldFiber.delete( + null === nextOldFiber.key ? newIdx : nextOldFiber.key + ), (currentFirstChild = placeChild( nextOldFiber, currentFirstChild, @@ -2737,7 +3012,7 @@ function ChildReconciler(shouldTrackSideEffects) { null === previousNewFiber ? (resultingFirstChild = nextOldFiber) : (previousNewFiber.sibling = nextOldFiber), - (previousNewFiber = nextOldFiber); + (previousNewFiber = nextOldFiber)); shouldTrackSideEffects && oldFiber.forEach(function(child) { return deleteChild(returnFiber, child); @@ -2751,15 +3026,13 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - "function" === typeof iteratorFn, - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." - ); + if ("function" !== typeof iteratorFn) + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); newChildrenIterable = iteratorFn.call(newChildrenIterable); - invariant( - null != newChildrenIterable, - "An iterable object provided no iterator." - ); + if (null == newChildrenIterable) + throw ReactError("An iterable object provided no iterator."); for ( var previousNewFiber = (iteratorFn = null), oldFiber = currentFirstChild, @@ -2779,7 +3052,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ); if (null === newFiber) { - oldFiber || (oldFiber = nextOldFiber); + null === oldFiber && (oldFiber = nextOldFiber); break; } shouldTrackSideEffects && @@ -2851,7 +3124,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) + if (isUnkeyedTopLevelFragment.key === isObject) { if ( 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE @@ -2876,14 +3149,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -2919,7 +3188,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== currentFirstChild; ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + if (currentFirstChild.key === isUnkeyedTopLevelFragment) { if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -2939,11 +3208,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren(returnFiber, currentFirstChild); - break; } - else deleteChild(returnFiber, currentFirstChild); + deleteRemainingChildren(returnFiber, currentFirstChild); + break; + } else deleteChild(returnFiber, currentFirstChild); currentFirstChild = currentFirstChild.sibling; } currentFirstChild = createFiberFromPortal( @@ -2997,12 +3265,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (returnFiber.tag) { case 1: case 0: - (expirationTime = returnFiber.type), - invariant( - !1, - "%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.", - expirationTime.displayName || expirationTime.name || "Component" - ); + throw ((returnFiber = returnFiber.type), + ReactError( + (returnFiber.displayName || returnFiber.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + )); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3014,10 +3281,10 @@ var reconcileChildFibers = ChildReconciler(!0), contextFiberStackCursor = { current: NO_CONTEXT }, rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." - ); + if (c === NO_CONTEXT) + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); return c; } function pushHostContainer(fiber, nextRootInstance) { @@ -3063,7 +3330,7 @@ var NoEffect$1 = 0, MountPassive = 64, UnmountPassive = 128, ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, - renderExpirationTime = 0, + renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, nextCurrentHook = null, @@ -3077,9 +3344,8 @@ var NoEffect$1 = 0, renderPhaseUpdates = null, numberOfReRenders = 0; function throwInvalidHookError() { - invariant( - !1, - "Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)" + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3096,7 +3362,7 @@ function renderWithHooks( refOrContext, nextRenderExpirationTime ) { - renderExpirationTime = nextRenderExpirationTime; + renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; nextCurrentHook = null !== current ? current.memoizedState : null; ReactCurrentDispatcher$1.current = @@ -3122,20 +3388,20 @@ function renderWithHooks( current.updateQueue = componentUpdateQueue; current.effectTag |= sideEffectTag; current = null !== currentHook && null !== currentHook.next; - renderExpirationTime = 0; + renderExpirationTime$1 = 0; nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; remainingExpirationTime = 0; componentUpdateQueue = null; sideEffectTag = 0; - invariant( - !current, - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." - ); + if (current) + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); return workInProgress; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - renderExpirationTime = 0; + renderExpirationTime$1 = 0; nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; remainingExpirationTime = 0; componentUpdateQueue = null; @@ -3164,10 +3430,8 @@ function updateWorkInProgressHook() { (currentHook = nextCurrentHook), (nextCurrentHook = null !== currentHook ? currentHook.next : null); else { - invariant( - null !== nextCurrentHook, - "Rendered more hooks than during the previous render." - ); + if (null === nextCurrentHook) + throw ReactError("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; var newHook = { memoizedState: currentHook.memoizedState, @@ -3190,10 +3454,11 @@ function basicStateReducer(state, action) { function updateReducer(reducer) { var hook = updateWorkInProgressHook(), queue = hook.queue; - invariant( - null !== queue, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + if (null === queue) + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + queue.lastRenderedReducer = reducer; if (0 < numberOfReRenders) { var _dispatch = queue.dispatch; if (null !== renderPhaseUpdates) { @@ -3208,8 +3473,7 @@ function updateReducer(reducer) { is(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; hook.baseUpdate === queue.last && (hook.baseState = newState); - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; return [newState, _dispatch]; } } @@ -3228,17 +3492,19 @@ function updateReducer(reducer) { didSkip = !1; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime + updateExpirationTime < renderExpirationTime$1 ? (didSkip || ((didSkip = !0), (newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)), updateExpirationTime > remainingExpirationTime && (remainingExpirationTime = updateExpirationTime)) - : (newState = + : (updateExpirationTime < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = updateExpirationTime), + (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action)); + : reducer(newState, _update.action))); baseUpdate = _update; _update = _update.next; } while (null !== _update && _update !== _dispatch); @@ -3248,8 +3514,7 @@ function updateReducer(reducer) { hook.memoizedState = newState; hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; } @@ -3312,10 +3577,10 @@ function imperativeHandleEffect(create, ref) { } function mountDebugValue() {} function dispatchAction(fiber, queue, action) { - invariant( - 25 > numberOfReRenders, - "Too many re-renders. React limits the number of renders to prevent an infinite loop." - ); + if (!(25 > numberOfReRenders)) + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); var alternate = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3324,7 +3589,7 @@ function dispatchAction(fiber, queue, action) { if ( ((didScheduleRenderPhaseUpdate = !0), (fiber = { - expirationTime: renderExpirationTime, + expirationTime: renderExpirationTime$1, action: action, eagerReducer: null, eagerState: null, @@ -3361,10 +3626,10 @@ function dispatchAction(fiber, queue, action) { if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && - ((alternate = queue.eagerReducer), null !== alternate) + ((alternate = queue.lastRenderedReducer), null !== alternate) ) try { - var currentState = queue.eagerState, + var currentState = queue.lastRenderedState, _eagerState = alternate(currentState, action); _update2.eagerReducer = alternate; _update2.eagerState = _eagerState; @@ -3372,7 +3637,7 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleUpdateOnFiber(fiber, currentTime); } } var ContextOnlyDispatcher = { @@ -3427,8 +3692,8 @@ var ContextOnlyDispatcher = { reducer = hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialArg + lastRenderedReducer: reducer, + lastRenderedState: initialArg }; reducer = reducer.dispatch = dispatchAction.bind( null, @@ -3449,8 +3714,8 @@ var ContextOnlyDispatcher = { initialState = hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }; initialState = initialState.dispatch = dispatchAction.bind( null, @@ -3515,6 +3780,7 @@ var ContextOnlyDispatcher = { }, useDebugValue: mountDebugValue }, + now$1 = Scheduler.unstable_now, commitTime = 0, profilerStartTime = -1; function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { @@ -4080,7 +4346,10 @@ function updateSuspenseComponent( nextState = null; var nextDidTimeout = !1; } else - (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextState = { + fallbackExpirationTime: + null !== nextState ? nextState.fallbackExpirationTime : 0 + }), (nextDidTimeout = !0), (workInProgress.effectTag &= -65); if (null === current$$1) @@ -4210,10 +4479,8 @@ function bailoutOnAlreadyFinishedWork( (workInProgress.contextDependencies = current$$1.contextDependencies); profilerStartTime = -1; if (workInProgress.childExpirationTime < renderExpirationTime) return null; - invariant( - null === current$$1 || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + if (null !== current$$1 && workInProgress.child !== current$$1.child) + throw ReactError("Resuming work not yet implemented."); if (null !== workInProgress.child) { current$$1 = workInProgress.child; renderExpirationTime = createWorkInProgress( @@ -4238,7 +4505,1655 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime) { +var appendAllChildren = void 0, + updateHostContainer = void 0, + updateHostComponent$1 = void 0, + updateHostText$1 = void 0; +appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden +) { + for (var node = workInProgress.child; null !== node; ) { + if (5 === node.tag) { + var instance = node.stateNode; + needsVisibilityToggle && + isHidden && + (instance = cloneHiddenInstance( + instance, + node.type, + node.memoizedProps, + node + )); + FabricUIManager.appendChild(parent.node, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle && isHidden) + throw Error("Not yet implemented."); + FabricUIManager.appendChild(parent.node, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + 0 !== (node.effectTag & 4) && + (instance = null !== node.memoizedState) + ) { + var primaryChildParent = node.child; + if ( + null !== primaryChildParent && + (null !== primaryChildParent.child && + ((primaryChildParent.child.return = primaryChildParent), + appendAllChildren(parent, primaryChildParent, !0, instance)), + (instance = primaryChildParent.sibling), + null !== instance) + ) { + instance.return = node; + node = instance; + continue; + } + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +}; +function appendAllChildrenToContainer( + containerChildSet, + workInProgress, + needsVisibilityToggle, + isHidden +) { + for (var node = workInProgress.child; null !== node; ) { + if (5 === node.tag) { + var instance = node.stateNode; + needsVisibilityToggle && + isHidden && + (instance = cloneHiddenInstance( + instance, + node.type, + node.memoizedProps, + node + )); + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle && isHidden) + throw Error("Not yet implemented."); + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + 0 !== (node.effectTag & 4) && + (instance = null !== node.memoizedState) + ) { + var primaryChildParent = node.child; + if ( + null !== primaryChildParent && + (null !== primaryChildParent.child && + ((primaryChildParent.child.return = primaryChildParent), + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + !0, + instance + )), + (instance = primaryChildParent.sibling), + null !== instance) + ) { + instance.return = node; + node = instance; + continue; + } + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +} +updateHostContainer = function(workInProgress) { + var portalOrRoot = workInProgress.stateNode; + if (null !== workInProgress.firstEffect) { + var container = portalOrRoot.containerInfo, + newChildSet = FabricUIManager.createChildSet(container); + appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); + portalOrRoot.pendingChildren = newChildSet; + workInProgress.effectTag |= 4; + FabricUIManager.completeRoot(container, newChildSet); + } +}; +updateHostComponent$1 = function(current, workInProgress, type, newProps) { + type = current.stateNode; + var oldProps = current.memoizedProps; + if ((current = null === workInProgress.firstEffect) && oldProps === newProps) + workInProgress.stateNode = type; + else { + var recyclableInstance = workInProgress.stateNode; + requiredContext(contextStackCursor$1.current); + var updatePayload = null; + oldProps !== newProps && + ((oldProps = diffProperties( + null, + oldProps, + newProps, + recyclableInstance.canonical.viewConfig.validAttributes + )), + (recyclableInstance.canonical.currentProps = newProps), + (updatePayload = oldProps)); + current && null === updatePayload + ? (workInProgress.stateNode = type) + : ((newProps = updatePayload), + (recyclableInstance = type.node), + (type = { + node: current + ? null !== newProps + ? FabricUIManager.cloneNodeWithNewProps( + recyclableInstance, + newProps + ) + : FabricUIManager.cloneNode(recyclableInstance) + : null !== newProps + ? FabricUIManager.cloneNodeWithNewChildrenAndProps( + recyclableInstance, + newProps + ) + : FabricUIManager.cloneNodeWithNewChildren(recyclableInstance), + canonical: type.canonical + }), + (workInProgress.stateNode = type), + current + ? (workInProgress.effectTag |= 4) + : appendAllChildren(type, workInProgress, !1, !1)); + } +}; +updateHostText$1 = function(current, workInProgress, oldText, newText) { + oldText !== newText && + ((current = requiredContext(rootInstanceStackCursor.current)), + (oldText = requiredContext(contextStackCursor$1.current)), + (workInProgress.stateNode = createTextInstance( + newText, + current, + oldText, + workInProgress + )), + (workInProgress.effectTag |= 4)); +}; +function completeWork(current, workInProgress, renderExpirationTime) { + var newProps = workInProgress.pendingProps; + switch (workInProgress.tag) { + case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 1: + isContextProvider(workInProgress.type) && popContext(workInProgress); + break; + case 3: + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + newProps = workInProgress.stateNode; + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)); + if (null === current || null === current.child) + workInProgress.effectTag &= -3; + updateHostContainer(workInProgress); + break; + case 5: + popHostContext(workInProgress); + renderExpirationTime = requiredContext(rootInstanceStackCursor.current); + var type = workInProgress.type; + if (null !== current && null != workInProgress.stateNode) + updateHostComponent$1( + current, + workInProgress, + type, + newProps, + renderExpirationTime + ), + current.ref !== workInProgress.ref && + (workInProgress.effectTag |= 128); + else if (newProps) { + requiredContext(contextStackCursor$1.current); + current = nextReactTag; + nextReactTag += 2; + type = ReactNativeViewConfigRegistry.get(type); + var updatePayload = diffProperties( + null, + emptyObject, + newProps, + type.validAttributes + ); + renderExpirationTime = FabricUIManager.createNode( + current, + type.uiViewClassName, + renderExpirationTime, + updatePayload, + workInProgress + ); + current = new ReactFabricHostComponent( + current, + type, + newProps, + workInProgress + ); + current = { node: renderExpirationTime, canonical: current }; + appendAllChildren(current, workInProgress, !1, !1); + workInProgress.stateNode = current; + null !== workInProgress.ref && (workInProgress.effectTag |= 128); + } else if (null === workInProgress.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + if (current && null != workInProgress.stateNode) + updateHostText$1( + current, + workInProgress, + current.memoizedProps, + newProps + ); + else { + if ("string" !== typeof newProps && null === workInProgress.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + current = requiredContext(rootInstanceStackCursor.current); + renderExpirationTime = requiredContext(contextStackCursor$1.current); + workInProgress.stateNode = createTextInstance( + newProps, + current, + renderExpirationTime, + workInProgress + ); + } + break; + case 11: + break; + case 13: + newProps = workInProgress.memoizedState; + if (0 !== (workInProgress.effectTag & 64)) + return ( + (workInProgress.expirationTime = renderExpirationTime), workInProgress + ); + newProps = null !== newProps; + renderExpirationTime = !1; + null !== current && + ((type = current.memoizedState), + (renderExpirationTime = null !== type), + newProps || + null === type || + ((type = type.fallbackExpirationTime), + type < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = type), + (current = current.child.sibling), + null !== current && + ((type = workInProgress.firstEffect), + null !== type + ? ((workInProgress.firstEffect = current), + (current.nextEffect = type)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = current), + (current.nextEffect = null)), + (current.effectTag = 8)))); + newProps && + !renderExpirationTime && + 0 !== (workInProgress.mode & 1) && + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); + newProps && (workInProgress.effectTag |= 4); + break; + case 7: + break; + case 8: + break; + case 12: + break; + case 4: + popHostContainer(workInProgress); + updateHostContainer(workInProgress); + break; + case 10: + popProvider(workInProgress); + break; + case 9: + break; + case 14: + break; + case 17: + isContextProvider(workInProgress.type) && popContext(workInProgress); + break; + case 18: + break; + case 19: + break; + case 20: + break; + default: + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + return null; +} +function createCapturedValue(value, source) { + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; +} +function logCapturedError(capturedError) { + var componentStack = capturedError.componentStack, + error = capturedError.error; + if (error instanceof Error) { + capturedError = error.message; + var name = error.name; + try { + error.message = + (capturedError ? name + ": " + capturedError : name) + + "\n\nThis error is located at:" + + componentStack; + } catch (e) {} + } else + error = + "string" === typeof error + ? Error(error + "\n\nThis error is located at:" + componentStack) + : Error("Unspecified error at:" + componentStack); + ExceptionsManager.handleException(error, !1); +} +var PossiblyWeakSet$1 = "function" === typeof WeakSet ? WeakSet : Set; +function logError(boundary, errorInfo) { + var source = errorInfo.source, + stack = errorInfo.stack; + null === stack && + null !== source && + (stack = getStackByFiberInDevAndProd(source)); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 1 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); + try { + logCapturedError(errorInfo); + } catch (e) { + setTimeout(function() { + throw e; + }); + } +} +function safelyDetachRef(current$$1) { + var ref = current$$1.ref; + if (null !== ref) + if ("function" === typeof ref) + try { + ref(null); + } catch (refError) { + captureCommitPhaseError(current$$1, refError); + } + else ref.current = null; +} +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & unmountTag) !== NoEffect$1) { + var destroy = effect.destroy; + effect.destroy = void 0; + void 0 !== destroy && destroy(); + } + (effect.tag & mountTag) !== NoEffect$1 && + ((destroy = effect.create), (effect.destroy = destroy())); + effect = effect.next; + } while (effect !== finishedWork); + } +} +function commitWork(current$$1, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 14: + case 15: + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + case 12: + return; + case 13: + commitSuspenseComponent(finishedWork); + return; + } + switch (finishedWork.tag) { + case 1: + case 5: + case 6: + case 20: + case 19: + break; + case 3: + case 4: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } +} +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + null !== newState && + 0 === newState.fallbackExpirationTime && + (newState.fallbackExpirationTime = requestCurrentTime() - 500); + newState = finishedWork.updateQueue; + if (null !== newState) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + null === retryCache && + (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); + newState.forEach(function(thenable) { + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + ((retry = tracing.unstable_wrap(retry)), + retryCache.add(thenable), + thenable.then(retry, retry)); + }); + } +} +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime); + expirationTime.tag = 3; + expirationTime.payload = { element: null }; + var error = errorInfo.value; + expirationTime.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logError(fiber, errorInfo); + }; + return expirationTime; +} +function createClassErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime); + expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error$jscomp$0 = errorInfo.value; + expirationTime.payload = function() { + return getDerivedStateFromError(error$jscomp$0); + }; + } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (expirationTime.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this)); + var error = errorInfo.value, + stack = errorInfo.stack; + logError(fiber, errorInfo); + this.componentDidCatch(error, { + componentStack: null !== stack ? stack : "" + }); + }); + return expirationTime; +} +function unwindWork(workInProgress) { + switch (workInProgress.tag) { + case 1: + isContextProvider(workInProgress.type) && popContext(workInProgress); + var effectTag = workInProgress.effectTag; + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), + workInProgress) + : null; + case 3: + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw ReactError( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + workInProgress.effectTag = (effectTag & -2049) | 64; + return workInProgress; + case 5: + return popHostContext(workInProgress), null; + case 13: + return ( + (effectTag = workInProgress.effectTag), + effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), + workInProgress) + : null + ); + case 18: + return null; + case 4: + return popHostContainer(workInProgress), null; + case 10: + return popProvider(workInProgress), null; + case 19: + case 20: + return null; + default: + return null; + } +} +var ceil = Math.ceil, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, + LegacyUnbatchedPhase = 2, + RenderPhase = 4, + CommitPhase = 5, + RootIncomplete = 0, + RootErrored = 1, + RootSuspended = 2, + RootCompleted = 3, + workPhase = 0, + workInProgressRoot = null, + workInProgress = null, + renderExpirationTime = 0, + workInProgressRootExitStatus = RootIncomplete, + workInProgressRootMostRecentEventTime = 1073741823, + nextEffect = null, + hasUncaughtError = !1, + firstUncaughtError = null, + legacyErrorBoundariesThatAlreadyFailed = null, + rootDoesHavePassiveEffects = !1, + rootWithPendingPassiveEffects = null, + pendingPassiveEffectsExpirationTime = 0, + rootsWithPendingDiscreteUpdates = null, + nestedUpdateCount = 0, + rootWithNestedUpdates = null, + currentEventTime = 0; +function requestCurrentTime() { + return workPhase === RenderPhase || workPhase === CommitPhase + ? 1073741822 - ((now() / 10) | 0) + : 0 !== currentEventTime + ? currentEventTime + : (currentEventTime = 1073741822 - ((now() / 10) | 0)); +} +function computeExpirationForFiber(currentTime, fiber) { + if (0 === (fiber.mode & 1)) return 1073741823; + if (workPhase === RenderPhase) return renderExpirationTime; + switch (getCurrentPriorityLevel()) { + case 99: + currentTime = 1073741823; + break; + case 98: + currentTime = + 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); + break; + case 97: + case 96: + currentTime = + 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); + break; + case 95: + currentTime = 1; + break; + default: + throw ReactError("Expected a valid priority level"); + } + null !== workInProgressRoot && + currentTime === renderExpirationTime && + --currentTime; + return currentTime; +} +function scheduleUpdateOnFiber(fiber, expirationTime) { + if (50 < nestedUpdateCount) + throw ((nestedUpdateCount = 0), + (rootWithNestedUpdates = null), + ReactError( + "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." + )); + fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (null !== fiber) + if (((fiber.pingTime = 0), 1073741823 === expirationTime)) + if (workPhase === LegacyUnbatchedPhase) + for ( + expirationTime = renderRoot(fiber, 1073741823, !0); + null !== expirationTime; + + ) + expirationTime = expirationTime(!0); + else + scheduleCallbackForRoot(fiber, 99, 1073741823), + 0 === workPhase && flushImmediateQueue(); + else { + var priorityLevel = getCurrentPriorityLevel(); + if (98 === priorityLevel) + if (null === rootsWithPendingDiscreteUpdates) + rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]]); + else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(fiber); + (void 0 === lastDiscreteTime || lastDiscreteTime > expirationTime) && + rootsWithPendingDiscreteUpdates.set(fiber, expirationTime); + } + scheduleCallbackForRoot(fiber, priorityLevel, expirationTime); + } +} +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); + var alternate = fiber.alternate; + null !== alternate && + alternate.expirationTime < expirationTime && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); + null !== alternate && + alternate.childExpirationTime < expirationTime && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 3 === node.tag) { + root = node.stateNode; + break; + } + node = node.return; + } + null !== root && + (expirationTime > root.firstPendingTime && + (root.firstPendingTime = expirationTime), + (fiber = root.lastPendingTime), + 0 === fiber || expirationTime < fiber) && + (root.lastPendingTime = expirationTime); + return root; +} +function scheduleCallbackForRoot(root, priorityLevel, expirationTime) { + if (root.callbackExpirationTime < expirationTime) { + var existingCallbackNode = root.callbackNode; + null !== existingCallbackNode && + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); + root.callbackExpirationTime = expirationTime; + existingCallbackNode = null; + 1073741823 !== expirationTime && + 1 !== expirationTime && + ((existingCallbackNode = 10 * (1073741822 - expirationTime) - now()), + 5e3 < existingCallbackNode && (existingCallbackNode = 5e3), + (existingCallbackNode = { timeout: existingCallbackNode })); + root.callbackNode = scheduleCallback( + priorityLevel, + runRootCallback.bind( + null, + root, + renderRoot.bind(null, root, expirationTime) + ), + existingCallbackNode + ); + } + schedulePendingInteraction(root, expirationTime); +} +function runRootCallback(root, callback, isSync) { + var prevCallbackNode = root.callbackNode, + continuation = null; + try { + return ( + (continuation = callback(isSync)), + null !== continuation + ? runRootCallback.bind(null, root, continuation) + : null + ); + } finally { + null === continuation && + prevCallbackNode === root.callbackNode && + ((root.callbackNode = null), (root.callbackExpirationTime = 0)); + } +} +function resolveLocksOnRoot(root, expirationTime) { + var firstBatch = root.firstBatch; + return null !== firstBatch && + firstBatch._defer && + firstBatch._expirationTime >= expirationTime + ? ((root.finishedWork = root.current.alternate), + (root.pendingCommitExpirationTime = expirationTime), + scheduleCallback(97, function() { + firstBatch._onComplete(); + return null; + }), + !0) + : !1; +} +function flushPendingDiscreteUpdates() { + if (null !== rootsWithPendingDiscreteUpdates) { + var roots = rootsWithPendingDiscreteUpdates; + rootsWithPendingDiscreteUpdates = null; + roots.forEach(function(expirationTime, root) { + scheduleCallback(99, renderRoot.bind(null, root, expirationTime)); + }); + flushImmediateQueue(); + } +} +function prepareFreshStack(root, expirationTime) { + root.pendingCommitExpirationTime = 0; + var timeoutHandle = root.timeoutHandle; + -1 !== timeoutHandle && + ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); + if (null !== workInProgress) + for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) { + var interruptedWork = timeoutHandle; + switch (interruptedWork.tag) { + case 1: + var childContextTypes = interruptedWork.type.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork); + break; + case 3: + popHostContainer(interruptedWork); + popTopLevelContextObject(interruptedWork); + break; + case 5: + popHostContext(interruptedWork); + break; + case 4: + popHostContainer(interruptedWork); + break; + case 10: + popProvider(interruptedWork); + } + timeoutHandle = timeoutHandle.return; + } + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null, expirationTime); + renderExpirationTime = expirationTime; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootMostRecentEventTime = 1073741823; +} +function renderRoot(root$jscomp$0, expirationTime, isSync) { + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Should not already be working."); + if (root$jscomp$0.firstPendingTime < expirationTime) return null; + if (root$jscomp$0.pendingCommitExpirationTime === expirationTime) + return ( + (root$jscomp$0.pendingCommitExpirationTime = 0), + commitRoot.bind(null, root$jscomp$0, expirationTime) + ); + flushPassiveEffects(); + if ( + root$jscomp$0 !== workInProgressRoot || + expirationTime !== renderExpirationTime + ) + prepareFreshStack(root$jscomp$0, expirationTime), + startWorkOnPendingInteraction(root$jscomp$0, expirationTime); + if (null !== workInProgress) { + var prevWorkPhase = workPhase; + workPhase = RenderPhase; + var prevDispatcher = ReactCurrentDispatcher.current; + null === prevDispatcher && (prevDispatcher = ContextOnlyDispatcher); + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + var prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root$jscomp$0.memoizedInteractions; + if (isSync) { + if (1073741823 !== expirationTime) { + var currentTime = requestCurrentTime(); + if (currentTime < expirationTime) + return ( + (workPhase = prevWorkPhase), + resetContextDependences(), + (ReactCurrentDispatcher.current = prevDispatcher), + (tracing.__interactionsRef.current = prevInteractions), + renderRoot.bind(null, root$jscomp$0, currentTime) + ); + } + } else currentEventTime = 0; + do + try { + if (isSync) + for (; null !== workInProgress; ) + workInProgress = performUnitOfWork(workInProgress); + else + for (; null !== workInProgress && !Scheduler_shouldYield(); ) + workInProgress = performUnitOfWork(workInProgress); + break; + } catch (thrownValue) { + resetContextDependences(); + resetHooks(); + currentTime = workInProgress; + if (null === currentTime || null === currentTime.return) + throw (prepareFreshStack(root$jscomp$0, expirationTime), + (workPhase = prevWorkPhase), + thrownValue); + currentTime.mode & 4 && + stopProfilerTimerIfRunningAndRecordDelta(currentTime, !0); + a: { + var root = root$jscomp$0, + returnFiber = currentTime.return, + sourceFiber = currentTime, + value = thrownValue, + renderExpirationTime$jscomp$0 = renderExpirationTime; + sourceFiber.effectTag |= 1024; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; + if ( + null !== value && + "object" === typeof value && + "function" === typeof value.then + ) { + var thenable = value; + value = returnFiber; + do { + if ( + 13 === value.tag && + (void 0 === value.memoizedProps.fallback + ? 0 + : null === value.memoizedState) + ) { + returnFiber = value.updateQueue; + null === returnFiber + ? ((returnFiber = new Set()), + returnFiber.add(thenable), + (value.updateQueue = returnFiber)) + : returnFiber.add(thenable); + if (0 === (value.mode & 1)) { + value.effectTag |= 64; + sourceFiber.effectTag &= -1957; + 1 === sourceFiber.tag && + (null === sourceFiber.alternate + ? (sourceFiber.tag = 17) + : ((renderExpirationTime$jscomp$0 = createUpdate( + 1073741823 + )), + (renderExpirationTime$jscomp$0.tag = 2), + enqueueUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ))); + sourceFiber.expirationTime = 1073741823; + break a; + } + sourceFiber = root; + root = renderExpirationTime$jscomp$0; + var pingCache = sourceFiber.pingCache; + null === pingCache + ? ((pingCache = sourceFiber.pingCache = new PossiblyWeakMap()), + (returnFiber = new Set()), + pingCache.set(thenable, returnFiber)) + : ((returnFiber = pingCache.get(thenable)), + void 0 === returnFiber && + ((returnFiber = new Set()), + pingCache.set(thenable, returnFiber))); + returnFiber.has(root) || + (returnFiber.add(root), + (sourceFiber = pingSuspendedRoot.bind( + null, + sourceFiber, + thenable, + root + )), + (sourceFiber = tracing.unstable_wrap(sourceFiber)), + thenable.then(sourceFiber, sourceFiber)); + value.effectTag |= 2048; + value.expirationTime = renderExpirationTime$jscomp$0; + break a; + } + value = value.return; + } while (null !== value); + value = Error( + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) + ); + } + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) + workInProgressRootExitStatus = RootErrored; + value = createCapturedValue(value, sourceFiber); + sourceFiber = returnFiber; + do { + switch (sourceFiber.tag) { + case 3: + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime$jscomp$0; + renderExpirationTime$jscomp$0 = createRootErrorUpdate( + sourceFiber, + value, + renderExpirationTime$jscomp$0 + ); + enqueueCapturedUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ); + break a; + case 1: + if ( + ((thenable = value), + (root = sourceFiber.type), + (returnFiber = sourceFiber.stateNode), + 0 === (sourceFiber.effectTag & 64) && + ("function" === typeof root.getDerivedStateFromError || + (null !== returnFiber && + "function" === typeof returnFiber.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has( + returnFiber + ))))) + ) { + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime$jscomp$0; + renderExpirationTime$jscomp$0 = createClassErrorUpdate( + sourceFiber, + thenable, + renderExpirationTime$jscomp$0 + ); + enqueueCapturedUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ); + break a; + } + } + sourceFiber = sourceFiber.return; + } while (null !== sourceFiber); + } + workInProgress = completeUnitOfWork(currentTime); + } + while (1); + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher.current = prevDispatcher; + tracing.__interactionsRef.current = prevInteractions; + if (null !== workInProgress) + return renderRoot.bind(null, root$jscomp$0, expirationTime); + } + if (resolveLocksOnRoot(root$jscomp$0, expirationTime)) return null; + workInProgressRoot = null; + switch (workInProgressRootExitStatus) { + case RootIncomplete: + throw ReactError("Should have a work-in-progress."); + case RootErrored: + return ( + (prevWorkPhase = root$jscomp$0.lastPendingTime), + root$jscomp$0.lastPendingTime < expirationTime + ? renderRoot.bind(null, root$jscomp$0, prevWorkPhase) + : isSync + ? commitRoot.bind(null, root$jscomp$0, expirationTime) + : (prepareFreshStack(root$jscomp$0, expirationTime), + scheduleCallback( + 99, + renderRoot.bind(null, root$jscomp$0, expirationTime) + ), + null) + ); + case RootSuspended: + if (!isSync) { + isSync = root$jscomp$0.lastPendingTime; + if (root$jscomp$0.lastPendingTime < expirationTime) + return renderRoot.bind(null, root$jscomp$0, isSync); + if ( + 1073741823 !== workInProgressRootMostRecentEventTime && + ((prevWorkPhase = + 10 * (1073741822 - workInProgressRootMostRecentEventTime) - 5e3), + (isSync = now()), + (prevWorkPhase = isSync - prevWorkPhase), + (prevWorkPhase = + (120 > prevWorkPhase + ? 120 + : 480 > prevWorkPhase + ? 480 + : 1080 > prevWorkPhase + ? 1080 + : 1920 > prevWorkPhase + ? 1920 + : 3e3 > prevWorkPhase + ? 3e3 + : 4320 > prevWorkPhase + ? 4320 + : 1960 * ceil(prevWorkPhase / 1960)) - prevWorkPhase), + (isSync = 10 * (1073741822 - expirationTime) - isSync), + isSync < prevWorkPhase && (prevWorkPhase = isSync), + (isSync = prevWorkPhase), + 10 < isSync) + ) + return ( + (root$jscomp$0.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root$jscomp$0, expirationTime), + isSync + )), + null + ); + } + return commitRoot.bind(null, root$jscomp$0, expirationTime); + case RootCompleted: + return commitRoot.bind(null, root$jscomp$0, expirationTime); + default: + throw ReactError("Unknown root exit status."); + } +} +function performUnitOfWork(unitOfWork) { + var current$$1 = unitOfWork.alternate; + 0 !== (unitOfWork.mode & 4) + ? ((profilerStartTime = now$1()), + 0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()), + (current$$1 = beginWork$$1(current$$1, unitOfWork, renderExpirationTime)), + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0)) + : (current$$1 = beginWork$$1(current$$1, unitOfWork, renderExpirationTime)); + unitOfWork.memoizedProps = unitOfWork.pendingProps; + null === current$$1 && (current$$1 = completeUnitOfWork(unitOfWork)); + ReactCurrentOwner$2.current = null; + return current$$1; +} +function completeUnitOfWork(unitOfWork) { + workInProgress = unitOfWork; + do { + var current$$1 = workInProgress.alternate; + unitOfWork = workInProgress.return; + if (0 === (workInProgress.effectTag & 1024)) { + if (0 === (workInProgress.mode & 4)) + current$$1 = completeWork( + current$$1, + workInProgress, + renderExpirationTime + ); + else { + var fiber = workInProgress; + profilerStartTime = now$1(); + 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); + current$$1 = completeWork( + current$$1, + workInProgress, + renderExpirationTime + ); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + } + fiber = workInProgress; + if (1 === renderExpirationTime || 1 !== fiber.childExpirationTime) { + var newChildExpirationTime = 0; + if (0 !== (fiber.mode & 4)) { + for ( + var actualDuration = fiber.actualDuration, + treeBaseDuration = fiber.selfBaseDuration, + shouldBubbleActualDurations = + null === fiber.alternate || + fiber.child !== fiber.alternate.child, + child = fiber.child; + null !== child; + + ) { + var childUpdateExpirationTime = child.expirationTime, + childChildExpirationTime = child.childExpirationTime; + childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = childUpdateExpirationTime); + childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = childChildExpirationTime); + shouldBubbleActualDurations && + (actualDuration += child.actualDuration); + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + fiber.actualDuration = actualDuration; + fiber.treeBaseDuration = treeBaseDuration; + } else + for (actualDuration = fiber.child; null !== actualDuration; ) + (treeBaseDuration = actualDuration.expirationTime), + (shouldBubbleActualDurations = + actualDuration.childExpirationTime), + treeBaseDuration > newChildExpirationTime && + (newChildExpirationTime = treeBaseDuration), + shouldBubbleActualDurations > newChildExpirationTime && + (newChildExpirationTime = shouldBubbleActualDurations), + (actualDuration = actualDuration.sibling); + fiber.childExpirationTime = newChildExpirationTime; + } + if (null !== current$$1) return current$$1; + null !== unitOfWork && + 0 === (unitOfWork.effectTag & 1024) && + (null === unitOfWork.firstEffect && + (unitOfWork.firstEffect = workInProgress.firstEffect), + null !== workInProgress.lastEffect && + (null !== unitOfWork.lastEffect && + (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), + (unitOfWork.lastEffect = workInProgress.lastEffect)), + 1 < workInProgress.effectTag && + (null !== unitOfWork.lastEffect + ? (unitOfWork.lastEffect.nextEffect = workInProgress) + : (unitOfWork.firstEffect = workInProgress), + (unitOfWork.lastEffect = workInProgress))); + } else { + current$$1 = unwindWork(workInProgress, renderExpirationTime); + if (0 !== (workInProgress.mode & 4)) { + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + fiber = workInProgress.actualDuration; + for ( + newChildExpirationTime = workInProgress.child; + null !== newChildExpirationTime; + + ) + (fiber += newChildExpirationTime.actualDuration), + (newChildExpirationTime = newChildExpirationTime.sibling); + workInProgress.actualDuration = fiber; + } + if (null !== current$$1) + return (current$$1.effectTag &= 1023), current$$1; + null !== unitOfWork && + ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), + (unitOfWork.effectTag |= 1024)); + } + current$$1 = workInProgress.sibling; + if (null !== current$$1) return current$$1; + workInProgress = unitOfWork; + } while (null !== workInProgress); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootCompleted); + return null; +} +function commitRoot(root, expirationTime) { + runWithPriority(99, commitRootImpl.bind(null, root, expirationTime)); + null !== rootWithPendingPassiveEffects && + ((root = getCurrentPriorityLevel()), + scheduleCallback(root, function() { + flushPassiveEffects(); + return null; + })); + return null; +} +function commitRootImpl(root, expirationTime) { + flushPassiveEffects(); + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Should not already be working."); + var finishedWork = root.current.alternate; + if (null === finishedWork) + throw ReactError("Should have a work-in-progress root."); + root.callbackNode = null; + root.callbackExpirationTime = 0; + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, + childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + updateExpirationTimeBeforeCommit = + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit; + root.firstPendingTime = updateExpirationTimeBeforeCommit; + updateExpirationTimeBeforeCommit < root.lastPendingTime && + (root.lastPendingTime = updateExpirationTimeBeforeCommit); + root === workInProgressRoot && + ((workInProgress = workInProgressRoot = null), (renderExpirationTime = 0)); + if (1 < finishedWork.effectTag) + if (null !== finishedWork.lastEffect) { + finishedWork.lastEffect.nextEffect = finishedWork; + var firstEffect = finishedWork.firstEffect; + } else firstEffect = finishedWork; + else firstEffect = finishedWork.firstEffect; + if (null !== firstEffect) { + updateExpirationTimeBeforeCommit = workPhase; + workPhase = CommitPhase; + childExpirationTimeBeforeCommit = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + ReactCurrentOwner$2.current = null; + nextEffect = firstEffect; + do + try { + for (; null !== nextEffect; ) { + if (0 !== (nextEffect.effectTag & 256)) { + var current$$1 = nextEffect.alternate, + finishedWork$jscomp$0 = nextEffect; + switch (finishedWork$jscomp$0.tag) { + case 0: + case 11: + case 15: + commitHookEffectList( + UnmountSnapshot, + NoEffect$1, + finishedWork$jscomp$0 + ); + break; + case 1: + if ( + finishedWork$jscomp$0.effectTag & 256 && + null !== current$$1 + ) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState, + instance = finishedWork$jscomp$0.stateNode, + snapshot = instance.getSnapshotBeforeUpdate( + finishedWork$jscomp$0.elementType === + finishedWork$jscomp$0.type + ? prevProps + : resolveDefaultProps( + finishedWork$jscomp$0.type, + prevProps + ), + prevState + ); + instance.__reactInternalSnapshotBeforeUpdate = snapshot; + } + break; + case 3: + case 5: + case 6: + case 4: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + commitTime = now$1(); + nextEffect = firstEffect; + do + try { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 128) { + var current$$1$jscomp$0 = nextEffect.alternate; + if (null !== current$$1$jscomp$0) { + var currentRef = current$$1$jscomp$0.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (effectTag & 14) { + case 2: + nextEffect.effectTag &= -3; + break; + case 6: + nextEffect.effectTag &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + current$$1 = nextEffect; + a: for (prevState = prevProps = current$$1; ; ) { + instance = prevState; + "function" === typeof onCommitFiberUnmount && + onCommitFiberUnmount(instance); + switch (instance.tag) { + case 0: + case 11: + case 14: + case 15: + var updateQueue = instance.updateQueue; + if (null !== updateQueue) { + var lastEffect = updateQueue.lastEffect; + if (null !== lastEffect) { + var firstEffect$jscomp$0 = lastEffect.next; + snapshot = firstEffect$jscomp$0; + do { + var destroy = snapshot.destroy; + if (void 0 !== destroy) { + finishedWork$jscomp$0 = instance; + try { + destroy(); + } catch (error) { + captureCommitPhaseError( + finishedWork$jscomp$0, + error + ); + } + } + snapshot = snapshot.next; + } while (snapshot !== firstEffect$jscomp$0); + } + } + break; + case 1: + safelyDetachRef(instance); + var instance$jscomp$0 = instance.stateNode; + if ( + "function" === + typeof instance$jscomp$0.componentWillUnmount + ) + try { + (instance$jscomp$0.props = instance.memoizedProps), + (instance$jscomp$0.state = instance.memoizedState), + instance$jscomp$0.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(instance, unmountError); + } + break; + case 5: + safelyDetachRef(instance); + break; + case 4: + FabricUIManager.createChildSet( + instance.stateNode.containerInfo + ); + } + if (null !== prevState.child) + (prevState.child.return = prevState), + (prevState = prevState.child); + else { + if (prevState === prevProps) break; + for (; null === prevState.sibling; ) { + if ( + null === prevState.return || + prevState.return === prevProps + ) + break a; + prevState = prevState.return; + } + prevState.sibling.return = prevState.return; + prevState = prevState.sibling; + } + } + current$$1.return = null; + current$$1.child = null; + current$$1.memoizedState = null; + current$$1.updateQueue = null; + var alternate = current$$1.alternate; + null !== alternate && + ((alternate.return = null), + (alternate.child = null), + (alternate.memoizedState = null), + (alternate.updateQueue = null)); + } + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + root.current = finishedWork; + nextEffect = firstEffect; + do + try { + for ( + effectTag = root, current$$1$jscomp$0 = expirationTime; + null !== nextEffect; + + ) { + var effectTag$jscomp$0 = nextEffect.effectTag; + if (effectTag$jscomp$0 & 36) { + lastEffect = effectTag; + var current$$1$jscomp$1 = nextEffect.alternate; + currentRef = nextEffect; + updateQueue = current$$1$jscomp$0; + switch (currentRef.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(UnmountLayout, MountLayout, currentRef); + break; + case 1: + var instance$jscomp$1 = currentRef.stateNode; + if (currentRef.effectTag & 4) + if (null === current$$1$jscomp$1) + instance$jscomp$1.componentDidMount(); + else { + var prevProps$jscomp$0 = + currentRef.elementType === currentRef.type + ? current$$1$jscomp$1.memoizedProps + : resolveDefaultProps( + currentRef.type, + current$$1$jscomp$1.memoizedProps + ); + instance$jscomp$1.componentDidUpdate( + prevProps$jscomp$0, + current$$1$jscomp$1.memoizedState, + instance$jscomp$1.__reactInternalSnapshotBeforeUpdate + ); + } + var updateQueue$jscomp$0 = currentRef.updateQueue; + null !== updateQueue$jscomp$0 && + commitUpdateQueue( + currentRef, + updateQueue$jscomp$0, + instance$jscomp$1, + updateQueue + ); + break; + case 3: + var _updateQueue = currentRef.updateQueue; + if (null !== _updateQueue) { + lastEffect = null; + if (null !== currentRef.child) + switch (currentRef.child.tag) { + case 5: + lastEffect = currentRef.child.stateNode.canonical; + break; + case 1: + lastEffect = currentRef.child.stateNode; + } + commitUpdateQueue( + currentRef, + _updateQueue, + lastEffect, + updateQueue + ); + } + break; + case 5: + if (null === current$$1$jscomp$1 && currentRef.effectTag & 4) + throw ReactError( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + break; + case 4: + break; + case 12: + var onRender = currentRef.memoizedProps.onRender; + onRender( + currentRef.memoizedProps.id, + null === current$$1$jscomp$1 ? "mount" : "update", + currentRef.actualDuration, + currentRef.treeBaseDuration, + currentRef.actualStartTime, + commitTime, + lastEffect.memoizedInteractions + ); + break; + case 13: + case 17: + break; + case 20: + break; + case 19: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + if (effectTag$jscomp$0 & 128) { + var ref = nextEffect.ref; + if (null !== ref) { + var instance$jscomp$2 = nextEffect.stateNode; + switch (nextEffect.tag) { + case 5: + var instanceToUse = instance$jscomp$2.canonical; + break; + default: + instanceToUse = instance$jscomp$2; + } + "function" === typeof ref + ? ref(instanceToUse) + : (ref.current = instanceToUse); + } + } + effectTag$jscomp$0 & 512 && (rootDoesHavePassiveEffects = !0); + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + nextEffect = null; + tracing.__interactionsRef.current = childExpirationTimeBeforeCommit; + workPhase = updateExpirationTimeBeforeCommit; + } else (root.current = finishedWork), (commitTime = now$1()); + rootDoesHavePassiveEffects + ? ((rootDoesHavePassiveEffects = !1), + (rootWithPendingPassiveEffects = root), + (pendingPassiveEffectsExpirationTime = expirationTime)) + : finishPendingInteractions(root, expirationTime); + expirationTime = root.firstPendingTime; + 0 !== expirationTime + ? ((effectTag$jscomp$0 = requestCurrentTime()), + (effectTag$jscomp$0 = inferPriorityFromExpirationTime( + effectTag$jscomp$0, + expirationTime + )), + scheduleCallbackForRoot(root, effectTag$jscomp$0, expirationTime)) + : (legacyErrorBoundariesThatAlreadyFailed = null); + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode); + 1073741823 === expirationTime + ? root === rootWithNestedUpdates + ? nestedUpdateCount++ + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) + : (nestedUpdateCount = 0); + if (hasUncaughtError) + throw ((hasUncaughtError = !1), + (root = firstUncaughtError), + (firstUncaughtError = null), + root); + if (workPhase === LegacyUnbatchedPhase) return null; + flushImmediateQueue(); + return null; +} +function flushPassiveEffects() { + if (null === rootWithPendingPassiveEffects) return !1; + var root = rootWithPendingPassiveEffects, + expirationTime = pendingPassiveEffectsExpirationTime; + rootWithPendingPassiveEffects = null; + pendingPassiveEffectsExpirationTime = 0; + var prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Cannot flush passive effects while already rendering."); + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + for (var effect = root.current.firstEffect; null !== effect; ) { + try { + var finishedWork = effect; + commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); + commitHookEffectList(NoEffect$1, MountPassive, finishedWork); + } catch (error) { + if (null === effect) throw ReactError("Should be working on an effect."); + captureCommitPhaseError(effect, error); + } + effect = effect.nextEffect; + } + tracing.__interactionsRef.current = prevInteractions; + finishPendingInteractions(root, expirationTime); + workPhase = prevWorkPhase; + flushImmediateQueue(); + return !0; +} +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + sourceFiber = createCapturedValue(error, sourceFiber); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); + enqueueUpdate(rootFiber, sourceFiber); + rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); + null !== rootFiber && scheduleCallbackForRoot(rootFiber, 99, 1073741823); +} +function captureCommitPhaseError(sourceFiber, error) { + if (3 === sourceFiber.tag) + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + else + for (var fiber = sourceFiber.return; null !== fiber; ) { + if (3 === fiber.tag) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + break; + } else if (1 === fiber.tag) { + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(error, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); + null !== fiber && scheduleCallbackForRoot(fiber, 99, 1073741823); + break; + } + } + fiber = fiber.return; + } +} +function pingSuspendedRoot(root, thenable, suspendedTime) { + var pingCache = root.pingCache; + null !== pingCache && pingCache.delete(thenable); + workInProgressRoot === root && renderExpirationTime === suspendedTime + ? prepareFreshStack(root, renderExpirationTime) + : root.lastPendingTime < suspendedTime || + ((thenable = root.pingTime), + (0 !== thenable && thenable < suspendedTime) || + ((root.pingTime = suspendedTime), + (thenable = requestCurrentTime()), + (thenable = inferPriorityFromExpirationTime(thenable, suspendedTime)), + scheduleCallbackForRoot(root, thenable, suspendedTime))); +} +function resolveRetryThenable(boundaryFiber, thenable) { + var retryCache = boundaryFiber.stateNode; + null !== retryCache && retryCache.delete(thenable); + retryCache = requestCurrentTime(); + thenable = computeExpirationForFiber(retryCache, boundaryFiber); + retryCache = inferPriorityFromExpirationTime(retryCache, thenable); + boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); + null !== boundaryFiber && + scheduleCallbackForRoot(boundaryFiber, retryCache, thenable); +} +var beginWork$$1 = void 0; +beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if (null !== current$$1) if ( @@ -4381,59 +6296,57 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ((current$$1.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); - hasContext = workInProgress.pendingProps; - current$$1 = readLazyComponentType(context); - workInProgress.type = current$$1; - context = workInProgress.tag = resolveLazyComponentTag(current$$1); - hasContext = resolveDefaultProps(current$$1, hasContext); - getDerivedStateFromProps = void 0; - switch (context) { + current$$1 = workInProgress.pendingProps; + context = readLazyComponentType(context); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current$$1 = resolveDefaultProps(context, current$$1); + switch (hasContext) { case 0: - getDerivedStateFromProps = updateFunctionComponent( + workInProgress = updateFunctionComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 1: - getDerivedStateFromProps = updateClassComponent( + workInProgress = updateClassComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 11: - getDerivedStateFromProps = updateForwardRef( + workInProgress = updateForwardRef( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 14: - getDerivedStateFromProps = updateMemoComponent( + workInProgress = updateMemoComponent( null, workInProgress, - current$$1, - resolveDefaultProps(current$$1.type, hasContext), + context, + resolveDefaultProps(context.type, current$$1), updateExpirationTime, renderExpirationTime ); break; default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", - current$$1, - "" + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + context + + ". Lazy element type must resolve to a class or function." ); } - return getDerivedStateFromProps; + return workInProgress; case 0: return ( (updateExpirationTime = workInProgress.type), @@ -4467,38 +6380,36 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) ); case 3: - return ( - pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), - invariant( - null !== updateExpirationTime, + pushHostRootContext(workInProgress); + updateExpirationTime = workInProgress.updateQueue; + if (null === updateExpirationTime) + throw ReactError( "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." - ), - (context = workInProgress.memoizedState), - (context = null !== context ? context.element : null), - processUpdateQueue( - workInProgress, - updateExpirationTime, - workInProgress.pendingProps, - null, - renderExpirationTime - ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === context - ? (workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )) - : (reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child)), - workInProgress + ); + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; + processUpdateQueue( + workInProgress, + updateExpirationTime, + workInProgress.pendingProps, + null, + renderExpirationTime ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context + ? (workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + )) + : (reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child)); + return workInProgress; case 5: return ( pushHostContext(workInProgress), @@ -4511,8 +6422,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (workInProgress = workInProgress.child), - workInProgress + workInProgress.child ); case 6: return ( @@ -4640,7 +6550,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) { 1 === oldValue.tag && ((dependency = createUpdate(renderExpirationTime)), - (dependency.tag = ForceUpdate), + (dependency.tag = 2), enqueueUpdate(oldValue, dependency)); oldValue.expirationTime < renderExpirationTime && (oldValue.expirationTime = renderExpirationTime); @@ -4791,1271 +6701,61 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) ); } - invariant( - !1, + throw ReactError( "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); +}; +function schedulePendingInteraction(root, expirationTime) { + var interactions = tracing.__interactionsRef.current; + if (0 < interactions.size) { + var pendingInteractionMap = root.pendingInteractionMap, + pendingInteractions = pendingInteractionMap.get(expirationTime); + null != pendingInteractions + ? interactions.forEach(function(interaction) { + pendingInteractions.has(interaction) || interaction.__count++; + pendingInteractions.add(interaction); + }) + : (pendingInteractionMap.set(expirationTime, new Set(interactions)), + interactions.forEach(function(interaction) { + interaction.__count++; + })); + pendingInteractionMap = tracing.__subscriberRef.current; + if (null !== pendingInteractionMap) + pendingInteractionMap.onWorkScheduled( + interactions, + 1e3 * expirationTime + root.interactionThreadID + ); + } } -var valueCursor = { current: null }, - currentlyRenderingFiber = null, - lastContextDependency = null, - lastContextWithAllBitsObserved = null; -function pushProvider(providerFiber, nextValue) { - var context = providerFiber.type._context; - push(valueCursor, context._currentValue2, providerFiber); - context._currentValue2 = nextValue; -} -function popProvider(providerFiber) { - var currentValue = valueCursor.current; - pop(valueCursor, providerFiber); - providerFiber.type._context._currentValue2 = currentValue; -} -function prepareToReadContext(workInProgress, renderExpirationTime) { - currentlyRenderingFiber = workInProgress; - lastContextWithAllBitsObserved = lastContextDependency = null; - var currentDependencies = workInProgress.contextDependencies; - null !== currentDependencies && - currentDependencies.expirationTime >= renderExpirationTime && - (didReceiveUpdate = !0); - workInProgress.contextDependencies = null; -} -function readContext(context, observedBits) { - if ( - lastContextWithAllBitsObserved !== context && - !1 !== observedBits && - 0 !== observedBits +function startWorkOnPendingInteraction(root, expirationTime) { + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime ) { - if ("number" !== typeof observedBits || 1073741823 === observedBits) - (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); - observedBits = { context: context, observedBits: observedBits, next: null }; - null === lastContextDependency - ? (invariant( - null !== currentlyRenderingFiber, - "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()." - ), - (lastContextDependency = observedBits), - (currentlyRenderingFiber.contextDependencies = { - first: observedBits, - expirationTime: 0 - })) - : (lastContextDependency = lastContextDependency.next = observedBits); - } - return context._currentValue2; -} -var UpdateState = 0, - ReplaceState = 1, - ForceUpdate = 2, - CaptureUpdate = 3, - hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; -} -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; -} -function createUpdate(expirationTime) { - return { - expirationTime: expirationTime, - tag: UpdateState, - payload: null, - callback: null, - next: null, - nextEffect: null - }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); -} -function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); -} -function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case ReplaceState: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case CaptureUpdate: - workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; - case UpdateState: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case ForceUpdate: - hasForceUpdate = !0; - } - return prevState; -} -function processUpdateQueue( - workInProgress, - queue, - props, - instance, - renderExpirationTime -) { - hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; - } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; - } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; -} -function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var _callback3 = effect.callback; - if (null !== _callback3) { - effect.callback = null; - var context = instance; - invariant( - "function" === typeof _callback3, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - _callback3 - ); - _callback3.call(context); - } - effect = effect.nextEffect; - } -} -function createCapturedValue(value, source) { - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; -} -var appendAllChildren = void 0, - updateHostContainer = void 0, - updateHostComponent$1 = void 0, - updateHostText$1 = void 0; -appendAllChildren = function( - parent, - workInProgress, - needsVisibilityToggle, - isHidden -) { - for (var node = workInProgress.child; null !== node; ) { - a: if (5 === node.tag) { - var instance = node.stateNode; - if (needsVisibilityToggle) { - var props = node.memoizedProps, - type = node.type; - instance = isHidden - ? cloneHiddenInstance(instance, type, props, node) - : cloneUnhiddenInstance(instance, type, props, node); - node.stateNode = instance; - } - FabricUIManager.appendChild(parent.node, instance.node); - } else if (6 === node.tag) { - instance = node.stateNode; - if (needsVisibilityToggle) { - instance = node.memoizedProps; - props = requiredContext(rootInstanceStackCursor.current); - type = requiredContext(contextStackCursor$1.current); - if (isHidden) throw Error("Not yet implemented."); - instance = createTextInstance(instance, props, type, workInProgress); - node.stateNode = instance; - } - FabricUIManager.appendChild(parent.node, instance.node); - } else if (4 !== node.tag) { - if ( - 13 === node.tag && - ((props = node.alternate), - null !== props && - ((instance = null !== node.memoizedState), - (null !== props.memoizedState) !== instance)) - ) { - props = instance ? node.child : node; - null !== props && appendAllChildren(parent, props, !0, instance); - break a; - } - if (null !== node.child) { - node.child.return = node; - node = node.child; - continue; - } - } - if (node === workInProgress) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === workInProgress) return; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } -}; -function appendAllChildrenToContainer( - containerChildSet, - workInProgress, - needsVisibilityToggle, - isHidden -) { - for (var node = workInProgress.child; null !== node; ) { - a: if (5 === node.tag) { - var instance = node.stateNode; - if (needsVisibilityToggle) { - var props = node.memoizedProps, - type = node.type; - instance = isHidden - ? cloneHiddenInstance(instance, type, props, node) - : cloneUnhiddenInstance(instance, type, props, node); - node.stateNode = instance; - } - FabricUIManager.appendChildToSet(containerChildSet, instance.node); - } else if (6 === node.tag) { - instance = node.stateNode; - if (needsVisibilityToggle) { - instance = node.memoizedProps; - props = requiredContext(rootInstanceStackCursor.current); - type = requiredContext(contextStackCursor$1.current); - if (isHidden) throw Error("Not yet implemented."); - instance = createTextInstance(instance, props, type, workInProgress); - node.stateNode = instance; - } - FabricUIManager.appendChildToSet(containerChildSet, instance.node); - } else if (4 !== node.tag) { - if ( - 13 === node.tag && - ((props = node.alternate), - null !== props && - ((instance = null !== node.memoizedState), - (null !== props.memoizedState) !== instance)) - ) { - props = instance ? node.child : node; - null !== props && - appendAllChildrenToContainer(containerChildSet, props, !0, instance); - break a; - } - if (null !== node.child) { - node.child.return = node; - node = node.child; - continue; - } - } - if (node === workInProgress) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === workInProgress) return; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } -} -updateHostContainer = function(workInProgress) { - var portalOrRoot = workInProgress.stateNode; - if (null !== workInProgress.firstEffect) { - var container = portalOrRoot.containerInfo, - newChildSet = FabricUIManager.createChildSet(container); - appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); - portalOrRoot.pendingChildren = newChildSet; - workInProgress.effectTag |= 4; - FabricUIManager.completeRoot(container, newChildSet); - } -}; -updateHostComponent$1 = function(current, workInProgress, type, newProps) { - type = current.stateNode; - var oldProps = current.memoizedProps; - if ((current = null === workInProgress.firstEffect) && oldProps === newProps) - workInProgress.stateNode = type; - else { - var recyclableInstance = workInProgress.stateNode; - requiredContext(contextStackCursor$1.current); - var updatePayload = null; - oldProps !== newProps && - ((oldProps = diffProperties( - null, - oldProps, - newProps, - recyclableInstance.canonical.viewConfig.validAttributes - )), - (recyclableInstance.canonical.currentProps = newProps), - (updatePayload = oldProps)); - current && null === updatePayload - ? (workInProgress.stateNode = type) - : ((newProps = updatePayload), - (recyclableInstance = type.node), - (type = { - node: current - ? null !== newProps - ? FabricUIManager.cloneNodeWithNewProps( - recyclableInstance, - newProps - ) - : FabricUIManager.cloneNode(recyclableInstance) - : null !== newProps - ? FabricUIManager.cloneNodeWithNewChildrenAndProps( - recyclableInstance, - newProps - ) - : FabricUIManager.cloneNodeWithNewChildren(recyclableInstance), - canonical: type.canonical - }), - (workInProgress.stateNode = type), - current - ? (workInProgress.effectTag |= 4) - : appendAllChildren(type, workInProgress, !1, !1)); - } -}; -updateHostText$1 = function(current, workInProgress, oldText, newText) { - oldText !== newText && - ((current = requiredContext(rootInstanceStackCursor.current)), - (oldText = requiredContext(contextStackCursor$1.current)), - (workInProgress.stateNode = createTextInstance( - newText, - current, - oldText, - workInProgress - )), - (workInProgress.effectTag |= 4)); -}; -function logCapturedError(capturedError) { - var componentStack = capturedError.componentStack, - error = capturedError.error; - if (error instanceof Error) { - capturedError = error.message; - var name = error.name; - try { - error.message = - (capturedError ? name + ": " + capturedError : name) + - "\n\nThis error is located at:" + - componentStack; - } catch (e) {} - } else - error = - "string" === typeof error - ? Error(error + "\n\nThis error is located at:" + componentStack) - : Error("Unspecified error at:" + componentStack); - ExceptionsManager.handleException(error, !1); -} -function logError(boundary, errorInfo) { - var source = errorInfo.source, - stack = errorInfo.stack; - null === stack && - null !== source && - (stack = getStackByFiberInDevAndProd(source)); - errorInfo = { - componentName: null !== source ? getComponentName(source.type) : null, - componentStack: null !== stack ? stack : "", - error: errorInfo.value, - errorBoundary: null, - errorBoundaryName: null, - errorBoundaryFound: !1, - willRetry: !1 - }; - null !== boundary && - 1 === boundary.tag && - ((errorInfo.errorBoundary = boundary.stateNode), - (errorInfo.errorBoundaryName = getComponentName(boundary.type)), - (errorInfo.errorBoundaryFound = !0), - (errorInfo.willRetry = !0)); - try { - logCapturedError(errorInfo); - } catch (e) { - setTimeout(function() { - throw e; - }); - } -} -function safelyDetachRef(current$$1) { - var ref = current$$1.ref; - if (null !== ref) - if ("function" === typeof ref) - try { - ref(null); - } catch (refError) { - captureCommitPhaseError(current$$1, refError); - } - else ref.current = null; -} -function commitHookEffectList(unmountTag, mountTag, finishedWork) { - finishedWork = finishedWork.updateQueue; - finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; - if (null !== finishedWork) { - var effect = (finishedWork = finishedWork.next); - do { - if ((effect.tag & unmountTag) !== NoEffect$1) { - var destroy = effect.destroy; - effect.destroy = void 0; - void 0 !== destroy && destroy(); - } - (effect.tag & mountTag) !== NoEffect$1 && - ((destroy = effect.create), (effect.destroy = destroy())); - effect = effect.next; - } while (effect !== finishedWork); - } -} -function commitWork(current$$1, finishedWork) { - switch (finishedWork.tag) { - case 0: - case 11: - case 14: - case 15: - commitHookEffectList(UnmountMutation, MountMutation, finishedWork); - return; - } - switch (finishedWork.tag) { - case 1: - break; - case 5: - break; - case 6: - break; - case 3: - case 4: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } -} -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime); - expirationTime.tag = CaptureUpdate; - expirationTime.payload = { element: null }; - var error = errorInfo.value; - expirationTime.callback = function() { - onUncaughtError(error); - logError(fiber, errorInfo); - }; - return expirationTime; -} -function createClassErrorUpdate(fiber, errorInfo, expirationTime) { - expirationTime = createUpdate(expirationTime); - expirationTime.tag = CaptureUpdate; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error$jscomp$0 = errorInfo.value; - expirationTime.payload = function() { - return getDerivedStateFromError(error$jscomp$0); - }; - } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (expirationTime.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this)); - var error = errorInfo.value, - stack = errorInfo.stack; - logError(fiber, errorInfo); - this.componentDidCatch(error, { - componentStack: null !== stack ? stack : "" + scheduledExpirationTime >= expirationTime && + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); }); - }); - return expirationTime; -} -function throwException( - root, - returnFiber, - sourceFiber, - value, - renderExpirationTime -) { - sourceFiber.effectTag |= 1024; - sourceFiber.firstEffect = sourceFiber.lastEffect = null; - if ( - null !== value && - "object" === typeof value && - "function" === typeof value.then - ) { - var thenable = value; - value = returnFiber; - var earliestTimeoutMs = -1, - startTimeMs = -1; - do { - if (13 === value.tag) { - var current$$1 = value.alternate; - if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), null !== current$$1) - ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); - break; - } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; - else if (-1 === earliestTimeoutMs || current$$1 < earliestTimeoutMs) - earliestTimeoutMs = current$$1; - } - value = value.return; - } while (null !== value); - value = returnFiber; - do { - if ((current$$1 = 13 === value.tag)) - current$$1 = - void 0 === value.memoizedProps.fallback - ? !1 - : null === value.memoizedState; - if (current$$1) { - returnFiber = value.updateQueue; - null === returnFiber - ? ((returnFiber = new Set()), - returnFiber.add(thenable), - (value.updateQueue = returnFiber)) - : returnFiber.add(thenable); - if (0 === (value.mode & 1)) { - value.effectTag |= 64; - sourceFiber.effectTag &= -1957; - 1 === sourceFiber.tag && - (null === sourceFiber.alternate - ? (sourceFiber.tag = 17) - : ((renderExpirationTime = createUpdate(1073741823)), - (renderExpirationTime.tag = ForceUpdate), - enqueueUpdate(sourceFiber, renderExpirationTime))); - sourceFiber.expirationTime = 1073741823; - return; - } - sourceFiber = root; - returnFiber = renderExpirationTime; - var pingCache = sourceFiber.pingCache; - null === pingCache - ? ((pingCache = sourceFiber.pingCache = new PossiblyWeakMap()), - (current$$1 = new Set()), - pingCache.set(thenable, current$$1)) - : ((current$$1 = pingCache.get(thenable)), - void 0 === current$$1 && - ((current$$1 = new Set()), pingCache.set(thenable, current$$1))); - current$$1.has(returnFiber) || - (current$$1.add(returnFiber), - (sourceFiber = pingSuspendedRoot.bind( - null, - sourceFiber, - thenable, - returnFiber - )), - (sourceFiber = tracing.unstable_wrap(sourceFiber)), - thenable.then(sourceFiber, sourceFiber)); - -1 === earliestTimeoutMs - ? (root = 1073741823) - : (-1 === startTimeMs && - (startTimeMs = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - )) - - 5e3), - (root = startTimeMs + earliestTimeoutMs)); - 0 <= root && - nextLatestAbsoluteTimeoutMs < root && - (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 2048; - value.expirationTime = renderExpirationTime; - return; - } - value = value.return; - } while (null !== value); - value = Error( - (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber) - ); - } - nextRenderDidError = !0; - value = createCapturedValue(value, sourceFiber); - root = returnFiber; - do { - switch (root.tag) { - case 3: - root.effectTag |= 2048; - root.expirationTime = renderExpirationTime; - renderExpirationTime = createRootErrorUpdate( - root, - value, - renderExpirationTime - ); - enqueueCapturedUpdate(root, renderExpirationTime); - return; - case 1: - if ( - ((earliestTimeoutMs = value), - (startTimeMs = root.type), - (sourceFiber = root.stateNode), - 0 === (root.effectTag & 64) && - ("function" === typeof startTimeMs.getDerivedStateFromError || - (null !== sourceFiber && - "function" === typeof sourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(sourceFiber))))) - ) { - root.effectTag |= 2048; - root.expirationTime = renderExpirationTime; - renderExpirationTime = createClassErrorUpdate( - root, - earliestTimeoutMs, - renderExpirationTime - ); - enqueueCapturedUpdate(root, renderExpirationTime); - return; - } - } - root = root.return; - } while (null !== root); -} -function unwindWork(workInProgress) { - switch (workInProgress.tag) { - case 1: - isContextProvider(workInProgress.type) && popContext(workInProgress); - var effectTag = workInProgress.effectTag; - return effectTag & 2048 - ? ((workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress) - : null; - case 3: - return ( - popHostContainer(workInProgress), - popTopLevelContextObject(workInProgress), - (effectTag = workInProgress.effectTag), - invariant( - 0 === (effectTag & 64), - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ), - (workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress - ); - case 5: - return popHostContext(workInProgress), null; - case 13: - return ( - (effectTag = workInProgress.effectTag), - effectTag & 2048 - ? ((workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress) - : null - ); - case 18: - return null; - case 4: - return popHostContainer(workInProgress), null; - case 10: - return popProvider(workInProgress), null; - default: - return null; - } -} -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, - ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; -invariant( - null != tracing.__interactionsRef && - null != tracing.__interactionsRef.current, - "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 http://fb.me/react-profiling" -); -var isWorking = !1, - nextUnitOfWork = null, - nextRoot = null, - nextRenderExpirationTime = 0, - nextLatestAbsoluteTimeoutMs = -1, - nextRenderDidError = !1, - nextEffect = null, - isCommitting$1 = !1, - rootWithPendingPassiveEffects = null, - passiveEffectCallbackHandle = null, - passiveEffectCallback = null, - legacyErrorBoundariesThatAlreadyFailed = null; -function resetStack() { - if (null !== nextUnitOfWork) - for ( - var interruptedWork = nextUnitOfWork.return; - null !== interruptedWork; - - ) { - var interruptedWork$jscomp$0 = interruptedWork; - switch (interruptedWork$jscomp$0.tag) { - case 1: - var childContextTypes = - interruptedWork$jscomp$0.type.childContextTypes; - null !== childContextTypes && - void 0 !== childContextTypes && - popContext(interruptedWork$jscomp$0); - break; - case 3: - popHostContainer(interruptedWork$jscomp$0); - popTopLevelContextObject(interruptedWork$jscomp$0); - break; - case 5: - popHostContext(interruptedWork$jscomp$0); - break; - case 4: - popHostContainer(interruptedWork$jscomp$0); - break; - case 10: - popProvider(interruptedWork$jscomp$0); - } - interruptedWork = interruptedWork.return; - } - nextRoot = null; - nextRenderExpirationTime = 0; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = !1; - nextUnitOfWork = null; -} -function commitAllHostEffects() { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { - var current$$1 = nextEffect.alternate; - null !== current$$1 && - ((current$$1 = current$$1.ref), - null !== current$$1 && - ("function" === typeof current$$1 - ? current$$1(null) - : (current$$1.current = null))); - } - switch (effectTag & 14) { - case 2: - nextEffect.effectTag &= -3; - break; - case 6: - nextEffect.effectTag &= -3; - commitWork(nextEffect.alternate, nextEffect); - break; - case 4: - commitWork(nextEffect.alternate, nextEffect); - break; - case 8: - effectTag = nextEffect; - a: for (var node = (current$$1 = effectTag); ; ) { - var current$$1$jscomp$0 = node; - "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$$1$jscomp$0); - switch (current$$1$jscomp$0.tag) { - case 0: - case 11: - case 14: - case 15: - var updateQueue = current$$1$jscomp$0.updateQueue; - if ( - null !== updateQueue && - ((updateQueue = updateQueue.lastEffect), null !== updateQueue) - ) { - var effect = (updateQueue = updateQueue.next); - do { - var destroy = effect.destroy; - if (void 0 !== destroy) { - var current$$1$jscomp$1 = current$$1$jscomp$0; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(current$$1$jscomp$1, error); - } - } - effect = effect.next; - } while (effect !== updateQueue); - } - break; - case 1: - safelyDetachRef(current$$1$jscomp$0); - updateQueue = current$$1$jscomp$0.stateNode; - if ("function" === typeof updateQueue.componentWillUnmount) - try { - (updateQueue.props = current$$1$jscomp$0.memoizedProps), - (updateQueue.state = current$$1$jscomp$0.memoizedState), - updateQueue.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current$$1$jscomp$0, unmountError); - } - break; - case 5: - safelyDetachRef(current$$1$jscomp$0); - break; - case 4: - FabricUIManager.createChildSet( - current$$1$jscomp$0.stateNode.containerInfo - ); - } - if (null !== node.child) - (node.child.return = node), (node = node.child); - else { - if (node === current$$1) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === current$$1) break a; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - effectTag.return = null; - effectTag.child = null; - effectTag.memoizedState = null; - effectTag.updateQueue = null; - effectTag = effectTag.alternate; - null !== effectTag && - ((effectTag.return = null), - (effectTag.child = null), - (effectTag.memoizedState = null), - (effectTag.updateQueue = null)); - } - nextEffect = nextEffect.nextEffect; - } -} -function commitBeforeMutationLifecycles() { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) - a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - break a; - case 1: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState; - current$$1 = finishedWork.stateNode; - finishedWork = current$$1.getSnapshotBeforeUpdate( - finishedWork.elementType === finishedWork.type - ? prevProps - : resolveDefaultProps(finishedWork.type, prevProps), - prevState - ); - current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; - } - break a; - case 3: - case 5: - case 6: - case 4: - case 17: - break a; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } -} -function commitAllLifeCycles( - finishedRoot$jscomp$0, - committedExpirationTime$jscomp$0 -) { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 36) { - var finishedRoot = finishedRoot$jscomp$0, - current$$1 = nextEffect.alternate, - finishedWork = nextEffect, - committedExpirationTime = committedExpirationTime$jscomp$0; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; - case 1: - finishedRoot = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current$$1) finishedRoot.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current$$1.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current$$1.memoizedProps - ); - finishedRoot.componentDidUpdate( - prevProps, - current$$1.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ); - } - current$$1 = finishedWork.updateQueue; - null !== current$$1 && - commitUpdateQueue( - finishedWork, - current$$1, - finishedRoot, - committedExpirationTime - ); - break; - case 3: - current$$1 = finishedWork.updateQueue; - if (null !== current$$1) { - finishedRoot = null; - if (null !== finishedWork.child) - switch (finishedWork.child.tag) { - case 5: - finishedRoot = finishedWork.child.stateNode.canonical; - break; - case 1: - finishedRoot = finishedWork.child.stateNode; - } - commitUpdateQueue( - finishedWork, - current$$1, - finishedRoot, - committedExpirationTime - ); - } - break; - case 5: - null === current$$1 && - finishedWork.effectTag & 4 && - invariant( - !1, - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - break; - case 4: - break; - case 12: - committedExpirationTime = finishedWork.memoizedProps.onRender; - committedExpirationTime( - finishedWork.memoizedProps.id, - null === current$$1 ? "mount" : "update", - finishedWork.actualDuration, - finishedWork.treeBaseDuration, - finishedWork.actualStartTime, - commitTime, - finishedRoot.memoizedInteractions - ); - break; - case 13: - break; - case 17: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - if ( - effectTag & 128 && - ((finishedWork = nextEffect.ref), null !== finishedWork) - ) { - committedExpirationTime = nextEffect.stateNode; - switch (nextEffect.tag) { - case 5: - committedExpirationTime = committedExpirationTime.canonical; - } - "function" === typeof finishedWork - ? finishedWork(committedExpirationTime) - : (finishedWork.current = committedExpirationTime); - } - effectTag & 512 && (rootWithPendingPassiveEffects = finishedRoot$jscomp$0); - nextEffect = nextEffect.nextEffect; - } -} -function commitPassiveEffects(root, firstEffect) { - passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; - var previousIsRendering = isRendering; - isRendering = !0; - do { - if (firstEffect.effectTag & 512) { - var didError = !1, - error = void 0; + }); + root.memoizedInteractions = interactions; + if (0 < interactions.size) { + var subscriber = tracing.__subscriberRef.current; + if (null !== subscriber) { + root = 1e3 * expirationTime + root.interactionThreadID; try { - var finishedWork = firstEffect; - commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); - commitHookEffectList(NoEffect$1, MountPassive, finishedWork); - } catch (e) { - (didError = !0), (error = e); + subscriber.onWorkStarted(interactions, root); + } catch (error) { + scheduleCallback(99, function() { + throw error; + }); } - didError && captureCommitPhaseError(firstEffect, error); } - firstEffect = firstEffect.nextEffect; - } while (null !== firstEffect); - isRendering = previousIsRendering; - previousIsRendering = root.expirationTime; - 0 !== previousIsRendering && requestWork(root, previousIsRendering); - isBatchingUpdates || isRendering || performWork(1073741823, !1); + } } -function flushPassiveEffects() { - if (null !== passiveEffectCallbackHandle) { - var callbackID = passiveEffectCallbackHandle; - scheduledCallback = null; - clearTimeout(callbackID); - } - null !== passiveEffectCallback && passiveEffectCallback(); -} -function commitRoot(root, finishedWork) { - isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); - var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== committedExpirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.pendingCommitExpirationTime = 0; - var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, - childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; - markCommittedPriorityLevels( - root, - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit - ? childExpirationTimeBeforeCommit - : updateExpirationTimeBeforeCommit - ); - updateExpirationTimeBeforeCommit = null; - updateExpirationTimeBeforeCommit = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - ReactCurrentOwner$2.current = null; - childExpirationTimeBeforeCommit = void 0; - 1 < finishedWork.effectTag - ? null !== finishedWork.lastEffect - ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (childExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (childExpirationTimeBeforeCommit = finishedWork) - : (childExpirationTimeBeforeCommit = finishedWork.firstEffect); - for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - var didError = !1, - error$jscomp$0 = void 0; - try { - commitBeforeMutationLifecycles(); - } catch (e) { - (didError = !0), (error$jscomp$0 = e); - } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - commitTime = now$1(); - for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - didError = !1; - error$jscomp$0 = void 0; - try { - commitAllHostEffects(); - } catch (e) { - (didError = !0), (error$jscomp$0 = e); - } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - root.current = finishedWork; - for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - didError = !1; - error$jscomp$0 = void 0; - try { - commitAllLifeCycles(root, committedExpirationTime); - } catch (e) { - (didError = !0), (error$jscomp$0 = e); - } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - if ( - null !== childExpirationTimeBeforeCommit && - null !== rootWithPendingPassiveEffects - ) { - var callback = commitPassiveEffects.bind( - null, - root, - childExpirationTimeBeforeCommit - ); - callback = tracing.unstable_wrap(callback); - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return scheduleDeferredCallback$1(callback); - } - ); - passiveEffectCallback = callback; - } - isWorking = isCommitting$1 = !1; - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode); - childExpirationTimeBeforeCommit = finishedWork.expirationTime; - finishedWork = finishedWork.childExpirationTime; - var earliestRemainingTimeAfterCommit = - finishedWork > childExpirationTimeBeforeCommit - ? finishedWork - : childExpirationTimeBeforeCommit; - 0 === earliestRemainingTimeAfterCommit && - (legacyErrorBoundariesThatAlreadyFailed = null); - onCommit(root, earliestRemainingTimeAfterCommit); - tracing.__interactionsRef.current = updateExpirationTimeBeforeCommit; - var subscriber = void 0; +function finishPendingInteractions(root, committedExpirationTime) { + var earliestRemainingTimeAfterCommit = root.firstPendingTime, + subscriber = void 0; try { if ( ((subscriber = tracing.__subscriberRef.current), @@ -6066,7 +6766,9 @@ function commitRoot(root, finishedWork) { 1e3 * committedExpirationTime + root.interactionThreadID ); } catch (error) { - hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); + scheduleCallback(99, function() { + throw error; + }); } finally { var pendingInteractionMap = root.pendingInteractionMap; pendingInteractionMap.forEach(function( @@ -6081,868 +6783,24 @@ function commitRoot(root, finishedWork) { try { subscriber.onInteractionScheduledWorkCompleted(interaction); } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); + scheduleCallback(99, function() { + throw error; + }); } })); }); } } -function completeUnitOfWork(workInProgress) { - for (;;) { - var current$$1 = workInProgress.alternate, - returnFiber = workInProgress.return, - siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 1024)) { - nextUnitOfWork = workInProgress; - if (workInProgress.mode & 4) { - var fiber = workInProgress; - profilerStartTime = now$1(); - 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); - } - a: { - var current = current$$1; - current$$1 = workInProgress; - var renderExpirationTime = nextRenderExpirationTime; - fiber = current$$1.pendingProps; - switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: - case 0: - break; - case 1: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 3: - popHostContainer(current$$1); - popTopLevelContextObject(current$$1); - fiber = current$$1.stateNode; - fiber.pendingContext && - ((fiber.context = fiber.pendingContext), - (fiber.pendingContext = null)); - if (null === current || null === current.child) - current$$1.effectTag &= -3; - updateHostContainer(current$$1); - break; - case 5: - popHostContext(current$$1); - renderExpirationTime = requiredContext( - rootInstanceStackCursor.current - ); - var type = current$$1.type; - if (null !== current && null != current$$1.stateNode) - updateHostComponent$1( - current, - current$$1, - type, - fiber, - renderExpirationTime - ), - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - else if (fiber) { - var currentHostContext = requiredContext( - contextStackCursor$1.current - ), - internalInstanceHandle = current$$1; - current = nextReactTag; - nextReactTag += 2; - var viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !currentHostContext.isInAParentText, - "Nesting of within is not currently supported." - ); - type = diffProperties( - null, - emptyObject, - fiber, - viewConfig.validAttributes - ); - renderExpirationTime = FabricUIManager.createNode( - current, - viewConfig.uiViewClassName, - renderExpirationTime, - type, - internalInstanceHandle - ); - fiber = new ReactFabricHostComponent(current, viewConfig, fiber); - fiber = { node: renderExpirationTime, canonical: fiber }; - appendAllChildren(fiber, current$$1, !1, !1); - current$$1.stateNode = fiber; - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - current && null != current$$1.stateNode - ? updateHostText$1( - current, - current$$1, - current.memoizedProps, - fiber - ) - : ("string" !== typeof fiber && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ), - (current = requiredContext(rootInstanceStackCursor.current)), - (renderExpirationTime = requiredContext( - contextStackCursor$1.current - )), - (current$$1.stateNode = createTextInstance( - fiber, - current, - renderExpirationTime, - current$$1 - ))); - break; - case 11: - break; - case 13: - fiber = current$$1.memoizedState; - if (0 !== (current$$1.effectTag & 64)) { - current$$1.expirationTime = renderExpirationTime; - nextUnitOfWork = current$$1; - break a; - } - fiber = null !== fiber; - renderExpirationTime = - null !== current && null !== current.memoizedState; - null !== current && - !fiber && - renderExpirationTime && - ((current = current.child.sibling), - null !== current && - ((viewConfig = current$$1.firstEffect), - null !== viewConfig - ? ((current$$1.firstEffect = current), - (current.nextEffect = viewConfig)) - : ((current$$1.firstEffect = current$$1.lastEffect = current), - (current.nextEffect = null)), - (current.effectTag = 8))); - if (fiber || renderExpirationTime) current$$1.effectTag |= 4; - break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); - break; - case 9: - break; - case 14: - break; - case 17: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 18: - break; - default: - invariant( - !1, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); - } - nextUnitOfWork = null; - } - workInProgress.mode & 4 && - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - current$$1 = workInProgress; - if ( - 1 === nextRenderExpirationTime || - 1 !== current$$1.childExpirationTime - ) { - fiber = 0; - if (current$$1.mode & 4) { - current = current$$1.actualDuration; - renderExpirationTime = current$$1.selfBaseDuration; - viewConfig = - null === current$$1.alternate || - current$$1.child !== current$$1.alternate.child; - for (type = current$$1.child; null !== type; ) - (internalInstanceHandle = type.expirationTime), - (currentHostContext = type.childExpirationTime), - internalInstanceHandle > fiber && - (fiber = internalInstanceHandle), - currentHostContext > fiber && (fiber = currentHostContext), - viewConfig && (current += type.actualDuration), - (renderExpirationTime += type.treeBaseDuration), - (type = type.sibling); - current$$1.actualDuration = current; - current$$1.treeBaseDuration = renderExpirationTime; - } else - for (current = current$$1.child; null !== current; ) - (renderExpirationTime = current.expirationTime), - (viewConfig = current.childExpirationTime), - renderExpirationTime > fiber && (fiber = renderExpirationTime), - viewConfig > fiber && (fiber = viewConfig), - (current = current.sibling); - current$$1.childExpirationTime = fiber; - } - if (null !== nextUnitOfWork) return nextUnitOfWork; - null !== returnFiber && - 0 === (returnFiber.effectTag & 1024) && - (null === returnFiber.firstEffect && - (returnFiber.firstEffect = workInProgress.firstEffect), - null !== workInProgress.lastEffect && - (null !== returnFiber.lastEffect && - (returnFiber.lastEffect.nextEffect = workInProgress.firstEffect), - (returnFiber.lastEffect = workInProgress.lastEffect)), - 1 < workInProgress.effectTag && - (null !== returnFiber.lastEffect - ? (returnFiber.lastEffect.nextEffect = workInProgress) - : (returnFiber.firstEffect = workInProgress), - (returnFiber.lastEffect = workInProgress))); - } else { - if (workInProgress.mode & 4) { - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - current$$1 = workInProgress.actualDuration; - for (fiber = workInProgress.child; null !== fiber; ) - (current$$1 += fiber.actualDuration), (fiber = fiber.sibling); - workInProgress.actualDuration = current$$1; - } - workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); - if (null !== workInProgress) - return (workInProgress.effectTag &= 1023), workInProgress; - null !== returnFiber && - ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 1024)); - } - if (null !== siblingFiber) return siblingFiber; - if (null !== returnFiber) workInProgress = returnFiber; - else break; - } - return null; -} -function performUnitOfWork(workInProgress) { - var current$$1 = workInProgress.alternate; - workInProgress.mode & 4 && - ((profilerStartTime = now$1()), - 0 > workInProgress.actualStartTime && - (workInProgress.actualStartTime = now$1())); - current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); - workInProgress.memoizedProps = workInProgress.pendingProps; - workInProgress.mode & 4 && - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); - null === current$$1 && (current$$1 = completeUnitOfWork(workInProgress)); - ReactCurrentOwner$2.current = null; - return current$$1; -} -function renderRoot(root, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - flushPassiveEffects(); - isWorking = !0; - var previousDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - var expirationTime = root.nextExpirationTimeToWorkOn; - if ( - expirationTime !== nextRenderExpirationTime || - root !== nextRoot || - null === nextUnitOfWork - ) { - resetStack(); - nextRoot = root; - nextRenderExpirationTime = expirationTime; - nextUnitOfWork = createWorkInProgress( - nextRoot.current, - null, - nextRenderExpirationTime - ); - root.pendingCommitExpirationTime = 0; - var interactions = new Set(); - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - scheduledExpirationTime >= expirationTime && - scheduledInteractions.forEach(function(interaction) { - return interactions.add(interaction); - }); - }); - root.memoizedInteractions = interactions; - if (0 < interactions.size) { - var subscriber = tracing.__subscriberRef.current; - if (null !== subscriber) { - var threadID = 1e3 * expirationTime + root.interactionThreadID; - try { - subscriber.onWorkStarted(interactions, threadID); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - } - } - } - subscriber = null; - subscriber = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - threadID = !1; - do { - try { - if (isYieldy) - for (; null !== nextUnitOfWork && !(frameDeadline <= now$1()); ) - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - else - for (; null !== nextUnitOfWork; ) - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - } catch (thrownValue) { - if ( - ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), - resetHooks(), - null === nextUnitOfWork) - ) - (threadID = !0), onUncaughtError(thrownValue); - else { - nextUnitOfWork.mode & 4 && - stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, !0); - invariant( - null !== nextUnitOfWork, - "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." - ); - var sourceFiber = nextUnitOfWork, - returnFiber = sourceFiber.return; - if (null === returnFiber) (threadID = !0), onUncaughtError(thrownValue); - else { - throwException( - root, - returnFiber, - sourceFiber, - thrownValue, - nextRenderExpirationTime - ); - nextUnitOfWork = completeUnitOfWork(sourceFiber); - continue; - } - } - } - break; - } while (1); - tracing.__interactionsRef.current = subscriber; - isWorking = !1; - ReactCurrentDispatcher.current = previousDispatcher; - lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; - resetHooks(); - if (threadID) (nextRoot = null), (root.finishedWork = null); - else if (null !== nextUnitOfWork) root.finishedWork = null; - else { - previousDispatcher = root.current.alternate; - invariant( - null !== previousDispatcher, - "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." - ); - nextRoot = null; - if (nextRenderDidError) { - if (hasLowerPriorityWork(root, expirationTime)) { - markSuspendedPriorityLevel(root, expirationTime); - onSuspend( - root, - previousDispatcher, - expirationTime, - root.expirationTime, - -1 - ); - return; - } - if (!root.didError && isYieldy) { - root.didError = !0; - isYieldy = root.nextExpirationTimeToWorkOn = expirationTime; - subscriber = root.expirationTime = 1073741823; - onSuspend(root, previousDispatcher, isYieldy, subscriber, -1); - return; - } - } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs - ? (markSuspendedPriorityLevel(root, expirationTime), - (isYieldy = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel(root, expirationTime))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), - onSuspend( - root, - previousDispatcher, - expirationTime, - root.expirationTime, - 0 > isYieldy ? 0 : isYieldy - )) - : onComplete(root, previousDispatcher, expirationTime); - } -} -function captureCommitPhaseError(sourceFiber, value) { - for (var fiber = sourceFiber.return; null !== fiber; ) { - switch (fiber.tag) { - case 1: - var instance = fiber.stateNode; - if ( - "function" === typeof fiber.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - sourceFiber = createCapturedValue(value, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); - return; - } - break; - case 3: - sourceFiber = createCapturedValue(value, sourceFiber); - sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); - return; - } - fiber = fiber.return; - } - 3 === sourceFiber.tag && - ((fiber = createCapturedValue(value, sourceFiber)), - (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), - enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); -} -function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(), - expirationTime = void 0; - if (0 === (fiber.mode & 1)) expirationTime = 1073741823; - else if (isWorking && !isCommitting$1) - expirationTime = nextRenderExpirationTime; - else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = 1073741823; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = - 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); - break; - case scheduler.unstable_NormalPriority: - expirationTime = - 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = 1; - break; - default: - invariant( - !1, - "Unknown priority level. This error is likely caused by a bug in React. Please file an issue." - ); - } - null !== nextRoot && - expirationTime === nextRenderExpirationTime && - --expirationTime; - } - priorityLevel === scheduler.unstable_UserBlockingPriority && - (0 === lowestPriorityPendingInteractiveExpirationTime || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) && - (lowestPriorityPendingInteractiveExpirationTime = expirationTime); - return expirationTime; -} -function pingSuspendedRoot(root, thenable, pingTime) { - var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - if (null !== nextRoot && nextRenderExpirationTime === pingTime) - nextRoot = null; - else if ( - ((thenable = root.earliestSuspendedTime), - (pingCache = root.latestSuspendedTime), - 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) - ) { - root.didError = !1; - thenable = root.latestPingedTime; - if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; - findNextExpirationTimeToWorkOn(pingTime, root); - pingTime = root.expirationTime; - 0 !== pingTime && requestWork(root, pingTime); - } -} -function scheduleWorkToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); - var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < expirationTime && - (alternate.expirationTime = expirationTime); - var node = fiber.return, - root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; - else - for (; null !== node; ) { - alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); - null !== alternate && - alternate.childExpirationTime < expirationTime && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { - root = node.stateNode; - break; - } - node = node.return; - } - if ( - null !== root && - ((fiber = tracing.__interactionsRef.current), 0 < fiber.size) - ) { - alternate = root.pendingInteractionMap; - var pendingInteractions = alternate.get(expirationTime); - null != pendingInteractions - ? fiber.forEach(function(interaction) { - pendingInteractions.has(interaction) || interaction.__count++; - pendingInteractions.add(interaction); - }) - : (alternate.set(expirationTime, new Set(fiber)), - fiber.forEach(function(interaction) { - interaction.__count++; - })); - alternate = tracing.__subscriberRef.current; - if (null !== alternate) - alternate.onWorkScheduled( - fiber, - 1e3 * expirationTime + root.interactionThreadID - ); - } - return root; -} -function scheduleWork(fiber, expirationTime) { - fiber = scheduleWorkToRoot(fiber, expirationTime); - null !== fiber && - (!isWorking && - 0 !== nextRenderExpirationTime && - expirationTime > nextRenderExpirationTime && - resetStack(), - markPendingPriorityLevel(fiber, expirationTime), - (isWorking && !isCommitting$1 && nextRoot === fiber) || - requestWork(fiber, fiber.expirationTime), - nestedUpdateCount > NESTED_UPDATE_LIMIT && - ((nestedUpdateCount = 0), - invariant( - !1, - "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." - ))); -} -var firstScheduledRoot = null, - lastScheduledRoot = null, - callbackExpirationTime = 0, - callbackID = void 0, - isRendering = !1, - nextFlushedRoot = null, - nextFlushedExpirationTime = 0, - lowestPriorityPendingInteractiveExpirationTime = 0, - hasUnhandledError = !1, - unhandledError = null, - isBatchingUpdates = !1, - isUnbatchingUpdates = !1, - completedBatches = null, - originalStartTimeMs = now$1(), - currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), - currentSchedulerTime = currentRendererTime, - NESTED_UPDATE_LIMIT = 50, - nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null; -function recomputeCurrentRendererTime() { - currentRendererTime = - 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); -} -function scheduleCallbackWithExpirationTime(root, expirationTime) { - if (0 !== callbackExpirationTime) { - if (expirationTime < callbackExpirationTime) return; - null !== callbackID && - ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); - } - callbackExpirationTime = expirationTime; - root = now$1() - originalStartTimeMs; - callbackID = scheduleDeferredCallback$1(performAsyncWork, { - timeout: 10 * (1073741822 - expirationTime) - root - }); -} -function onComplete(root, finishedWork, expirationTime) { - root.pendingCommitExpirationTime = expirationTime; - root.finishedWork = finishedWork; -} -function onSuspend( - root, - finishedWork, - suspendedExpirationTime, - rootExpirationTime, - msUntilTimeout -) { - root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || frameDeadline <= now$1() - ? 0 < msUntilTimeout && - (root.timeoutHandle = scheduleTimeout( - onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), - msUntilTimeout - )) - : ((root.pendingCommitExpirationTime = suspendedExpirationTime), - (root.finishedWork = finishedWork)); -} -function onTimeout(root, finishedWork, suspendedExpirationTime) { - root.pendingCommitExpirationTime = suspendedExpirationTime; - root.finishedWork = finishedWork; - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); - nextFlushedRoot = root; - nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); -} -function onCommit(root, expirationTime) { - root.expirationTime = expirationTime; - root.finishedWork = null; -} -function requestCurrentTime() { - if (isRendering) return currentSchedulerTime; - findHighestPriorityRoot(); - if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - return currentSchedulerTime; -} -function requestWork(root, expirationTime) { - null === root.nextScheduledRoot - ? ((root.expirationTime = expirationTime), - null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = root), - (root.nextScheduledRoot = root)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) - : expirationTime > root.expirationTime && - (root.expirationTime = expirationTime); - isRendering || - (isBatchingUpdates - ? isUnbatchingUpdates && - ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1073741823), - performWorkOnRoot(root, 1073741823, !1)) - : 1073741823 === expirationTime - ? performWork(1073741823, !1) - : scheduleCallbackWithExpirationTime(root, expirationTime)); -} -function findHighestPriorityRoot() { - var highestPriorityWork = 0, - highestPriorityRoot = null; - if (null !== lastScheduledRoot) - for ( - var previousScheduledRoot = lastScheduledRoot, root = firstScheduledRoot; - null !== root; - - ) { - var remainingExpirationTime = root.expirationTime; - if (0 === remainingExpirationTime) { - invariant( - null !== previousScheduledRoot && null !== lastScheduledRoot, - "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." - ); - if (root === root.nextScheduledRoot) { - firstScheduledRoot = lastScheduledRoot = root.nextScheduledRoot = null; - break; - } else if (root === firstScheduledRoot) - (firstScheduledRoot = remainingExpirationTime = - root.nextScheduledRoot), - (lastScheduledRoot.nextScheduledRoot = remainingExpirationTime), - (root.nextScheduledRoot = null); - else if (root === lastScheduledRoot) { - lastScheduledRoot = previousScheduledRoot; - lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; - root.nextScheduledRoot = null; - break; - } else - (previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot), - (root.nextScheduledRoot = null); - root = previousScheduledRoot.nextScheduledRoot; - } else { - remainingExpirationTime > highestPriorityWork && - ((highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root)); - if (root === lastScheduledRoot) break; - if (1073741823 === highestPriorityWork) break; - previousScheduledRoot = root; - root = root.nextScheduledRoot; - } - } - nextFlushedRoot = highestPriorityRoot; - nextFlushedExpirationTime = highestPriorityWork; -} -function performAsyncWork(didTimeout) { - if (didTimeout && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - didTimeout = firstScheduledRoot; - do { - var expirationTime = didTimeout.expirationTime; - 0 !== expirationTime && - currentRendererTime <= expirationTime && - (didTimeout.nextExpirationTimeToWorkOn = currentRendererTime); - didTimeout = didTimeout.nextScheduledRoot; - } while (didTimeout !== firstScheduledRoot); - } - performWork(0, !0); -} -function performWork(minExpirationTime, isYieldy) { - findHighestPriorityRoot(); - if (isYieldy) - for ( - recomputeCurrentRendererTime(), - currentSchedulerTime = currentRendererTime; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !( - frameDeadline <= now$1() && - currentRendererTime > nextFlushedExpirationTime - ); - - ) - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ), - findHighestPriorityRoot(), - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - else - for ( - ; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; - - ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), - findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); - 0 !== nextFlushedExpirationTime && - scheduleCallbackWithExpirationTime( - nextFlushedRoot, - nextFlushedExpirationTime - ); - nestedUpdateCount = 0; - lastCommittedRootDuringThisBatch = null; - if (null !== completedBatches) - for ( - minExpirationTime = completedBatches, - completedBatches = null, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ - ) { - var batch = minExpirationTime[isYieldy]; - try { - batch._onComplete(); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - } - if (hasUnhandledError) - throw ((minExpirationTime = unhandledError), - (unhandledError = null), - (hasUnhandledError = !1), - minExpirationTime); -} -function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - isRendering = !0; - if (isYieldy) { - var _finishedWork = root.finishedWork; - null !== _finishedWork - ? completeRoot$1(root, _finishedWork, expirationTime) - : ((root.finishedWork = null), - (_finishedWork = root.timeoutHandle), - -1 !== _finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), - renderRoot(root, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - (frameDeadline <= now$1() - ? (root.finishedWork = _finishedWork) - : completeRoot$1(root, _finishedWork, expirationTime))); - } else - (_finishedWork = root.finishedWork), - null !== _finishedWork - ? completeRoot$1(root, _finishedWork, expirationTime) - : ((root.finishedWork = null), - (_finishedWork = root.timeoutHandle), - -1 !== _finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), - renderRoot(root, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - completeRoot$1(root, _finishedWork, expirationTime)); - isRendering = !1; -} -function completeRoot$1(root, finishedWork, expirationTime) { - var firstBatch = root.firstBatch; - if ( - null !== firstBatch && - firstBatch._expirationTime >= expirationTime && - (null === completedBatches - ? (completedBatches = [firstBatch]) - : completedBatches.push(firstBatch), - firstBatch._defer) - ) { - root.finishedWork = finishedWork; - root.expirationTime = 0; - return; - } - root.finishedWork = null; - root === lastCommittedRootDuringThisBatch - ? nestedUpdateCount++ - : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); - } - ); -} -function onUncaughtError(error) { - invariant( - null !== nextFlushedRoot, - "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." - ); - nextFlushedRoot.expirationTime = 0; - hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); -} function findHostInstance(component) { var fiber = component._reactInternalFiber; - void 0 === fiber && - ("function" === typeof component.render - ? invariant(!1, "Unable to find node on an unmounted component.") - : invariant( - !1, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - )); + if (void 0 === fiber) { + if ("function" === typeof component.render) + throw ReactError("Unable to find node on an unmounted component."); + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } component = findCurrentHostFiber(fiber); return null === component ? null : component.stateNode; } @@ -6954,10 +6812,13 @@ function updateContainer(element, container, parentComponent, callback) { a: if (parentComponent) { parentComponent = parentComponent._reactInternalFiber; b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); + if ( + 2 !== isFiberMountedImpl(parentComponent) || + 1 !== parentComponent.tag + ) + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); var parentContext = parentComponent; do { switch (parentContext.tag) { @@ -6974,11 +6835,9 @@ function updateContainer(element, container, parentComponent, callback) { } parentContext = parentContext.return; } while (null !== parentContext); - invariant( - !1, + throw ReactError( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); - parentContext = void 0; } if (1 === parentComponent.tag) { var Component = parentComponent.type; @@ -7003,7 +6862,7 @@ function updateContainer(element, container, parentComponent, callback) { null !== container && (callback.callback = container); flushPassiveEffects(); enqueueUpdate(currentTime, callback); - scheduleWork(currentTime, current$$1); + scheduleUpdateOnFiber(currentTime, current$$1); return current$$1; } function createPortal(children, containerInfo, implementation) { @@ -7038,7 +6897,9 @@ function _inherits(subClass, superClass) { } var getInspectorDataForViewTag = void 0; getInspectorDataForViewTag = function() { - invariant(!1, "getInspectorDataForViewTag() is not available in production"); + throw ReactError( + "getInspectorDataForViewTag() is not available in production" + ); }; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7054,21 +6915,18 @@ function findNodeHandle(componentOrHandle) { : componentOrHandle._nativeTag; } _batchedUpdatesImpl = function(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; + if (0 !== workPhase) return fn(a); + workPhase = 1; try { return fn(a); } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1073741823, !1); + (workPhase = 0), flushImmediateQueue(); } }; _flushInteractiveUpdatesImpl = function() { - isRendering || - 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), - (lowestPriorityPendingInteractiveExpirationTime = 0)); + workPhase !== RenderPhase && + workPhase !== CommitPhase && + flushPendingDiscreteUpdates(); }; var roots = new Map(), ReactFabric = { @@ -7095,35 +6953,67 @@ var roots = new Map(), TextInputState.focusTextInput(findNodeHandle(this)); }; ReactNativeComponent.prototype.measure = function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureLayout = function( relativeToNativeNode, onSuccess, onFail ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { + if (null != maybeInstance && !maybeInstance.canonical) { var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; maybeInstance = @@ -7146,53 +7036,16 @@ var roots = new Map(), })(React.Component); })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, - setNativeProps: function(handle, nativeProps) { - null != handle._nativeTag && - ((nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - handle.viewConfig.validAttributes - )), - null != nativeProps && - UIManager.updateView( - handle._nativeTag, - handle.viewConfig.uiViewClassName, - nativeProps - )); - }, + setNativeProps: function() {}, render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = 0; - isDevToolsPresent && (root |= 4); - root = createFiber(3, null, null, root); - var root$jscomp$0 = { - current: root, - containerInfo: containerTag, - pendingChildren: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - pingCache: null, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: !1, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null, - interactionThreadID: tracing.unstable_getThreadID(), - memoizedInteractions: new Set(), - pendingInteractionMap: new Map() - }; - root = root.stateNode = root$jscomp$0; + root = new FiberRootNode(containerTag, !1); + var uninitializedFiber = 0; + isDevToolsPresent && (uninitializedFiber |= 4); + uninitializedFiber = createFiber(3, null, null, uninitializedFiber); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -7226,31 +7079,63 @@ var roots = new Map(), NativeMethodsMixin: (function(findNodeHandle, findHostInstance) { return { measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }, setNativeProps: function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { + if (null != maybeInstance && !maybeInstance.canonical) { var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; maybeInstance = @@ -7283,7 +7168,10 @@ var roots = new Map(), var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: null, overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { fiber = findCurrentHostFiber(fiber); @@ -7300,7 +7188,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.8.3", + version: "16.8.6", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js index 8afedd6a1..38166b62d 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -26,10 +26,20 @@ var deepDiffer = require("deepDiffer"); var flattenStyle = require("flattenStyle"); var TextInputState = require("TextInputState"); var checkPropTypes = require("prop-types/checkPropTypes"); +var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); -var scheduler = require("scheduler"); var ExceptionsManager = require("ExceptionsManager"); +// Do not require this module directly! Use a normal error constructor with +// template literal strings. The messages will be converted to ReactError during +// build, and in production they will be minified. + +function ReactError(message) { + var error = new Error(message); + error.name = "Invariant Violation"; + return error; +} + /** * Use invariant() to assert state which your program assumes to be true. * @@ -41,39 +51,237 @@ var ExceptionsManager = require("ExceptionsManager"); * will remain to ensure logic does not differ in production. */ -var validateFormat = function() {}; +/** + * Injectable ordering of event plugins. + */ +var eventPluginOrder = null; -{ - validateFormat = function(format) { - if (format === undefined) { - throw new Error("invariant requires an error message argument"); +/** + * Injectable mapping from names to event plugin modules. + */ +var namesToPlugins = {}; + +/** + * Recomputes the plugin list using the injected plugins and plugin ordering. + * + * @private + */ +function recomputePluginOrdering() { + if (!eventPluginOrder) { + // Wait until an `eventPluginOrder` is injected. + return; + } + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName]; + var pluginIndex = eventPluginOrder.indexOf(pluginName); + (function() { + if (!(pluginIndex > -1)) { + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." + ); + } + })(); + if (plugins[pluginIndex]) { + continue; } - }; + (function() { + if (!pluginModule.extractEvents) { + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); + } + })(); + plugins[pluginIndex] = pluginModule; + var publishedEvents = pluginModule.eventTypes; + for (var eventName in publishedEvents) { + (function() { + if ( + !publishEventForPlugin( + publishedEvents[eventName], + pluginModule, + eventName + ) + ) { + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); + } + })(); + } + } } -function invariant(condition, format, a, b, c, d, e, f) { - validateFormat(format); - - if (!condition) { - var error = void 0; - if (format === undefined) { - error = new Error( - "Minified exception occurred; use the non-minified dev environment " + - "for the full error message and additional helpful warnings." +/** + * Publishes an event so that it can be dispatched by the supplied plugin. + * + * @param {object} dispatchConfig Dispatch configuration for the event. + * @param {object} PluginModule Plugin publishing the event. + * @return {boolean} True if the event was successfully published. + * @private + */ +function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { + (function() { + if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName + + "`." ); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - error.name = "Invariant Violation"; } + })(); + eventNameDispatchConfigs[eventName] = dispatchConfig; - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + if (phasedRegistrationNames) { + for (var phaseName in phasedRegistrationNames) { + if (phasedRegistrationNames.hasOwnProperty(phaseName)) { + var phasedRegistrationName = phasedRegistrationNames[phaseName]; + publishRegistrationName( + phasedRegistrationName, + pluginModule, + eventName + ); + } + } + return true; + } else if (dispatchConfig.registrationName) { + publishRegistrationName( + dispatchConfig.registrationName, + pluginModule, + eventName + ); + return true; + } + return false; +} + +/** + * Publishes a registration name that is used to identify dispatched events. + * + * @param {string} registrationName Registration name to add. + * @param {object} PluginModule Plugin publishing the event. + * @private + */ +function publishRegistrationName(registrationName, pluginModule, eventName) { + (function() { + if (!!registrationNameModules[registrationName]) { + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); + } + })(); + registrationNameModules[registrationName] = pluginModule; + registrationNameDependencies[registrationName] = + pluginModule.eventTypes[eventName].dependencies; + + { + var lowerCasedName = registrationName.toLowerCase(); + } +} + +/** + * Registers plugins so that they can extract and dispatch events. + * + * @see {EventPluginHub} + */ + +/** + * Ordered list of injected plugins. + */ +var plugins = []; + +/** + * Mapping from event name to dispatch config + */ +var eventNameDispatchConfigs = {}; + +/** + * Mapping from registration name to plugin module + */ +var registrationNameModules = {}; + +/** + * Mapping from registration name to event name + */ +var registrationNameDependencies = {}; + +/** + * Mapping from lowercase registration names to the properly cased version, + * used to warn in the case of missing event handlers. Available + * only in true. + * @type {Object} + */ + +// Trust the developer to only use possibleRegistrationNames in true + +/** + * Injects an ordering of plugins (by plugin name). This allows the ordering + * to be decoupled from injection of the actual plugins so that ordering is + * always deterministic regardless of packaging, on-the-fly injection, etc. + * + * @param {array} InjectedEventPluginOrder + * @internal + * @see {EventPluginHub.injection.injectEventPluginOrder} + */ +function injectEventPluginOrder(injectedEventPluginOrder) { + (function() { + if (!!eventPluginOrder) { + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); + } + })(); + // Clone the ordering so it cannot be dynamically mutated. + eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); + recomputePluginOrdering(); +} + +/** + * Injects plugins to be used by `EventPluginHub`. The plugin names must be + * in the ordering injected by `injectEventPluginOrder`. + * + * Plugins can be injected as part of page initialization or on-the-fly. + * + * @param {object} injectedNamesToPlugins Map from names to plugin modules. + * @internal + * @see {EventPluginHub.injection.injectEventPluginsByName} + */ +function injectEventPluginsByName(injectedNamesToPlugins) { + var isOrderingDirty = false; + for (var pluginName in injectedNamesToPlugins) { + if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { + continue; + } + var pluginModule = injectedNamesToPlugins[pluginName]; + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + (function() { + if (!!namesToPlugins[pluginName]) { + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + } + })(); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = true; + } + } + if (isOrderingDirty) { + recomputePluginOrdering(); } } @@ -141,16 +349,13 @@ var invokeGuardedCallbackImpl = function( // when we call document.createEvent(). However this can cause confusing // errors: https://github.com/facebookincubator/create-react-app/issues/3482 // So we preemptively throw with a better message instead. - invariant( - typeof document !== "undefined", - "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." - ); + (function() { + if (!(typeof document !== "undefined")) { + throw ReactError( + "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." + ); + } + })(); var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We @@ -373,221 +578,13 @@ function clearCaughtError() { caughtError = null; return error; } else { - invariant( - false, - "clearCaughtError was called but no error was captured. This error " + - "is likely caused by a bug in React. Please file an issue." - ); - } -} - -/** - * Injectable ordering of event plugins. - */ -var eventPluginOrder = null; - -/** - * Injectable mapping from names to event plugin modules. - */ -var namesToPlugins = {}; - -/** - * Recomputes the plugin list using the injected plugins and plugin ordering. - * - * @private - */ -function recomputePluginOrdering() { - if (!eventPluginOrder) { - // Wait until an `eventPluginOrder` is injected. - return; - } - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName]; - var pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - pluginIndex > -1, - "EventPluginRegistry: Cannot inject event plugins that do not exist in " + - "the plugin ordering, `%s`.", - pluginName - ); - if (plugins[pluginIndex]) { - continue; - } - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` " + - "method, but `%s` does not.", - pluginName - ); - plugins[pluginIndex] = pluginModule; - var publishedEvents = pluginModule.eventTypes; - for (var eventName in publishedEvents) { - invariant( - publishEventForPlugin( - publishedEvents[eventName], - pluginModule, - eventName - ), - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); - } - } -} - -/** - * Publishes an event so that it can be dispatched by the supplied plugin. - * - * @param {object} dispatchConfig Dispatch configuration for the event. - * @param {object} PluginModule Plugin publishing the event. - * @return {boolean} True if the event was successfully published. - * @private - */ -function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName), - "EventPluginHub: More than one plugin attempted to publish the same " + - "event name, `%s`.", - eventName - ); - eventNameDispatchConfigs[eventName] = dispatchConfig; - - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - if (phasedRegistrationNames) { - for (var phaseName in phasedRegistrationNames) { - if (phasedRegistrationNames.hasOwnProperty(phaseName)) { - var phasedRegistrationName = phasedRegistrationNames[phaseName]; - publishRegistrationName( - phasedRegistrationName, - pluginModule, - eventName + (function() { + { + throw ReactError( + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); } - } - return true; - } else if (dispatchConfig.registrationName) { - publishRegistrationName( - dispatchConfig.registrationName, - pluginModule, - eventName - ); - return true; - } - return false; -} - -/** - * Publishes a registration name that is used to identify dispatched events. - * - * @param {string} registrationName Registration name to add. - * @param {object} PluginModule Plugin publishing the event. - * @private - */ -function publishRegistrationName(registrationName, pluginModule, eventName) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same " + - "registration name, `%s`.", - registrationName - ); - registrationNameModules[registrationName] = pluginModule; - registrationNameDependencies[registrationName] = - pluginModule.eventTypes[eventName].dependencies; - - { - var lowerCasedName = registrationName.toLowerCase(); - } -} - -/** - * Registers plugins so that they can extract and dispatch events. - * - * @see {EventPluginHub} - */ - -/** - * Ordered list of injected plugins. - */ -var plugins = []; - -/** - * Mapping from event name to dispatch config - */ -var eventNameDispatchConfigs = {}; - -/** - * Mapping from registration name to plugin module - */ -var registrationNameModules = {}; - -/** - * Mapping from registration name to event name - */ -var registrationNameDependencies = {}; - -/** - * Mapping from lowercase registration names to the properly cased version, - * used to warn in the case of missing event handlers. Available - * only in true. - * @type {Object} - */ - -// Trust the developer to only use possibleRegistrationNames in true - -/** - * Injects an ordering of plugins (by plugin name). This allows the ordering - * to be decoupled from injection of the actual plugins so that ordering is - * always deterministic regardless of packaging, on-the-fly injection, etc. - * - * @param {array} InjectedEventPluginOrder - * @internal - * @see {EventPluginHub.injection.injectEventPluginOrder} - */ -function injectEventPluginOrder(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than " + - "once. You are likely trying to load more than one copy of React." - ); - // Clone the ordering so it cannot be dynamically mutated. - eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); - recomputePluginOrdering(); -} - -/** - * Injects plugins to be used by `EventPluginHub`. The plugin names must be - * in the ordering injected by `injectEventPluginOrder`. - * - * Plugins can be injected as part of page initialization or on-the-fly. - * - * @param {object} injectedNamesToPlugins Map from names to plugin modules. - * @internal - * @see {EventPluginHub.injection.injectEventPluginsByName} - */ -function injectEventPluginsByName(injectedNamesToPlugins) { - var isOrderingDirty = false; - for (var pluginName in injectedNamesToPlugins) { - if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { - continue; - } - var pluginModule = injectedNamesToPlugins[pluginName]; - if ( - !namesToPlugins.hasOwnProperty(pluginName) || - namesToPlugins[pluginName] !== pluginModule - ) { - invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins " + - "using the same name, `%s`.", - pluginName - ); - namesToPlugins[pluginName] = pluginModule; - isOrderingDirty = true; - } - } - if (isOrderingDirty) { - recomputePluginOrdering(); + })(); } } @@ -796,10 +793,11 @@ function executeDirectDispatch(event) { } var dispatchListener = event._dispatchListeners; var dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + (function() { + if (!!Array.isArray(dispatchListener)) { + throw ReactError("executeDirectDispatch(...): Invalid `event`."); + } + })(); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -832,10 +830,13 @@ function hasDispatches(event) { */ function accumulateInto(current, next) { - invariant( - next != null, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + (function() { + if (!(next != null)) { + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + } + })(); if (current == null) { return next; @@ -902,6 +903,32 @@ var executeDispatchesAndReleaseTopLevel = function(e) { return executeDispatchesAndRelease(e); }; +function runEventsInBatch(events) { + if (events !== null) { + eventQueue = accumulateInto(eventQueue, events); + } + + // Set `eventQueue` to null before processing it so that we can tell if more + // events get enqueued while processing. + var processingEventQueue = eventQueue; + eventQueue = null; + + if (!processingEventQueue) { + return; + } + + forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); + (function() { + if (!!eventQueue) { + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + } + })(); + // This would be a good time to rethrow if any of the event handlers threw. + rethrowCaughtError(); +} + function isInteractive(tag) { return ( tag === "button" || @@ -992,12 +1019,17 @@ function getListener(inst, registrationName) { if (shouldPreventMouseEvent(registrationName, inst.type, props)) { return null; } - invariant( - !listener || typeof listener === "function", - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + (function() { + if (!(!listener || typeof listener === "function")) { + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } + })(); return listener; } @@ -1008,7 +1040,7 @@ function getListener(inst, registrationName) { * @return {*} An accumulation of synthetic events. * @internal */ -function extractEvents( +function extractPluginEvents( topLevelType, targetInst, nativeEvent, @@ -1033,37 +1065,13 @@ function extractEvents( return events; } -function runEventsInBatch(events) { - if (events !== null) { - eventQueue = accumulateInto(eventQueue, events); - } - - // Set `eventQueue` to null before processing it so that we can tell if more - // events get enqueued while processing. - var processingEventQueue = eventQueue; - eventQueue = null; - - if (!processingEventQueue) { - return; - } - - forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing " + - "an event queue. Support for this has not yet been implemented." - ); - // This would be a good time to rethrow if any of the event handlers threw. - rethrowCaughtError(); -} - -function runExtractedEventsInBatch( +function runExtractedPluginEventsInBatch( topLevelType, targetInst, nativeEvent, nativeEventTarget ) { - var events = extractEvents( + var events = extractPluginEvents( topLevelType, targetInst, nativeEvent, @@ -1091,6 +1099,8 @@ var SimpleMemoComponent = 15; var LazyComponent = 16; var IncompleteClassComponent = 17; var DehydratedSuspenseComponent = 18; +var EventComponent = 19; +var EventTarget = 20; function getParent(inst) { do { @@ -1609,10 +1619,13 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { function releasePooledEvent(event) { var EventConstructor = this; - invariant( - event instanceof EventConstructor, - "Trying to release an event instance into a pool of a different type." - ); + (function() { + if (!(event instanceof EventConstructor)) { + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); + } + })(); event.destructor(); if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { EventConstructor.eventPool.push(event); @@ -1719,7 +1732,11 @@ function resetTouchRecord(touchRecord, touch) { function getTouchIdentifier(_ref) { var identifier = _ref.identifier; - invariant(identifier != null, "Touch object is missing identifier."); + (function() { + if (!(identifier != null)) { + throw ReactError("Touch object is missing identifier."); + } + })(); { !(identifier <= MAX_TOUCH_BANK) ? warningWithoutStack$1( @@ -1847,10 +1864,13 @@ var ResponderTouchHistoryStore = { * @return {*|array<*>} An accumulation of items. */ function accumulate(current, next) { - invariant( - next != null, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + (function() { + if (!(next != null)) { + throw ReactError( + "accumulate(...): Accumulated items must not be null or undefined." + ); + } + })(); if (current == null) { return next; @@ -2462,11 +2482,13 @@ var ReactNativeBridgeEventPlugin = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType]; var directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + (function() { + if (!(bubbleDispatchConfig || directDispatchConfig)) { + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); + } + })(); var event = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -2531,7 +2553,11 @@ function getTagFromInstance(inst) { if (tag === undefined) { tag = inst.stateNode.canonical._nativeTag; } - invariant(tag, "All native instances should have a tag."); + (function() { + if (!tag) { + throw ReactError("All native instances should have a tag."); + } + })(); return tag; } @@ -2557,11 +2583,13 @@ function restoreStateOfTarget(target) { // Unmounted return; } - invariant( - typeof restoreImpl === "function", - "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." - ); + (function() { + if (!(typeof restoreImpl === "function")) { + throw ReactError( + "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." + ); + } + })(); var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); restoreImpl(internalInstance.stateNode, internalInstance.type, props); } @@ -2704,7 +2732,7 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { var nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT; var inst = getInstanceFromTag(rootNodeID); batchedUpdates(function() { - runExtractedEventsInBatch( + runExtractedPluginEventsInBatch( topLevelType, inst, nativeEvent, @@ -2873,6 +2901,17 @@ var REACT_FORWARD_REF_TYPE = hasSymbol var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_EVENT_COMPONENT_TYPE = hasSymbol + ? Symbol.for("react.event_component") + : 0xead5; +var REACT_EVENT_TARGET_TYPE = hasSymbol + ? Symbol.for("react.event_target") + : 0xead6; + +// React event targets +var REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol + ? Symbol.for("react.event_target.touch_hit") + : 0xead7; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2898,6 +2937,22 @@ function refineResolvedLazyComponent(lazyComponent) { return lazyComponent._status === Resolved ? lazyComponent._result : null; } +var debugRenderPhaseSideEffects = false; +var debugRenderPhaseSideEffectsForStrictMode = false; +var enableUserTimingAPI = true; +var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; +var warnAboutDeprecatedLifecycles = true; +var enableProfilerTimer = true; +var enableSchedulerTracing = true; +var enableSuspenseServerRenderer = false; + +var disableYielding = false; + +var warnAboutDeprecatedSetNativeProps = false; +var enableEventAPI = false; + +// Only used in www builds. + function getWrappedName(outerType, innerType, wrapperName) { var functionName = innerType.displayName || innerType.name || ""; return ( @@ -2956,6 +3011,29 @@ function getComponentName(type) { if (resolvedThenable) { return getComponentName(resolvedThenable); } + break; + } + case REACT_EVENT_COMPONENT_TYPE: { + if (enableEventAPI) { + var eventComponent = type; + var displayName = eventComponent.displayName; + if (displayName !== undefined) { + return displayName; + } + } + break; + } + case REACT_EVENT_TARGET_TYPE: { + if (enableEventAPI) { + var eventTarget = type; + if (eventTarget.type === REACT_EVENT_TARGET_TOUCH_HIT) { + return "TouchHitTarget"; + } + var _displayName = eventTarget.displayName; + if (_displayName !== undefined) { + return _displayName; + } + } } } } @@ -3055,10 +3133,11 @@ function isMounted(component) { } function assertIsMounted(fiber) { - invariant( - isFiberMountedImpl(fiber) === MOUNTED, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(isFiberMountedImpl(fiber) === MOUNTED)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } function findCurrentFiberUsingSlowPath(fiber) { @@ -3066,10 +3145,11 @@ function findCurrentFiberUsingSlowPath(fiber) { if (!alternate) { // If there is no alternate, then we only need to check if it is mounted. var state = isFiberMountedImpl(fiber); - invariant( - state !== UNMOUNTED, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(state !== UNMOUNTED)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); if (state === MOUNTING) { return null; } @@ -3082,11 +3162,24 @@ function findCurrentFiberUsingSlowPath(fiber) { var b = alternate; while (true) { var parentA = a.return; - var parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) { + if (parentA === null) { // We're at the root. break; } + var parentB = parentA.alternate; + if (parentB === null) { + // There is no alternate. This is an unusual case. Currently, it only + // happens when a Suspense component is hidden. An extra fragment fiber + // is inserted in between the Suspense fiber and its children. Skip + // over this extra fragment fiber and proceed to the next parent. + var nextParent = parentA.return; + if (nextParent !== null) { + a = b = nextParent; + continue; + } + // If there's no parent, we're at the root. + break; + } // If both copies of the parent fiber point to the same child, we can // assume that the child is current. This happens when we bailout on low @@ -3108,7 +3201,11 @@ function findCurrentFiberUsingSlowPath(fiber) { } // We should never have an alternate for any mounting node. So the only // way this could possibly happen is if this was unmounted, if at all. - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } if (a.return !== b.return) { @@ -3159,26 +3256,31 @@ function findCurrentFiberUsingSlowPath(fiber) { } _child = _child.sibling; } - invariant( - didFindChild, - "Child was not found in either parent set. This indicates a bug " + - "in React related to the return pointer. Please file an issue." - ); + (function() { + if (!didFindChild) { + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); + } + })(); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(a.alternate === b)) { + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // If the root is not a host container, we're in a disconnected tree. I.e. // unmounted. - invariant( - a.tag === HostRoot, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(a.tag === HostRoot)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); if (a.stateNode.current === a) { // We've determined that A is the current branch. return fiber; @@ -3725,19 +3827,6 @@ function warnForStyleProps(props, validAttributes) { } } -var debugRenderPhaseSideEffects = false; -var debugRenderPhaseSideEffectsForStrictMode = false; -var enableUserTimingAPI = true; -var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; -var warnAboutDeprecatedLifecycles = false; -var enableProfilerTimer = true; -var enableSchedulerTracing = true; -var enableSuspenseServerRenderer = false; - -var warnAboutDeprecatedSetNativeProps = false; - -// Only used in www builds. - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); @@ -3791,9 +3880,32 @@ var ReactNativeFiberHostComponent = (function() { onSuccess, onFail /* currently unused */ ) { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } else if ( + relativeToNativeNode.canonical && + relativeToNativeNode.canonical._nativeTag + ) { + relativeNode = relativeToNativeNode.canonical._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + UIManager.measureLayout( this._nativeTag, - relativeToNativeNode, + relativeNode, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); @@ -3832,63 +3944,17 @@ var ReactNativeFiberHostComponent = (function() { return ReactNativeFiberHostComponent; })(); -var hasNativePerformanceNow = - typeof performance === "object" && typeof performance.now === "function"; - -var now$1 = hasNativePerformanceNow - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }; - -var scheduledCallback = null; -var frameDeadline = 0; - -function setTimeoutCallback() { - // TODO (bvaughn) Hard-coded 5ms unblocks initial async testing. - // React API probably changing to boolean rather than time remaining. - // Longer-term plan is to rewrite this using shared memory, - // And just return the value of the bit as the boolean. - frameDeadline = now$1() + 5; - - var callback = scheduledCallback; - scheduledCallback = null; - if (callback !== null) { - callback(); - } -} - -// RN has a poor polyfill for requestIdleCallback so we aren't using it. -// This implementation is only intended for short-term use anyway. -// We also don't implement cancel functionality b'c Fiber doesn't currently need it. -function scheduleDeferredCallback$1(callback, options) { - // We assume only one callback is scheduled at a time b'c that's how Fiber works. - scheduledCallback = callback; - var timeoutId = setTimeout(setTimeoutCallback, 1); - return timeoutId; // Timeouts are always numbers on RN -} - -function cancelDeferredCallback$1(callbackID) { - scheduledCallback = null; - clearTimeout(callbackID); // Timeouts are always numbers on RN -} - -function shouldYield$1() { - return frameDeadline <= now$1(); -} - // Renderers that don't support persistence // can re-export everything from this module. function shim() { - invariant( - false, - "The current renderer does not support persistence. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + (function() { + { + throw ReactError( + "The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // Persistence (when unsupported) @@ -3899,19 +3965,19 @@ var appendChildToContainerChildSet = shim; var finalizeContainerChildren = shim; var replaceContainerChildren = shim; var cloneHiddenInstance = shim; -var cloneUnhiddenInstance = shim; -var createHiddenTextInstance = shim; +var cloneHiddenTextInstance = shim; // Renderers that don't support hydration // can re-export everything from this module. function shim$1() { - invariant( - false, - "The current renderer does not support hydration. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + (function() { + { + throw ReactError( + "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // Hydration (when unsupported) @@ -3995,11 +4061,6 @@ function createInstance( } } - invariant( - type !== "RCTView" || !hostContext.isInAParentText, - "Nesting of within is not currently supported." - ); - var updatePayload = create(props, viewConfig.validAttributes); UIManager.createView( @@ -4025,10 +4086,13 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - invariant( - hostContext.isInAParentText, - "Text strings must be rendered within a component." - ); + (function() { + if (!hostContext.isInAParentText) { + throw ReactError( + "Text strings must be rendered within a component." + ); + } + })(); var tag = allocateTag(); @@ -4092,6 +4156,16 @@ function getChildHostContext(parentHostContext, type, rootContainerInstance) { } } +function getChildHostContextForEventComponent(parentHostContext) { + // TODO: add getChildHostContextForEventComponent implementation + return parentHostContext; +} + +function getChildHostContextForEventTarget(parentHostContext, type) { + // TODO: add getChildHostContextForEventTarget implementation + return parentHostContext; +} + function getPublicInstance(instance) { return instance; } @@ -4115,17 +4189,11 @@ function resetAfterCommit(containerInfo) { // Noop } -var now$$1 = now$1; var isPrimaryRenderer = true; -var scheduleDeferredCallback$$1 = scheduleDeferredCallback$1; -var cancelDeferredCallback$$1 = cancelDeferredCallback$1; -var shouldYield$$1 = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; var noTimeout = -1; -var schedulePassiveEffects = scheduleDeferredCallback$$1; -var cancelPassiveEffects = cancelDeferredCallback$$1; function shouldDeprioritizeSubtree(type, props) { return false; @@ -4260,10 +4328,11 @@ function insertInContainerBefore(parentInstance, child, beforeChild) { // We create a wrapper object for the container in ReactNative render() // Or we refactor to remove wrapper objects entirely. // For more info on pros/cons see PR #8560 description. - invariant( - typeof parentInstance !== "number", - "Container does not support insertBefore operation" - ); + (function() { + if (!(typeof parentInstance !== "number")) { + throw ReactError("Container does not support insertBefore operation"); + } + })(); } function removeChild(parentInstance, child) { @@ -4334,6 +4403,35 @@ function unhideTextInstance(textInstance, text) { throw new Error("Not yet implemented."); } +function mountEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function updateEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function unmountEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function getEventTargetChildElement(type, props) { + throw new Error("Not yet implemented."); +} + +function handleEventTarget( + type, + props, + rootContainerInstance, + internalInstanceHandle +) { + throw new Error("Not yet implemented."); +} + +function commitEventTarget(type, props, instance, parentInstance) { + throw new Error("Not yet implemented."); +} + var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -4647,15 +4745,15 @@ function startRequestCallbackTimer() { } } -function stopRequestCallbackTimer(didExpire, expirationTime) { +function stopRequestCallbackTimer(didExpire) { if (enableUserTimingAPI) { if (supportsUserTiming) { isWaitingForCallback = false; - var warning = didExpire ? "React was blocked by main thread" : null; + var warning = didExpire + ? "Update expired; will flush synchronously" + : null; endMark( - "(Waiting for async callback... will force flush in " + - expirationTime + - " ms)", + "(Waiting for async callback...)", "(Waiting for async callback...)", warning ); @@ -4957,25 +5055,6 @@ function push(cursor, value, fiber) { cursor.current = value; } -function checkThatStackIsEmpty() { - { - if (index !== -1) { - warningWithoutStack$1( - false, - "Expected an empty stack. Something was not reset properly." - ); - } - } -} - -function resetStackAfterFatalErrorInDev() { - { - index = -1; - valueStack.length = 0; - fiberStack.length = 0; - } -} - var warnedAboutMissingGetChildContext = void 0; { @@ -5080,11 +5159,13 @@ function popTopLevelContextObject(fiber) { } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(contextStackCursor.current === emptyContextObject)) { + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); @@ -5126,12 +5207,16 @@ function processChildContext(fiber, type, parentContext) { setCurrentPhase(null); } for (var contextKey in childContext) { - invariant( - contextKey in childContextTypes, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + (function() { + if (!(contextKey in childContextTypes)) { + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); + } + })(); } { var name = getComponentName(type) || "Unknown"; @@ -5176,11 +5261,13 @@ function pushContextProvider(workInProgress) { function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!instance) { + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); if (didChange) { // Merge parent and own context. @@ -5209,11 +5296,13 @@ function invalidateContextProvider(workInProgress, type, didChange) { function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere - invariant( - isFiberMounted(fiber) && fiber.tag === ClassComponent, - "Expected subtree parent to be a mounted class component. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var node = fiber; do { @@ -5230,11 +5319,13 @@ function findCurrentUnmaskedContext(fiber) { } node = node.return; } while (node !== null); - invariant( - false, - "Found unexpected detached subtree parent. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var onCommitFiberRoot = null; @@ -5322,14 +5413,198 @@ function onCommitUnmount(fiber) { // Max 31 bit integer. The max integer size in V8 for 32-bit systems. // Math.pow(2, 30) - 1 // 0b111111111111111111111111111111 -var maxSigned31BitInt = 1073741823; +var MAX_SIGNED_31_BIT_INT = 1073741823; + +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority; +var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback; +var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback; +var Scheduler_shouldYield = Scheduler.unstable_shouldYield; +var Scheduler_now = Scheduler.unstable_now; +var Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel; +var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority; +var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; +var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority; +var Scheduler_LowPriority = Scheduler.unstable_LowPriority; +var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; + +if (enableSchedulerTracing) { + // Provide explicit error message when production+profiling bundle of e.g. + // react-dom is used with production (non-profiling) bundle of + // scheduler/tracing + (function() { + if ( + !( + tracing.__interactionsRef != null && + tracing.__interactionsRef.current != null + ) + ) { + throw ReactError( + "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 http://fb.me/react-profiling" + ); + } + })(); +} + +var fakeCallbackNode = {}; + +// Except for NoPriority, these correspond to Scheduler priorities. We use +// ascending numbers so we can compare them like numbers. They start at 90 to +// avoid clashing with Scheduler's priorities. +var ImmediatePriority = 99; +var UserBlockingPriority = 98; +var NormalPriority = 97; +var LowPriority = 96; +var IdlePriority = 95; +// NoPriority is the absence of priority. Also React-only. + +var shouldYield = disableYielding + ? function() { + return false; + } // Never yield when `disableYielding` is on + : Scheduler_shouldYield; + +var immediateQueue = null; +var immediateQueueCallbackNode = null; +var isFlushingImmediate = false; +var initialTimeMs = Scheduler_now(); + +// If the initial timestamp is reasonably small, use Scheduler's `now` directly. +// This will be the case for modern browsers that support `performance.now`. In +// older browsers, Scheduler falls back to `Date.now`, which returns a Unix +// timestamp. In that case, subtract the module initialization time to simulate +// the behavior of performance.now and keep our times small enough to fit +// within 32 bits. +// TODO: Consider lifting this into Scheduler. +var now = + initialTimeMs < 10000 + ? Scheduler_now + : function() { + return Scheduler_now() - initialTimeMs; + }; + +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return ImmediatePriority; + case Scheduler_UserBlockingPriority: + return UserBlockingPriority; + case Scheduler_NormalPriority: + return NormalPriority; + case Scheduler_LowPriority: + return LowPriority; + case Scheduler_IdlePriority: + return IdlePriority; + default: + (function() { + { + throw ReactError("Unknown priority level."); + } + })(); + } +} + +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case ImmediatePriority: + return Scheduler_ImmediatePriority; + case UserBlockingPriority: + return Scheduler_UserBlockingPriority; + case NormalPriority: + return Scheduler_NormalPriority; + case LowPriority: + return Scheduler_LowPriority; + case IdlePriority: + return Scheduler_IdlePriority; + default: + (function() { + { + throw ReactError("Unknown priority level."); + } + })(); + } +} + +function runWithPriority(reactPriorityLevel, fn) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(priorityLevel, fn); +} + +function scheduleCallback(reactPriorityLevel, callback, options) { + if (reactPriorityLevel === ImmediatePriority) { + // Push this callback into an internal queue. We'll flush these either in + // the next tick, or earlier if something calls `flushImmediateQueue`. + if (immediateQueue === null) { + immediateQueue = [callback]; + // Flush the queue in the next tick, at the earliest. + immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueueImpl + ); + } else { + // Push onto existing queue. Don't need to schedule a callback because + // we already scheduled one when we created the queue. + immediateQueue.push(callback); + } + return fakeCallbackNode; + } + // Otherwise pass through to Scheduler. + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(priorityLevel, callback, options); +} + +function cancelCallback(callbackNode) { + if (callbackNode !== fakeCallbackNode) { + Scheduler_cancelCallback(callbackNode); + } +} + +function flushImmediateQueue() { + if (immediateQueueCallbackNode !== null) { + Scheduler_cancelCallback(immediateQueueCallbackNode); + } + flushImmediateQueueImpl(); +} + +function flushImmediateQueueImpl() { + if (!isFlushingImmediate && immediateQueue !== null) { + // Prevent re-entrancy. + isFlushingImmediate = true; + var i = 0; + try { + var _isSync = true; + for (; i < immediateQueue.length; i++) { + var callback = immediateQueue[i]; + do { + callback = callback(_isSync); + } while (callback !== null); + } + immediateQueue = null; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (immediateQueue !== null) { + immediateQueue = immediateQueue.slice(i + 1); + } + // Resume flushing in the next tick + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueue + ); + throw error; + } finally { + isFlushingImmediate = false; + } + } +} var NoWork = 0; var Never = 1; -var Sync = maxSigned31BitInt; +var Sync = MAX_SIGNED_31_BIT_INT; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; +var MAGIC_NUMBER_OFFSET = MAX_SIGNED_31_BIT_INT - 1; // 1 unit of expiration time represents 10ms. function msToExpirationTime(ms) { @@ -5355,6 +5630,8 @@ function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { ); } +// TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update +// the names to reflect. var LOW_PRIORITY_EXPIRATION = 5000; var LOW_PRIORITY_BATCH_SIZE = 250; @@ -5366,6 +5643,12 @@ function computeAsyncExpiration(currentTime) { ); } +// Same as computeAsyncExpiration but without the bucketing logic. This is +// used to compute timestamps instead of actual expiration times. +function computeAsyncExpirationNoBucket(currentTime) { + return currentTime - LOW_PRIORITY_EXPIRATION / UNIT_SIZE; +} + // We intentionally set a higher expiration time for interactive updates in // dev than in production. // @@ -5388,6 +5671,31 @@ function computeInteractiveExpiration(currentTime) { ); } +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (expirationTime === Sync) { + return ImmediatePriority; + } + if (expirationTime === Never) { + return IdlePriority; + } + var msUntil = + expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime); + if (msUntil <= 0) { + return ImmediatePriority; + } + if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { + return UserBlockingPriority; + } + if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { + return NormalPriority; + } + + // TODO: Handle LowPriority + + // Assume anything lower has idle priority + return IdlePriority; +} + var NoContext = 0; var ConcurrentMode = 1; var StrictMode = 2; @@ -5489,6 +5797,7 @@ function FiberNode(tag, pendingProps, key, mode) { this._debugSource = null; this._debugOwner = null; this._debugIsCurrentlyTiming = false; + this._debugHookTypes = null; if (!hasBadMapPolyfill && typeof Object.preventExtensions === "function") { Object.preventExtensions(this); } @@ -5565,6 +5874,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { workInProgress._debugID = current._debugID; workInProgress._debugSource = current._debugSource; workInProgress._debugOwner = current._debugOwner; + workInProgress._debugHookTypes = current._debugHookTypes; } workInProgress.alternate = current; @@ -5692,6 +6002,28 @@ function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; + case REACT_EVENT_COMPONENT_TYPE: + if (enableEventAPI) { + return createFiberFromEventComponent( + type, + pendingProps, + mode, + expirationTime, + key + ); + } + break; + case REACT_EVENT_TARGET_TYPE: + if (enableEventAPI) { + return createFiberFromEventTarget( + type, + pendingProps, + mode, + expirationTime, + key + ); + } + break; } } var info = ""; @@ -5712,14 +6044,16 @@ function createFiberFromTypeAndProps( info += "\n\nCheck the render method of `" + ownerName + "`."; } } - invariant( - false, - "Element type is invalid: expected a string (for built-in " + - "components) or a class/function (for composite components) " + - "but got: %s.%s", - type == null ? type : typeof type, - info - ); + (function() { + { + throw ReactError( + "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 + ); + } + })(); } } } @@ -5761,6 +6095,38 @@ function createFiberFromFragment(elements, mode, expirationTime, key) { return fiber; } +function createFiberFromEventComponent( + eventComponent, + pendingProps, + mode, + expirationTime, + key +) { + var fiber = createFiber(EventComponent, pendingProps, key, mode); + fiber.elementType = eventComponent; + fiber.type = eventComponent; + fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromEventTarget( + eventTarget, + pendingProps, + mode, + expirationTime, + key +) { + var fiber = createFiber(EventTarget, pendingProps, key, mode); + fiber.elementType = eventTarget; + fiber.type = eventTarget; + fiber.expirationTime = expirationTime; + // Store latest props + fiber.stateNode = { + props: pendingProps + }; + return fiber; +} + function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { { if ( @@ -5883,6 +6249,7 @@ function assignFiberPropertiesInDEV(target, source) { target._debugSource = source._debugSource; target._debugOwner = source._debugOwner; target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; + target._debugHookTypes = source._debugHookTypes; return target; } @@ -5899,81 +6266,131 @@ function assignFiberPropertiesInDEV(target, source) { // The types are defined separately within this file to ensure they stay in sync. // (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.) +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pendingChildren = null; + this.pingCache = null; + this.pendingCommitExpirationTime = NoWork; + this.finishedWork = null; + this.timeoutHandle = noTimeout; + this.context = null; + this.pendingContext = null; + this.hydrate = hydrate; + this.firstBatch = null; + this.callbackNode = null; + this.callbackExpirationTime = NoWork; + this.firstPendingTime = NoWork; + this.lastPendingTime = NoWork; + this.pingTime = NoWork; + + if (enableSchedulerTracing) { + this.interactionThreadID = tracing.unstable_getThreadID(); + this.memoizedInteractions = new Set(); + this.pendingInteractionMap = new Map(); + } +} + function createFiberRoot(containerInfo, isConcurrent, hydrate) { + var root = new FiberRootNode(containerInfo, hydrate); + // Cyclic construction. This cheats the type system right now because // stateNode is any. var uninitializedFiber = createHostRootFiber(isConcurrent); - - var root = void 0; - if (enableSchedulerTracing) { - root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, - - pingCache: null, - - didError: false, - - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null, - - interactionThreadID: tracing.unstable_getThreadID(), - memoizedInteractions: new Set(), - pendingInteractionMap: new Map() - }; - } else { - root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - - pingCache: null, - - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, - - didError: false, - - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null - }; - } - + root.current = uninitializedFiber; uninitializedFiber.stateNode = root; - // The reason for the way the Flow types are structured in this file, - // Is to avoid needing :any casts everywhere interaction tracing fields are used. - // Unfortunately that requires an :any cast for non-interaction tracing capable builds. - // $FlowFixMe Remove this :any cast and replace it with something better. return root; } +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = warningWithoutStack$1; + +{ + warning = function(condition, format) { + if (condition) { + return; + } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + // eslint-disable-next-line react-internal/warning-and-invariant-args + + for ( + var _len = arguments.length, + args = Array(_len > 2 ? _len - 2 : 0), + _key = 2; + _key < _len; + _key++ + ) { + args[_key - 2] = arguments[_key]; + } + + warningWithoutStack$1.apply( + undefined, + [false, format + "%s"].concat(args, [stack]) + ); + }; +} + +var warning$1 = warning; + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + return ( + (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare + ); +} + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * Performs equality by iterating through keys on an object and returning false + * when any key has values which are not strictly equal between the arguments. + * Returns true when the values of all keys are strictly equal. + */ +function shallowEqual(objA, objB) { + if (is(objA, objB)) { + return true; + } + + if ( + typeof objA !== "object" || + objA === null || + typeof objB !== "object" || + objB === null + ) { + return false; + } + + var keysA = Object.keys(objA); + var keysB = Object.keys(objB); + + if (keysA.length !== keysB.length) { + return false; + } + + // Test for A's keys different from B. + for (var i = 0; i < keysA.length; i++) { + if ( + !hasOwnProperty.call(objB, keysA[i]) || + !is(objA[keysA[i]], objB[keysA[i]]) + ) { + return false; + } + } + + return true; +} + /** * Forked from fbjs/warning: * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js @@ -6373,349 +6790,6 @@ var ReactStrictModeWarnings = { }; } -// This lets us hook into Fiber to debug what it's doing. -// See https://github.com/facebook/react/pull/8033. -// This is not part of the public API, not even for React DevTools. -// You may only inject a debugTool if you work on React Fiber itself. -var ReactFiberInstrumentation = { - debugTool: null -}; - -var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; - -// TODO: Offscreen updates should never suspend. However, a promise that -// suspended inside an offscreen subtree should be able to ping at the priority -// of the outer render. - -function markPendingPriorityLevel(root, expirationTime) { - // If there's a gap between completing a failed root and retrying it, - // additional updates may be scheduled. Clear `didError`, in case the update - // is sufficient to fix the error. - root.didError = false; - - // Update the latest and earliest pending times - var earliestPendingTime = root.earliestPendingTime; - if (earliestPendingTime === NoWork) { - // No other pending updates. - root.earliestPendingTime = root.latestPendingTime = expirationTime; - } else { - if (earliestPendingTime < expirationTime) { - // This is the earliest pending update. - root.earliestPendingTime = expirationTime; - } else { - var latestPendingTime = root.latestPendingTime; - if (latestPendingTime > expirationTime) { - // This is the latest pending update - root.latestPendingTime = expirationTime; - } - } - } - findNextExpirationTimeToWorkOn(expirationTime, root); -} - -function markCommittedPriorityLevels(root, earliestRemainingTime) { - root.didError = false; - - if (earliestRemainingTime === NoWork) { - // Fast path. There's no remaining work. Clear everything. - root.earliestPendingTime = NoWork; - root.latestPendingTime = NoWork; - root.earliestSuspendedTime = NoWork; - root.latestSuspendedTime = NoWork; - root.latestPingedTime = NoWork; - findNextExpirationTimeToWorkOn(NoWork, root); - return; - } - - if (earliestRemainingTime < root.latestPingedTime) { - root.latestPingedTime = NoWork; - } - - // Let's see if the previous latest known pending level was just flushed. - var latestPendingTime = root.latestPendingTime; - if (latestPendingTime !== NoWork) { - if (latestPendingTime > earliestRemainingTime) { - // We've flushed all the known pending levels. - root.earliestPendingTime = root.latestPendingTime = NoWork; - } else { - var earliestPendingTime = root.earliestPendingTime; - if (earliestPendingTime > earliestRemainingTime) { - // We've flushed the earliest known pending level. Set this to the - // latest pending time. - root.earliestPendingTime = root.latestPendingTime; - } - } - } - - // Now let's handle the earliest remaining level in the whole tree. We need to - // decide whether to treat it as a pending level or as suspended. Check - // it falls within the range of known suspended levels. - - var earliestSuspendedTime = root.earliestSuspendedTime; - if (earliestSuspendedTime === NoWork) { - // There's no suspended work. Treat the earliest remaining level as a - // pending level. - markPendingPriorityLevel(root, earliestRemainingTime); - findNextExpirationTimeToWorkOn(NoWork, root); - return; - } - - var latestSuspendedTime = root.latestSuspendedTime; - if (earliestRemainingTime < latestSuspendedTime) { - // The earliest remaining level is later than all the suspended work. That - // means we've flushed all the suspended work. - root.earliestSuspendedTime = NoWork; - root.latestSuspendedTime = NoWork; - root.latestPingedTime = NoWork; - - // There's no suspended work. Treat the earliest remaining level as a - // pending level. - markPendingPriorityLevel(root, earliestRemainingTime); - findNextExpirationTimeToWorkOn(NoWork, root); - return; - } - - if (earliestRemainingTime > earliestSuspendedTime) { - // The earliest remaining time is earlier than all the suspended work. - // Treat it as a pending update. - markPendingPriorityLevel(root, earliestRemainingTime); - findNextExpirationTimeToWorkOn(NoWork, root); - return; - } - - // The earliest remaining time falls within the range of known suspended - // levels. We should treat this as suspended work. - findNextExpirationTimeToWorkOn(NoWork, root); -} - -function hasLowerPriorityWork(root, erroredExpirationTime) { - var latestPendingTime = root.latestPendingTime; - var latestSuspendedTime = root.latestSuspendedTime; - var latestPingedTime = root.latestPingedTime; - return ( - (latestPendingTime !== NoWork && - latestPendingTime < erroredExpirationTime) || - (latestSuspendedTime !== NoWork && - latestSuspendedTime < erroredExpirationTime) || - (latestPingedTime !== NoWork && latestPingedTime < erroredExpirationTime) - ); -} - -function isPriorityLevelSuspended(root, expirationTime) { - var earliestSuspendedTime = root.earliestSuspendedTime; - var latestSuspendedTime = root.latestSuspendedTime; - return ( - earliestSuspendedTime !== NoWork && - expirationTime <= earliestSuspendedTime && - expirationTime >= latestSuspendedTime - ); -} - -function markSuspendedPriorityLevel(root, suspendedTime) { - root.didError = false; - clearPing(root, suspendedTime); - - // First, check the known pending levels and update them if needed. - var earliestPendingTime = root.earliestPendingTime; - var latestPendingTime = root.latestPendingTime; - if (earliestPendingTime === suspendedTime) { - if (latestPendingTime === suspendedTime) { - // Both known pending levels were suspended. Clear them. - root.earliestPendingTime = root.latestPendingTime = NoWork; - } else { - // The earliest pending level was suspended. Clear by setting it to the - // latest pending level. - root.earliestPendingTime = latestPendingTime; - } - } else if (latestPendingTime === suspendedTime) { - // The latest pending level was suspended. Clear by setting it to the - // latest pending level. - root.latestPendingTime = earliestPendingTime; - } - - // Finally, update the known suspended levels. - var earliestSuspendedTime = root.earliestSuspendedTime; - var latestSuspendedTime = root.latestSuspendedTime; - if (earliestSuspendedTime === NoWork) { - // No other suspended levels. - root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime; - } else { - if (earliestSuspendedTime < suspendedTime) { - // This is the earliest suspended level. - root.earliestSuspendedTime = suspendedTime; - } else if (latestSuspendedTime > suspendedTime) { - // This is the latest suspended level - root.latestSuspendedTime = suspendedTime; - } - } - - findNextExpirationTimeToWorkOn(suspendedTime, root); -} - -function markPingedPriorityLevel(root, pingedTime) { - root.didError = false; - - // TODO: When we add back resuming, we need to ensure the progressed work - // is thrown out and not reused during the restarted render. One way to - // invalidate the progressed work is to restart at expirationTime + 1. - var latestPingedTime = root.latestPingedTime; - if (latestPingedTime === NoWork || latestPingedTime > pingedTime) { - root.latestPingedTime = pingedTime; - } - findNextExpirationTimeToWorkOn(pingedTime, root); -} - -function clearPing(root, completedTime) { - var latestPingedTime = root.latestPingedTime; - if (latestPingedTime >= completedTime) { - root.latestPingedTime = NoWork; - } -} - -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestExpirationTime = renderExpirationTime; - - var earliestPendingTime = root.earliestPendingTime; - var earliestSuspendedTime = root.earliestSuspendedTime; - if (earliestPendingTime > earliestExpirationTime) { - earliestExpirationTime = earliestPendingTime; - } - if (earliestSuspendedTime > earliestExpirationTime) { - earliestExpirationTime = earliestSuspendedTime; - } - return earliestExpirationTime; -} - -function didExpireAtExpirationTime(root, currentTime) { - var expirationTime = root.expirationTime; - if (expirationTime !== NoWork && currentTime <= expirationTime) { - // The root has expired. Flush all work up to the current time. - root.nextExpirationTimeToWorkOn = currentTime; - } -} - -function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { - var earliestSuspendedTime = root.earliestSuspendedTime; - var latestSuspendedTime = root.latestSuspendedTime; - var earliestPendingTime = root.earliestPendingTime; - var latestPingedTime = root.latestPingedTime; - - // Work on the earliest pending time. Failing that, work on the latest - // pinged time. - var nextExpirationTimeToWorkOn = - earliestPendingTime !== NoWork ? earliestPendingTime : latestPingedTime; - - // If there is no pending or pinged work, check if there's suspended work - // that's lower priority than what we just completed. - if ( - nextExpirationTimeToWorkOn === NoWork && - (completedExpirationTime === NoWork || - latestSuspendedTime < completedExpirationTime) - ) { - // The lowest priority suspended work is the work most likely to be - // committed next. Let's start rendering it again, so that if it times out, - // it's ready to commit. - nextExpirationTimeToWorkOn = latestSuspendedTime; - } - - var expirationTime = nextExpirationTimeToWorkOn; - if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) { - // Expire using the earliest known expiration time. - expirationTime = earliestSuspendedTime; - } - - root.nextExpirationTimeToWorkOn = nextExpirationTimeToWorkOn; - root.expirationTime = expirationTime; -} - -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - undefined, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - */ -function is(x, y) { - return ( - (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare - ); -} - -var hasOwnProperty = Object.prototype.hasOwnProperty; - -/** - * Performs equality by iterating through keys on an object and returning false - * when any key has values which are not strictly equal between the arguments. - * Returns true when the values of all keys are strictly equal. - */ -function shallowEqual(objA, objB) { - if (is(objA, objB)) { - return true; - } - - if ( - typeof objA !== "object" || - objA === null || - typeof objB !== "object" || - objB === null - ) { - return false; - } - - var keysA = Object.keys(objA); - var keysB = Object.keys(objB); - - if (keysA.length !== keysB.length) { - return false; - } - - // Test for A's keys different from B. - for (var i = 0; i < keysA.length; i++) { - if ( - !hasOwnProperty.call(objB, keysA[i]) || - !is(objA[keysA[i]], objB[keysA[i]]) - ) { - return false; - } - } - - return true; -} - function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { // Resolve default props. Taken from ReactElement @@ -6790,6 +6864,912 @@ function readLazyComponentType(lazyComponent) { } } +var valueCursor = createCursor(null); + +var rendererSigil = void 0; +{ + // Use this to detect multiple renderers using the same context + rendererSigil = {}; +} + +var currentlyRenderingFiber = null; +var lastContextDependency = null; +var lastContextWithAllBitsObserved = null; + +var isDisallowedContextReadInDEV = false; + +function resetContextDependences() { + // This is called right before React yields execution, to ensure `readContext` + // cannot be called outside the render phase. + currentlyRenderingFiber = null; + lastContextDependency = null; + lastContextWithAllBitsObserved = null; + { + isDisallowedContextReadInDEV = false; + } +} + +function enterDisallowedContextReadInDEV() { + { + isDisallowedContextReadInDEV = true; + } +} + +function exitDisallowedContextReadInDEV() { + { + isDisallowedContextReadInDEV = false; + } +} + +function pushProvider(providerFiber, nextValue) { + var context = providerFiber.type._context; + + if (isPrimaryRenderer) { + push(valueCursor, context._currentValue, providerFiber); + + context._currentValue = nextValue; + { + !( + context._currentRenderer === undefined || + context._currentRenderer === null || + context._currentRenderer === rendererSigil + ) + ? warningWithoutStack$1( + false, + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ) + : void 0; + context._currentRenderer = rendererSigil; + } + } else { + push(valueCursor, context._currentValue2, providerFiber); + + context._currentValue2 = nextValue; + { + !( + context._currentRenderer2 === undefined || + context._currentRenderer2 === null || + context._currentRenderer2 === rendererSigil + ) + ? warningWithoutStack$1( + false, + "Detected multiple renderers concurrently rendering the " + + "same context provider. This is currently unsupported." + ) + : void 0; + context._currentRenderer2 = rendererSigil; + } + } +} + +function popProvider(providerFiber) { + var currentValue = valueCursor.current; + + pop(valueCursor, providerFiber); + + var context = providerFiber.type._context; + if (isPrimaryRenderer) { + context._currentValue = currentValue; + } else { + context._currentValue2 = currentValue; + } +} + +function calculateChangedBits(context, newValue, oldValue) { + if (is(oldValue, newValue)) { + // No change + return 0; + } else { + var changedBits = + typeof context._calculateChangedBits === "function" + ? context._calculateChangedBits(oldValue, newValue) + : MAX_SIGNED_31_BIT_INT; + + { + !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) + ? warning$1( + false, + "calculateChangedBits: Expected the return value to be a " + + "31-bit integer. Instead received: %s", + changedBits + ) + : void 0; + } + return changedBits | 0; + } +} + +function scheduleWorkOnParentPath(parent, renderExpirationTime) { + // Update the child expiration time of all the ancestors, including + // the alternates. + var node = parent; + while (node !== null) { + var alternate = node.alternate; + if (node.childExpirationTime < renderExpirationTime) { + node.childExpirationTime = renderExpirationTime; + if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; + } + } else if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; + } else { + // Neither alternate was updated, which means the rest of the + // ancestor path already has sufficient priority. + break; + } + node = node.return; + } +} + +function propagateContextChange( + workInProgress, + context, + changedBits, + renderExpirationTime +) { + var fiber = workInProgress.child; + if (fiber !== null) { + // Set the return pointer of the child to the work-in-progress fiber. + fiber.return = workInProgress; + } + while (fiber !== null) { + var nextFiber = void 0; + + // Visit this fiber. + var list = fiber.contextDependencies; + if (list !== null) { + nextFiber = fiber.child; + + var dependency = list.first; + while (dependency !== null) { + // Check if the context matches. + if ( + dependency.context === context && + (dependency.observedBits & changedBits) !== 0 + ) { + // Match! Schedule an update on this fiber. + + if (fiber.tag === ClassComponent) { + // Schedule a force update on the work-in-progress. + var update = createUpdate(renderExpirationTime); + update.tag = ForceUpdate; + // TODO: Because we don't have a work-in-progress, this will add the + // update to the current fiber, too, which means it will persist even if + // this render is thrown away. Since it's a race condition, not sure it's + // worth fixing. + enqueueUpdate(fiber, update); + } + + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; + } + var alternate = fiber.alternate; + if ( + alternate !== null && + alternate.expirationTime < renderExpirationTime + ) { + alternate.expirationTime = renderExpirationTime; + } + + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); + + // Mark the expiration time on the list, too. + if (list.expirationTime < renderExpirationTime) { + list.expirationTime = renderExpirationTime; + } + + // Since we already found a match, we can stop traversing the + // dependency list. + break; + } + dependency = dependency.next; + } + } else if (fiber.tag === ContextProvider) { + // Don't scan deeper if this is a matching provider + nextFiber = fiber.type === workInProgress.type ? null : fiber.child; + } else if ( + enableSuspenseServerRenderer && + fiber.tag === DehydratedSuspenseComponent + ) { + // If a dehydrated suspense component is in this subtree, we don't know + // if it will have any context consumers in it. The best we can do is + // mark it as having updates on its children. + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; + } + var _alternate = fiber.alternate; + if ( + _alternate !== null && + _alternate.expirationTime < renderExpirationTime + ) { + _alternate.expirationTime = renderExpirationTime; + } + // This is intentionally passing this fiber as the parent + // because we want to schedule this fiber as having work + // on its children. We'll use the childExpirationTime on + // this fiber to indicate that a context has changed. + scheduleWorkOnParentPath(fiber, renderExpirationTime); + nextFiber = fiber.sibling; + } else { + // Traverse down. + nextFiber = fiber.child; + } + + if (nextFiber !== null) { + // Set the return pointer of the child to the work-in-progress fiber. + nextFiber.return = fiber; + } else { + // No child. Traverse to next sibling. + nextFiber = fiber; + while (nextFiber !== null) { + if (nextFiber === workInProgress) { + // We're back to the root of this subtree. Exit. + nextFiber = null; + break; + } + var sibling = nextFiber.sibling; + if (sibling !== null) { + // Set the return pointer of the sibling to the work-in-progress fiber. + sibling.return = nextFiber.return; + nextFiber = sibling; + break; + } + // No more siblings. Traverse up. + nextFiber = nextFiber.return; + } + } + fiber = nextFiber; + } +} + +function prepareToReadContext(workInProgress, renderExpirationTime) { + currentlyRenderingFiber = workInProgress; + lastContextDependency = null; + lastContextWithAllBitsObserved = null; + + var currentDependencies = workInProgress.contextDependencies; + if ( + currentDependencies !== null && + currentDependencies.expirationTime >= renderExpirationTime + ) { + // Context list has a pending update. Mark that this fiber performed work. + markWorkInProgressReceivedUpdate(); + } + + // Reset the work-in-progress list + workInProgress.contextDependencies = null; +} + +function readContext(context, observedBits) { + { + // This warning would fire if you read context inside a Hook like useMemo. + // Unlike the class check below, it's not enforced in production for perf. + !!isDisallowedContextReadInDEV + ? warning$1( + false, + "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()." + ) + : void 0; + } + + if (lastContextWithAllBitsObserved === context) { + // Nothing to do. We already observe everything in this context. + } else if (observedBits === false || observedBits === 0) { + // Do not observe any updates. + } else { + var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types. + if ( + typeof observedBits !== "number" || + observedBits === MAX_SIGNED_31_BIT_INT + ) { + // Observe all updates. + lastContextWithAllBitsObserved = context; + resolvedObservedBits = MAX_SIGNED_31_BIT_INT; + } else { + resolvedObservedBits = observedBits; + } + + var contextItem = { + context: context, + observedBits: resolvedObservedBits, + next: null + }; + + if (lastContextDependency === null) { + (function() { + if (!(currentlyRenderingFiber !== null)) { + throw ReactError( + "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()." + ); + } + })(); + + // This is the first dependency for this component. Create a new list. + lastContextDependency = contextItem; + currentlyRenderingFiber.contextDependencies = { + first: contextItem, + expirationTime: NoWork + }; + } else { + // Append a new context item. + lastContextDependency = lastContextDependency.next = contextItem; + } + } + return isPrimaryRenderer ? context._currentValue : context._currentValue2; +} + +// UpdateQueue is a linked list of prioritized updates. +// +// Like fibers, update queues come in pairs: a current queue, which represents +// the visible state of the screen, and a work-in-progress queue, which can be +// mutated and processed asynchronously before it is committed — a form of +// double buffering. If a work-in-progress render is discarded before finishing, +// we create a new work-in-progress by cloning the current queue. +// +// Both queues share a persistent, singly-linked list structure. To schedule an +// update, we append it to the end of both queues. Each queue maintains a +// pointer to first update in the persistent list that hasn't been processed. +// The work-in-progress pointer always has a position equal to or greater than +// the current queue, since we always work on that one. The current queue's +// pointer is only updated during the commit phase, when we swap in the +// work-in-progress. +// +// For example: +// +// Current pointer: A - B - C - D - E - F +// Work-in-progress pointer: D - E - F +// ^ +// The work-in-progress queue has +// processed more updates than current. +// +// The reason we append to both queues is because otherwise we might drop +// updates without ever processing them. For example, if we only add updates to +// the work-in-progress queue, some updates could be lost whenever a work-in +// -progress render restarts by cloning from current. Similarly, if we only add +// updates to the current queue, the updates will be lost whenever an already +// in-progress queue commits and swaps with the current queue. However, by +// adding to both queues, we guarantee that the update will be part of the next +// work-in-progress. (And because the work-in-progress queue becomes the +// current queue once it commits, there's no danger of applying the same +// update twice.) +// +// Prioritization +// -------------- +// +// Updates are not sorted by priority, but by insertion; new updates are always +// appended to the end of the list. +// +// The priority is still important, though. When processing the update queue +// during the render phase, only the updates with sufficient priority are +// included in the result. If we skip an update because it has insufficient +// priority, it remains in the queue to be processed later, during a lower +// priority render. Crucially, all updates subsequent to a skipped update also +// remain in the queue *regardless of their priority*. That means high priority +// updates are sometimes processed twice, at two separate priorities. We also +// keep track of a base state, that represents the state before the first +// update in the queue is applied. +// +// For example: +// +// Given a base state of '', and the following queue of updates +// +// A1 - B2 - C1 - D2 +// +// where the number indicates the priority, and the update is applied to the +// previous state by appending a letter, React will process these updates as +// two separate renders, one per distinct priority level: +// +// First render, at priority 1: +// Base state: '' +// Updates: [A1, C1] +// Result state: 'AC' +// +// Second render, at priority 2: +// Base state: 'A' <- The base state does not include C1, +// because B2 was skipped. +// Updates: [B2, C1, D2] <- C1 was rebased on top of B2 +// Result state: 'ABCD' +// +// Because we process updates in insertion order, and rebase high priority +// updates when preceding updates are skipped, the final result is deterministic +// regardless of priority. Intermediate state may vary according to system +// resources, but the final state is always the same. + +var UpdateState = 0; +var ReplaceState = 1; +var ForceUpdate = 2; +var CaptureUpdate = 3; + +// Global state that is reset at the beginning of calling `processUpdateQueue`. +// It should only be read right after calling `processUpdateQueue`, via +// `checkHasForceUpdateAfterProcessing`. +var hasForceUpdate = false; + +var didWarnUpdateInsideUpdate = void 0; +var currentlyProcessingQueue = void 0; + +{ + didWarnUpdateInsideUpdate = false; + currentlyProcessingQueue = null; +} + +function createUpdateQueue(baseState) { + var queue = { + baseState: baseState, + firstUpdate: null, + lastUpdate: null, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; + return queue; +} + +function cloneUpdateQueue(currentQueue) { + var queue = { + baseState: currentQueue.baseState, + firstUpdate: currentQueue.firstUpdate, + lastUpdate: currentQueue.lastUpdate, + + // TODO: With resuming, if we bail out and resuse the child tree, we should + // keep these effects. + firstCapturedUpdate: null, + lastCapturedUpdate: null, + + firstEffect: null, + lastEffect: null, + + firstCapturedEffect: null, + lastCapturedEffect: null + }; + return queue; +} + +function createUpdate(expirationTime) { + return { + expirationTime: expirationTime, + + tag: UpdateState, + payload: null, + callback: null, + + next: null, + nextEffect: null + }; +} + +function appendUpdateToQueue(queue, update) { + // Append the update to the end of the list. + if (queue.lastUpdate === null) { + // Queue is empty + queue.firstUpdate = queue.lastUpdate = update; + } else { + queue.lastUpdate.next = update; + queue.lastUpdate = update; + } +} + +function enqueueUpdate(fiber, update) { + // Update queues are created lazily. + var alternate = fiber.alternate; + var queue1 = void 0; + var queue2 = void 0; + if (alternate === null) { + // There's only one fiber. + queue1 = fiber.updateQueue; + queue2 = null; + if (queue1 === null) { + queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); + } + } else { + // There are two owners. + queue1 = fiber.updateQueue; + queue2 = alternate.updateQueue; + if (queue1 === null) { + if (queue2 === null) { + // Neither fiber has an update queue. Create new ones. + queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); + queue2 = alternate.updateQueue = createUpdateQueue( + alternate.memoizedState + ); + } else { + // Only one fiber has an update queue. Clone to create a new one. + queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); + } + } else { + if (queue2 === null) { + // Only one fiber has an update queue. Clone to create a new one. + queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); + } else { + // Both owners have an update queue. + } + } + } + if (queue2 === null || queue1 === queue2) { + // There's only a single queue. + appendUpdateToQueue(queue1, update); + } else { + // There are two queues. We need to append the update to both queues, + // while accounting for the persistent structure of the list — we don't + // want the same update to be added multiple times. + if (queue1.lastUpdate === null || queue2.lastUpdate === null) { + // One of the queues is not empty. We must add the update to both queues. + appendUpdateToQueue(queue1, update); + appendUpdateToQueue(queue2, update); + } else { + // Both queues are non-empty. The last update is the same in both lists, + // because of structural sharing. So, only append to one of the lists. + appendUpdateToQueue(queue1, update); + // But we still need to update the `lastUpdate` pointer of queue2. + queue2.lastUpdate = update; + } + } + + { + if ( + fiber.tag === ClassComponent && + (currentlyProcessingQueue === queue1 || + (queue2 !== null && currentlyProcessingQueue === queue2)) && + !didWarnUpdateInsideUpdate + ) { + warningWithoutStack$1( + false, + "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." + ); + didWarnUpdateInsideUpdate = true; + } + } +} + +function enqueueCapturedUpdate(workInProgress, update) { + // Captured updates go into a separate list, and only on the work-in- + // progress queue. + var workInProgressQueue = workInProgress.updateQueue; + if (workInProgressQueue === null) { + workInProgressQueue = workInProgress.updateQueue = createUpdateQueue( + workInProgress.memoizedState + ); + } else { + // TODO: I put this here rather than createWorkInProgress so that we don't + // clone the queue unnecessarily. There's probably a better way to + // structure this. + workInProgressQueue = ensureWorkInProgressQueueIsAClone( + workInProgress, + workInProgressQueue + ); + } + + // Append the update to the end of the list. + if (workInProgressQueue.lastCapturedUpdate === null) { + // This is the first render phase update + workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update; + } else { + workInProgressQueue.lastCapturedUpdate.next = update; + workInProgressQueue.lastCapturedUpdate = update; + } +} + +function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { + var current = workInProgress.alternate; + if (current !== null) { + // If the work-in-progress queue is equal to the current queue, + // we need to clone it first. + if (queue === current.updateQueue) { + queue = workInProgress.updateQueue = cloneUpdateQueue(queue); + } + } + return queue; +} + +function getStateFromUpdate( + workInProgress, + queue, + update, + prevState, + nextProps, + instance +) { + switch (update.tag) { + case ReplaceState: { + var _payload = update.payload; + if (typeof _payload === "function") { + // Updater function + { + enterDisallowedContextReadInDEV(); + if ( + debugRenderPhaseSideEffects || + (debugRenderPhaseSideEffectsForStrictMode && + workInProgress.mode & StrictMode) + ) { + _payload.call(instance, prevState, nextProps); + } + } + var nextState = _payload.call(instance, prevState, nextProps); + { + exitDisallowedContextReadInDEV(); + } + return nextState; + } + // State object + return _payload; + } + case CaptureUpdate: { + workInProgress.effectTag = + (workInProgress.effectTag & ~ShouldCapture) | DidCapture; + } + // Intentional fallthrough + case UpdateState: { + var _payload2 = update.payload; + var partialState = void 0; + if (typeof _payload2 === "function") { + // Updater function + { + enterDisallowedContextReadInDEV(); + if ( + debugRenderPhaseSideEffects || + (debugRenderPhaseSideEffectsForStrictMode && + workInProgress.mode & StrictMode) + ) { + _payload2.call(instance, prevState, nextProps); + } + } + partialState = _payload2.call(instance, prevState, nextProps); + { + exitDisallowedContextReadInDEV(); + } + } else { + // Partial state object + partialState = _payload2; + } + if (partialState === null || partialState === undefined) { + // Null and undefined are treated as no-ops. + return prevState; + } + // Merge the partial state and the previous state. + return Object.assign({}, prevState, partialState); + } + case ForceUpdate: { + hasForceUpdate = true; + return prevState; + } + } + return prevState; +} + +function processUpdateQueue( + workInProgress, + queue, + props, + instance, + renderExpirationTime +) { + hasForceUpdate = false; + + queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); + + { + currentlyProcessingQueue = queue; + } + + // These values may change as we process the queue. + var newBaseState = queue.baseState; + var newFirstUpdate = null; + var newExpirationTime = NoWork; + + // Iterate through the list of updates to compute the result. + var update = queue.firstUpdate; + var resultState = newBaseState; + while (update !== null) { + var updateExpirationTime = update.expirationTime; + if (updateExpirationTime < renderExpirationTime) { + // This update does not have sufficient priority. Skip it. + if (newFirstUpdate === null) { + // This is the first skipped update. It will be the first update in + // the new list. + newFirstUpdate = update; + // Since this is the first update that was skipped, the current result + // is the new base state. + newBaseState = resultState; + } + // Since this update will remain in the list, update the remaining + // expiration time. + if (newExpirationTime < updateExpirationTime) { + newExpirationTime = updateExpirationTime; + } + } else { + // This update does have sufficient priority. + + // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + markRenderEventTime(updateExpirationTime); + + // Process it and compute a new result. + resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + ); + var _callback = update.callback; + if (_callback !== null) { + workInProgress.effectTag |= Callback; + // Set this to null, in case it was mutated during an aborted render. + update.nextEffect = null; + if (queue.lastEffect === null) { + queue.firstEffect = queue.lastEffect = update; + } else { + queue.lastEffect.nextEffect = update; + queue.lastEffect = update; + } + } + } + // Continue to the next update. + update = update.next; + } + + // Separately, iterate though the list of captured updates. + var newFirstCapturedUpdate = null; + update = queue.firstCapturedUpdate; + while (update !== null) { + var _updateExpirationTime = update.expirationTime; + if (_updateExpirationTime < renderExpirationTime) { + // This update does not have sufficient priority. Skip it. + if (newFirstCapturedUpdate === null) { + // This is the first skipped captured update. It will be the first + // update in the new list. + newFirstCapturedUpdate = update; + // If this is the first update that was skipped, the current result is + // the new base state. + if (newFirstUpdate === null) { + newBaseState = resultState; + } + } + // Since this update will remain in the list, update the remaining + // expiration time. + if (newExpirationTime < _updateExpirationTime) { + newExpirationTime = _updateExpirationTime; + } + } else { + // This update does have sufficient priority. Process it and compute + // a new result. + resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + ); + var _callback2 = update.callback; + if (_callback2 !== null) { + workInProgress.effectTag |= Callback; + // Set this to null, in case it was mutated during an aborted render. + update.nextEffect = null; + if (queue.lastCapturedEffect === null) { + queue.firstCapturedEffect = queue.lastCapturedEffect = update; + } else { + queue.lastCapturedEffect.nextEffect = update; + queue.lastCapturedEffect = update; + } + } + } + update = update.next; + } + + if (newFirstUpdate === null) { + queue.lastUpdate = null; + } + if (newFirstCapturedUpdate === null) { + queue.lastCapturedUpdate = null; + } else { + workInProgress.effectTag |= Callback; + } + if (newFirstUpdate === null && newFirstCapturedUpdate === null) { + // We processed every update, without skipping. That means the new base + // state is the same as the result state. + newBaseState = resultState; + } + + queue.baseState = newBaseState; + queue.firstUpdate = newFirstUpdate; + queue.firstCapturedUpdate = newFirstCapturedUpdate; + + // Set the remaining expiration time to be whatever is remaining in the queue. + // This should be fine because the only two other things that contribute to + // expiration time are props and context. We're already in the middle of the + // begin phase by the time we start processing the queue, so we've already + // dealt with the props. Context in components that specify + // shouldComponentUpdate is tricky; but we'll have to account for + // that regardless. + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = resultState; + + { + currentlyProcessingQueue = null; + } +} + +function callCallback(callback, context) { + (function() { + if (!(typeof callback === "function")) { + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + } + })(); + callback.call(context); +} + +function resetHasForceUpdateBeforeProcessing() { + hasForceUpdate = false; +} + +function checkHasForceUpdateAfterProcessing() { + return hasForceUpdate; +} + +function commitUpdateQueue( + finishedWork, + finishedQueue, + instance, + renderExpirationTime +) { + // If the finished render included captured updates, and there are still + // lower priority updates left over, we need to keep the captured updates + // in the queue so that they are rebased and not dropped once we process the + // queue again at the lower priority. + if (finishedQueue.firstCapturedUpdate !== null) { + // Join the captured update list to the end of the normal list. + if (finishedQueue.lastUpdate !== null) { + finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate; + finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate; + } + // Clear the list of captured updates. + finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null; + } + + // Commit the effects + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} + +function commitUpdateEffects(effect, instance) { + while (effect !== null) { + var _callback3 = effect.callback; + if (_callback3 !== null) { + effect.callback = null; + callCallback(_callback3, instance); + } + effect = effect.nextEffect; + } +} + var fakeInternalInstance = {}; var isArray$1 = Array.isArray; @@ -6860,15 +7840,13 @@ var didWarnAboutInvalidateContextType = void 0; Object.defineProperty(fakeInternalInstance, "_processChildContext", { enumerable: false, value: function() { - invariant( - false, - "_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)." - ); + (function() { + { + throw ReactError( + "_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)." + ); + } + })(); } }); Object.freeze(fakeInternalInstance); @@ -7282,23 +8260,51 @@ function constructClassInstance( var unmaskedContext = emptyContextObject; var context = null; var contextType = ctor.contextType; - if (typeof contextType === "object" && contextType !== null) { - { - if ( - contextType.$$typeof !== REACT_CONTEXT_TYPE && - !didWarnAboutInvalidateContextType.has(ctor) - ) { + + { + if ("contextType" in ctor) { + var isValid = + // Allow null for conditional declaration + contextType === null || + (contextType !== undefined && + contextType.$$typeof === REACT_CONTEXT_TYPE && + contextType._context === undefined); // Not a + + if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { didWarnAboutInvalidateContextType.add(ctor); + + var addendum = ""; + if (contextType === undefined) { + 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."; + } else if (typeof contextType !== "object") { + addendum = " However, it is set to a " + typeof contextType + "."; + } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { + addendum = " Did you accidentally pass the Context.Provider instead?"; + } else if (contextType._context !== undefined) { + // + addendum = " Did you accidentally pass the Context.Consumer instead?"; + } else { + addendum = + " However, it is set to an object with keys {" + + Object.keys(contextType).join(", ") + + "}."; + } warningWithoutStack$1( false, "%s defines an invalid contextType. " + - "contextType should point to the Context object returned by React.createContext(). " + - "Did you accidentally pass the Context.Provider instead?", - getComponentName(ctor) || "Component" + "contextType should point to the Context object returned by React.createContext().%s", + getComponentName(ctor) || "Component", + addendum ); } } + } + if (typeof contextType === "object" && contextType !== null) { context = readContext(contextType); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); @@ -7940,11 +8946,13 @@ var warnForMissingKey = function(child) {}; if (!child._store || child._store.validated || child.key != null) { return; } - invariant( - typeof child._store === "object", - "React Component in warnForMissingKey should have a _store. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(typeof child._store === "object")) { + throw ReactError( + "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); child._store.validated = true; var currentComponentErrorInfo = @@ -8000,19 +9008,24 @@ function coerceRef(returnFiber, current$$1, element) { var inst = void 0; if (owner) { var ownerFiber = owner; - invariant( - ownerFiber.tag === ClassComponent, - "Function components cannot have refs. " + - "Did you mean to use React.forwardRef()?" - ); + (function() { + if (!(ownerFiber.tag === ClassComponent)) { + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + } + })(); inst = ownerFiber.stateNode; } - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a " + - "bug in React. Please file an issue.", - mixedRef - ); + (function() { + if (!inst) { + throw ReactError( + "Missing owner for string ref " + + mixedRef + + ". This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref if ( @@ -8038,20 +9051,22 @@ function coerceRef(returnFiber, current$$1, element) { ref._stringRef = stringRef; return ref; } else { - invariant( - typeof mixedRef === "string", - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of" + - " the following reasons:\n" + - "1. You may be adding a ref to a function component\n" + - "2. You may be adding a ref to a component that was not created inside a component's render method\n" + - "3. You have multiple copies of React loaded\n" + - "See https://fb.me/react-refs-must-have-owner for more information.", - mixedRef - ); + (function() { + if (!(typeof mixedRef === "string")) { + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + } + })(); + (function() { + if (!element._owner) { + throw ReactError( + "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://fb.me/react-refs-must-have-owner for more information." + ); + } + })(); } } return mixedRef; @@ -8066,14 +9081,18 @@ function throwOnInvalidObjectType(returnFiber, newChild) { "instead." + getCurrentFiberStackInDev(); } - invariant( - false, - "Objects are not valid as a React child (found: %s).%s", - Object.prototype.toString.call(newChild) === "[object Object]" - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - addendum - ); + (function() { + { + throw ReactError( + "Objects are not valid as a React child (found: " + + (Object.prototype.toString.call(newChild) === "[object Object]" + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." + + addendum + ); + } + })(); } } @@ -8662,7 +9681,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChildren[newIdx], expirationTime ); - if (!_newFiber) { + if (_newFiber === null) { continue; } lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx); @@ -8689,7 +9708,7 @@ function ChildReconciler(shouldTrackSideEffects) { newChildren[newIdx], expirationTime ); - if (_newFiber2) { + if (_newFiber2 !== null) { if (shouldTrackSideEffects) { if (_newFiber2.alternate !== null) { // The new fiber is a work in progress, but if there exists a @@ -8732,11 +9751,13 @@ function ChildReconciler(shouldTrackSideEffects) { // but using the iterator instead. var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - typeof iteratorFn === "function", - "An object is not an iterable. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + (function() { + if (!(typeof iteratorFn === "function")) { + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); { // We don't support rendering Generators because it's a mutation. @@ -8786,7 +9807,11 @@ function ChildReconciler(shouldTrackSideEffects) { } var newChildren = iteratorFn.call(newChildrenIterable); - invariant(newChildren != null, "An iterable object provided no iterator."); + (function() { + if (!(newChildren != null)) { + throw ReactError("An iterable object provided no iterator."); + } + })(); var resultingFirstChild = null; var previousNewFiber = null; @@ -8819,7 +9844,7 @@ function ChildReconciler(shouldTrackSideEffects) { // unfortunate because it triggers the slow path all the time. We need // a better way to communicate whether this was a miss or null, // boolean, undefined, etc. - if (!oldFiber) { + if (oldFiber === null) { oldFiber = nextOldFiber; } break; @@ -9157,13 +10182,14 @@ function ChildReconciler(shouldTrackSideEffects) { // eslint-disable-next-lined no-fallthrough case FunctionComponent: { var Component = returnFiber.type; - invariant( - false, - "%s(...): Nothing was returned from render. This usually means a " + - "return statement is missing. Or, to render nothing, " + - "return null.", - Component.displayName || Component.name || "Component" - ); + (function() { + { + throw ReactError( + (Component.displayName || Component.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + ); + } + })(); } } } @@ -9179,10 +10205,11 @@ var reconcileChildFibers = ChildReconciler(true); var mountChildFibers = ChildReconciler(false); function cloneChildFibers(current$$1, workInProgress) { - invariant( - current$$1 === null || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + (function() { + if (!(current$$1 === null || workInProgress.child === current$$1.child)) { + throw ReactError("Resuming work not yet implemented."); + } + })(); if (workInProgress.child === null) { return; @@ -9216,11 +10243,13 @@ var contextFiberStackCursor = createCursor(NO_CONTEXT); var rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + if (!(c !== NO_CONTEXT)) { + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); return c; } @@ -9276,6 +10305,37 @@ function pushHostContext(fiber) { push(contextStackCursor$1, nextContext, fiber); } +function pushHostContextForEventComponent(fiber) { + var context = requiredContext(contextStackCursor$1.current); + var nextContext = getChildHostContextForEventComponent(context); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + +function pushHostContextForEventTarget(fiber) { + var context = requiredContext(contextStackCursor$1.current); + var eventTargetType = fiber.type.type; + var nextContext = getChildHostContextForEventTarget(context, eventTargetType); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + function popHostContext(fiber) { // Do not pop unless this Fiber provided the current context. // pushHostContext() only pushes Fibers that provide unique contexts. @@ -9304,7 +10364,7 @@ var didWarnAboutMismatchedHooksForComponent = void 0; } // These are set right before calling the component. -var renderExpirationTime = NoWork; +var renderExpirationTime$1 = NoWork; // The work-in-progress fiber. I've named it differently to distinguish it from // the work-in-progress hook. var currentlyRenderingFiber$1 = null; @@ -9313,7 +10373,6 @@ var currentlyRenderingFiber$1 = null; // current hook list is the list that belongs to the current fiber. The // work-in-progress hook list is a new list that will be added to the // work-in-progress fiber. -var firstCurrentHook = null; var currentHook = null; var nextCurrentHook = null; var firstWorkInProgressHook = null; @@ -9343,60 +10402,107 @@ var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook var currentHookNameInDev = null; -function warnOnHookMismatchInDev() { +// In DEV, this list ensures that hooks are called in the same order between renders. +// The list stores the order of hooks used during the initial render (mount). +// Subsequent renders (updates) reference this list. +var hookTypesDev = null; +var hookTypesUpdateIndexDev = -1; + +function mountHookTypesDev() { { - var componentName = getComponentName(currentlyRenderingFiber$1.type); - if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { - didWarnAboutMismatchedHooksForComponent.add(componentName); + var hookName = currentHookNameInDev; - var secondColumnStart = 22; + if (hookTypesDev === null) { + hookTypesDev = [hookName]; + } else { + hookTypesDev.push(hookName); + } + } +} - var table = ""; - var prevHook = firstCurrentHook; - var nextHook = firstWorkInProgressHook; - var n = 1; - while (prevHook !== null && nextHook !== null) { - var oldHookName = prevHook._debugType; - var newHookName = nextHook._debugType; +function updateHookTypesDev() { + { + var hookName = currentHookNameInDev; - var row = n + ". " + oldHookName; - - // Extra space so second column lines up - // lol @ IE not supporting String#repeat - while (row.length < secondColumnStart) { - row += " "; - } - - row += newHookName + "\n"; - - table += row; - prevHook = prevHook.next; - nextHook = nextHook.next; - n++; + if (hookTypesDev !== null) { + hookTypesUpdateIndexDev++; + if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { + warnOnHookMismatchInDev(hookName); } + } + } +} +function checkDepsAreArrayDev(deps) { + { + if (deps !== undefined && deps !== null && !Array.isArray(deps)) { + // Verify deps, but only on mount to avoid extra checks. + // It's unlikely their type would change as usually you define them inline. warning$1( false, - "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://fb.me/rules-of-hooks\n\n" + - " Previous render Next render\n" + - " -------------------------------\n" + - "%s" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - componentName, - table + "%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 ); } } } +function warnOnHookMismatchInDev(currentHookName) { + { + var componentName = getComponentName(currentlyRenderingFiber$1.type); + if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { + didWarnAboutMismatchedHooksForComponent.add(componentName); + + if (hookTypesDev !== null) { + var table = ""; + + var secondColumnStart = 30; + + for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { + var oldHookName = hookTypesDev[i]; + var newHookName = + i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; + + var row = i + 1 + ". " + oldHookName; + + // Extra space so second column lines up + // lol @ IE not supporting String#repeat + while (row.length < secondColumnStart) { + row += " "; + } + + row += newHookName + "\n"; + + table += row; + } + + warning$1( + false, + "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://fb.me/rules-of-hooks\n\n" + + " Previous render Next render\n" + + " ------------------------------------------------------\n" + + "%s" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + componentName, + table + ); + } + } + } +} + function throwInvalidHookError() { - invariant( - false, - "Hooks can only be called inside the body of a function component. " + - "(https://fb.me/react-invalid-hook-call)" - ); + (function() { + { + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + ); + } + })(); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -9424,8 +10530,8 @@ function areHookInputsEqual(nextDeps, prevDeps) { "Previous: %s\n" + "Incoming: %s", currentHookNameInDev, - "[" + nextDeps.join(", ") + "]", - "[" + prevDeps.join(", ") + "]" + "[" + prevDeps.join(", ") + "]", + "[" + nextDeps.join(", ") + "]" ); } } @@ -9446,10 +10552,14 @@ function renderWithHooks( refOrContext, nextRenderExpirationTime ) { - renderExpirationTime = nextRenderExpirationTime; + renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - firstCurrentHook = nextCurrentHook = - current !== null ? current.memoizedState : null; + nextCurrentHook = current !== null ? current.memoizedState : null; + + { + hookTypesDev = current !== null ? current._debugHookTypes : null; + hookTypesUpdateIndexDev = -1; + } // The following should have already been reset // currentHook = null; @@ -9463,11 +10573,26 @@ function renderWithHooks( // numberOfReRenders = 0; // sideEffectTag = 0; + // TODO Warn if no hooks are used at all during mount, then some are used during update. + // Currently we will identify the update render as a mount because nextCurrentHook === null. + // This is tricky because it's valid for certain types of components (e.g. React.lazy) + + // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used. + // Non-stateful hooks (e.g. context) don't get added to memoizedState, + // so nextCurrentHook would be null during updates and mounts. { - ReactCurrentDispatcher$1.current = - nextCurrentHook === null - ? HooksDispatcherOnMountInDEV - : HooksDispatcherOnUpdateInDEV; + if (nextCurrentHook !== null) { + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; + } else if (hookTypesDev !== null) { + // This dispatcher handles an edge case where a component is updating, + // but no stateful hooks have been used. + // We want to match the production code behavior (which will use HooksDispatcherOnMount), + // but with the extra DEV validation to ensure hooks ordering hasn't changed. + // This dispatcher does that. + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; + } else { + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; + } } var children = Component(props, refOrContext); @@ -9478,14 +10603,18 @@ function renderWithHooks( numberOfReRenders += 1; // Start over from the beginning of the list - firstCurrentHook = nextCurrentHook = - current !== null ? current.memoizedState : null; + nextCurrentHook = current !== null ? current.memoizedState : null; nextWorkInProgressHook = firstWorkInProgressHook; currentHook = null; workInProgressHook = null; componentUpdateQueue = null; + { + // Also validate hook order for cascading updates. + hookTypesUpdateIndexDev = -1; + } + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; children = Component(props, refOrContext); @@ -9495,10 +10624,6 @@ function renderWithHooks( numberOfReRenders = 0; } - { - currentHookNameInDev = null; - } - // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; @@ -9510,18 +10635,29 @@ function renderWithHooks( renderedWork.updateQueue = componentUpdateQueue; renderedWork.effectTag |= sideEffectTag; + { + renderedWork._debugHookTypes = hookTypesDev; + } + + // This check uses currentHook so that it works the same in DEV and prod bundles. + // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; - renderExpirationTime = NoWork; + renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; - firstCurrentHook = null; currentHook = null; nextCurrentHook = null; firstWorkInProgressHook = null; workInProgressHook = null; nextWorkInProgressHook = null; + { + currentHookNameInDev = null; + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + } + remainingExpirationTime = NoWork; componentUpdateQueue = null; sideEffectTag = 0; @@ -9531,11 +10667,13 @@ function renderWithHooks( // renderPhaseUpdates = null; // numberOfReRenders = 0; - invariant( - !didRenderTooFewHooks, - "Rendered fewer hooks than expected. This may be caused by an accidental " + - "early return statement." - ); + (function() { + if (!!didRenderTooFewHooks) { + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); + } + })(); return children; } @@ -9556,24 +10694,26 @@ function resetHooks() { // This is used to reset the state of this module when a component throws. // It's also called inside mountIndeterminateComponent if we determine the // component is a module-style component. - renderExpirationTime = NoWork; + renderExpirationTime$1 = NoWork; currentlyRenderingFiber$1 = null; - firstCurrentHook = null; currentHook = null; nextCurrentHook = null; firstWorkInProgressHook = null; workInProgressHook = null; nextWorkInProgressHook = null; + { + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + + currentHookNameInDev = null; + } + remainingExpirationTime = NoWork; componentUpdateQueue = null; sideEffectTag = 0; - { - currentHookNameInDev = null; - } - didScheduleRenderPhaseUpdate = false; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -9590,9 +10730,6 @@ function mountWorkInProgressHook() { next: null }; - { - hook._debugType = currentHookNameInDev; - } if (workInProgressHook === null) { // This is the first hook in the list firstWorkInProgressHook = workInProgressHook = hook; @@ -9618,10 +10755,13 @@ function updateWorkInProgressHook() { nextCurrentHook = currentHook !== null ? currentHook.next : null; } else { // Clone from the current hook. - invariant( - nextCurrentHook !== null, - "Rendered more hooks than during the previous render." - ); + (function() { + if (!(nextCurrentHook !== null)) { + throw ReactError( + "Rendered more hooks than during the previous render." + ); + } + })(); currentHook = nextCurrentHook; var newHook = { @@ -9642,13 +10782,6 @@ function updateWorkInProgressHook() { workInProgressHook = workInProgressHook.next = newHook; } nextCurrentHook = currentHook.next; - - { - newHook._debugType = currentHookNameInDev; - if (currentHookNameInDev !== currentHook._debugType) { - warnOnHookMismatchInDev(); - } - } } return workInProgressHook; } @@ -9663,20 +10796,6 @@ function basicStateReducer(state, action) { return typeof action === "function" ? action(state) : action; } -function mountContext(context, observedBits) { - { - mountWorkInProgressHook(); - } - return readContext(context, observedBits); -} - -function updateContext(context, observedBits) { - { - updateWorkInProgressHook(); - } - return readContext(context, observedBits); -} - function mountReducer(reducer, initialArg, init) { var hook = mountWorkInProgressHook(); var initialState = void 0; @@ -9689,8 +10808,8 @@ function mountReducer(reducer, initialArg, init) { var queue = (hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialState + lastRenderedReducer: reducer, + lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( null, @@ -9704,10 +10823,15 @@ function mountReducer(reducer, initialArg, init) { function updateReducer(reducer, initialArg, init) { var hook = updateWorkInProgressHook(); var queue = hook.queue; - invariant( - queue !== null, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + (function() { + if (!(queue !== null)) { + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + } + })(); + + queue.lastRenderedReducer = reducer; if (numberOfReRenders > 0) { // This is a re-render. Apply the new render phase updates to the previous @@ -9743,8 +10867,7 @@ function updateReducer(reducer, initialArg, init) { hook.baseState = newState; } - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; return [newState, _dispatch]; } @@ -9780,7 +10903,7 @@ function updateReducer(reducer, initialArg, init) { var didSkip = false; do { var updateExpirationTime = _update.expirationTime; - if (updateExpirationTime < renderExpirationTime) { + if (updateExpirationTime < renderExpirationTime$1) { // Priority is insufficient. Skip this update. If this is the first // skipped update, the previous update/state is the new base // update/state. @@ -9794,6 +10917,16 @@ function updateReducer(reducer, initialArg, init) { remainingExpirationTime = updateExpirationTime; } } else { + // This update does have sufficient priority. + + // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + markRenderEventTime(updateExpirationTime); + // Process this update. if (_update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -9823,8 +10956,7 @@ function updateReducer(reducer, initialArg, init) { hook.baseUpdate = newBaseUpdate; hook.baseState = newBaseState; - queue.eagerReducer = reducer; - queue.eagerState = _newState; + queue.lastRenderedState = _newState; } var dispatch = queue.dispatch; @@ -9840,8 +10972,8 @@ function mountState(initialState) { var queue = (hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( null, @@ -10084,25 +11216,14 @@ function updateMemo(nextCreate, deps) { return nextValue; } -// in a test-like environment, we want to warn if dispatchAction() -// is called outside of a batchedUpdates/TestUtils.act(...) call. -var shouldWarnForUnbatchedSetState = false; - -{ - // jest isn't a 'global', it's just exposed to tests via a wrapped function - // further, this isn't a test file, so flow doesn't recognize the symbol. So... - // $FlowExpectedError - because requirements don't give a damn about your type sigs. - if ("undefined" !== typeof jest) { - shouldWarnForUnbatchedSetState = true; - } -} - function dispatchAction(fiber, queue, action) { - invariant( - numberOfReRenders < RE_RENDER_LIMIT, - "Too many re-renders. React limits the number of renders to prevent " + - "an infinite loop." - ); + (function() { + if (!(numberOfReRenders < RE_RENDER_LIMIT)) { + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); + } + })(); { !(arguments.length <= 3) @@ -10125,7 +11246,7 @@ function dispatchAction(fiber, queue, action) { // and apply the stashed updates on top of the work-in-progress hook. didScheduleRenderPhaseUpdate = true; var update = { - expirationTime: renderExpirationTime, + expirationTime: renderExpirationTime$1, action: action, eagerReducer: null, eagerState: null, @@ -10181,21 +11302,21 @@ function dispatchAction(fiber, queue, action) { // The queue is currently empty, which means we can eagerly compute the // next state before entering the render phase. If the new state is the // same as the current state, we may be able to bail out entirely. - var _eagerReducer = queue.eagerReducer; - if (_eagerReducer !== null) { + var _lastRenderedReducer = queue.lastRenderedReducer; + if (_lastRenderedReducer !== null) { var prevDispatcher = void 0; { prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } try { - var currentState = queue.eagerState; - var _eagerState = _eagerReducer(currentState, action); + var currentState = queue.lastRenderedState; + var _eagerState = _lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute // it, on the update object. If the reducer hasn't changed by the // time we enter the render phase, then the eager state can be used // without calling the reducer again. - _update2.eagerReducer = _eagerReducer; + _update2.eagerReducer = _lastRenderedReducer; _update2.eagerState = _eagerState; if (is(_eagerState, currentState)) { // Fast path. We can bail out without scheduling React to re-render. @@ -10214,8 +11335,11 @@ function dispatchAction(fiber, queue, action) { } } { - if (shouldWarnForUnbatchedSetState === true) { - warnIfNotCurrentlyBatchingInDev(fiber); + // jest isn't a 'global', it's just exposed to tests via a wrapped function + // further, this isn't a test file, so flow doesn't recognize the symbol. So... + // $FlowExpectedError - because requirements don't give a damn about your type sigs. + if ("undefined" !== typeof jest) { + warnIfNotCurrentlyActingUpdatesInDev(fiber); } } scheduleWork(fiber, _expirationTime); @@ -10238,6 +11362,7 @@ var ContextOnlyDispatcher = { }; var HooksDispatcherOnMountInDEV = null; +var HooksDispatcherOnMountWithHookTypesInDEV = null; var HooksDispatcherOnUpdateInDEV = null; var InvalidNestedHooksDispatcherOnMountInDEV = null; var InvalidNestedHooksDispatcherOnUpdateInDEV = null; @@ -10269,26 +11394,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); return mountCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; - return mountContext(context, observedBits); + mountHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); return mountEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); return mountImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); return mountLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10299,6 +11435,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10309,10 +11446,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useRef: function(initialValue) { currentHookNameInDev = "useRef"; + mountHookTypesDev(); return mountRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10323,6 +11462,81 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; + mountHookTypesDev(); + return mountDebugValue(value, formatterFn); + } + }; + + HooksDispatcherOnMountWithHookTypesInDEV = { + readContext: function(context, observedBits) { + return readContext(context, observedBits); + }, + useCallback: function(callback, deps) { + currentHookNameInDev = "useCallback"; + updateHookTypesDev(); + return mountCallback(callback, deps); + }, + useContext: function(context, observedBits) { + currentHookNameInDev = "useContext"; + updateHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function(create, deps) { + currentHookNameInDev = "useEffect"; + updateHookTypesDev(); + return mountEffect(create, deps); + }, + useImperativeHandle: function(ref, create, deps) { + currentHookNameInDev = "useImperativeHandle"; + updateHookTypesDev(); + return mountImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function(create, deps) { + currentHookNameInDev = "useLayoutEffect"; + updateHookTypesDev(); + return mountLayoutEffect(create, deps); + }, + useMemo: function(create, deps) { + currentHookNameInDev = "useMemo"; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function(reducer, initialArg, init) { + currentHookNameInDev = "useReducer"; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function(initialValue) { + currentHookNameInDev = "useRef"; + updateHookTypesDev(); + return mountRef(initialValue); + }, + useState: function(initialState) { + currentHookNameInDev = "useState"; + updateHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function(value, formatterFn) { + currentHookNameInDev = "useDebugValue"; + updateHookTypesDev(); return mountDebugValue(value, formatterFn); } }; @@ -10333,26 +11547,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; + updateHookTypesDev(); return updateCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; - return updateContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; + updateHookTypesDev(); return updateEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; + updateHookTypesDev(); return updateImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; + updateHookTypesDev(); return updateLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10363,6 +11583,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10373,10 +11594,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useRef: function(initialValue) { currentHookNameInDev = "useRef"; + updateHookTypesDev(); return updateRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10387,6 +11610,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; + updateHookTypesDev(); return updateDebugValue(value, formatterFn); } }; @@ -10399,31 +11623,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; warnInvalidHookAccess(); - return mountContext(context, observedBits); + mountHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10435,6 +11665,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10446,11 +11677,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useRef: function(initialValue) { currentHookNameInDev = "useRef"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10462,6 +11695,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountDebugValue(value, formatterFn); } }; @@ -10474,31 +11708,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; warnInvalidHookAccess(); - return updateContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10510,6 +11750,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10521,11 +11762,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useRef: function(initialValue) { currentHookNameInDev = "useRef"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10537,11 +11780,16 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateDebugValue(value, formatterFn); } }; } +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var now$1 = Scheduler.unstable_now; + var commitTime = 0; var profilerStartTime = -1; @@ -10553,7 +11801,7 @@ function recordCommitTime() { if (!enableProfilerTimer) { return; } - commitTime = now$$1(); + commitTime = now$1(); } function startProfilerTimer(fiber) { @@ -10561,10 +11809,10 @@ function startProfilerTimer(fiber) { return; } - profilerStartTime = now$$1(); + profilerStartTime = now$1(); if (fiber.actualStartTime < 0) { - fiber.actualStartTime = now$$1(); + fiber.actualStartTime = now$1(); } } @@ -10581,7 +11829,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } if (profilerStartTime >= 0) { - var elapsedTime = now$$1() - profilerStartTime; + var elapsedTime = now$1() - profilerStartTime; fiber.actualDuration += elapsedTime; if (overrideBaseTime) { fiber.selfBaseDuration = elapsedTime; @@ -10800,11 +12048,13 @@ function prepareToHydrateHostInstance( hostContext ) { if (!supportsHydration) { - invariant( - false, - "Expected prepareToHydrateHostInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var instance = fiber.stateNode; @@ -10828,11 +12078,13 @@ function prepareToHydrateHostInstance( function prepareToHydrateHostTextInstance(fiber) { if (!supportsHydration) { - invariant( - false, - "Expected prepareToHydrateHostTextInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var textInstance = fiber.stateNode; @@ -10876,18 +12128,22 @@ function prepareToHydrateHostTextInstance(fiber) { function skipPastDehydratedSuspenseInstance(fiber) { if (!supportsHydration) { - invariant( - false, - "Expected skipPastDehydratedSuspenseInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var suspenseInstance = fiber.stateNode; - invariant( - suspenseInstance, - "Expected to have a hydrated suspense instance. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!suspenseInstance) { + throw ReactError( + "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance( suspenseInstance ); @@ -10966,17 +12222,21 @@ var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didReceiveUpdate = false; var didWarnAboutBadClass = void 0; +var didWarnAboutModulePatternComponent = void 0; var didWarnAboutContextTypeOnFunctionComponent = void 0; var didWarnAboutGetDerivedStateOnFunctionComponent = void 0; var didWarnAboutFunctionRefs = void 0; var didWarnAboutReassigningProps = void 0; +var didWarnAboutMaxDuration = void 0; { didWarnAboutBadClass = {}; + didWarnAboutModulePatternComponent = {}; didWarnAboutContextTypeOnFunctionComponent = {}; didWarnAboutGetDerivedStateOnFunctionComponent = {}; didWarnAboutFunctionRefs = {}; didWarnAboutReassigningProps = false; + didWarnAboutMaxDuration = false; } function reconcileChildren( @@ -11642,12 +12902,13 @@ function pushHostRootContext(workInProgress) { function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - invariant( - updateQueue !== null, - "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." - ); + (function() { + if (!(updateQueue !== null)) { + throw ReactError( + "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." + ); + } + })(); var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; @@ -11871,13 +13132,16 @@ function mountLazyComponent( // This message intentionally doesn't mention ForwardRef or MemoComponent // because the fact that it's a separate type of work is an // implementation detail. - invariant( - false, - "Element type is invalid. Received a promise that resolves to: %s. " + - "Lazy element type must resolve to a class or function.%s", - Component, - hint - ); + (function() { + { + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + Component + + ". Lazy element type must resolve to a class or function." + + hint + ); + } + })(); } } return child; @@ -12008,6 +13272,24 @@ function mountIndeterminateComponent( typeof value.render === "function" && value.$$typeof === undefined ) { + { + var _componentName = getComponentName(Component) || "Unknown"; + if (!didWarnAboutModulePatternComponent[_componentName]) { + warningWithoutStack$1( + false, + "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 + ); + didWarnAboutModulePatternComponent[_componentName] = true; + } + } + // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; @@ -12129,15 +13411,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { typeof Component.contextType === "object" && Component.contextType !== null ) { - var _componentName = getComponentName(Component) || "Unknown"; + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName]) { + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) { warningWithoutStack$1( false, "%s: Function components do not support contextType.", - _componentName + _componentName2 ); - didWarnAboutContextTypeOnFunctionComponent[_componentName] = true; + didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true; } } } @@ -12150,6 +13432,12 @@ function updateSuspenseComponent( var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; + { + if (shouldSuspend(workInProgress)) { + workInProgress.effectTag |= DidCapture; + } + } + // We should attempt to render the primary children unless this boundary // already suspended during this render (`alreadyCaptured` is true). var nextState = workInProgress.memoizedState; @@ -12163,12 +13451,26 @@ function updateSuspenseComponent( // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. nextState = { - timedOutAt: nextState !== null ? nextState.timedOutAt : NoWork + fallbackExpirationTime: + nextState !== null ? nextState.fallbackExpirationTime : NoWork }; nextDidTimeout = true; workInProgress.effectTag &= ~DidCapture; } + { + if ("maxDuration" in nextProps) { + if (!didWarnAboutMaxDuration) { + didWarnAboutMaxDuration = true; + warning$1( + false, + "maxDuration has been removed from React. " + + "Remove the maxDuration prop." + ); + } + } + } + // This next part is a bit confusing. If the children timeout, we switch to // showing the fallback children in place of the "primary" children. // However, we don't want to delete the primary children because then their @@ -12419,15 +13721,73 @@ function updateSuspenseComponent( return next; } +function retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime +) { + // Detach from the current dehydrated boundary. + current$$1.alternate = null; + workInProgress.alternate = null; + + // Insert a deletion in the effect list. + var returnFiber = workInProgress.return; + (function() { + if (!(returnFiber !== null)) { + throw ReactError( + "Suspense boundaries are never on the root. This is probably a bug in React." + ); + } + })(); + var last = returnFiber.lastEffect; + if (last !== null) { + last.nextEffect = current$$1; + returnFiber.lastEffect = current$$1; + } else { + returnFiber.firstEffect = returnFiber.lastEffect = current$$1; + } + current$$1.nextEffect = null; + current$$1.effectTag = Deletion; + + // Upgrade this work in progress to a real Suspense component. + workInProgress.tag = SuspenseComponent; + workInProgress.stateNode = null; + workInProgress.memoizedState = null; + // This is now an insertion. + workInProgress.effectTag |= Placement; + // Retry as a real Suspense component. + return updateSuspenseComponent(null, workInProgress, renderExpirationTime); +} + function updateDehydratedSuspenseComponent( current$$1, workInProgress, renderExpirationTime ) { + var suspenseInstance = workInProgress.stateNode; if (current$$1 === null) { // During the first pass, we'll bail out and not drill into the children. // Instead, we'll leave the content in place and try to hydrate it later. - workInProgress.expirationTime = Never; + if (isSuspenseInstanceFallback(suspenseInstance)) { + // This is a client-only boundary. Since we won't get any content from the server + // for this, we need to schedule that at a higher priority based on when it would + // have timed out. In theory we could render it in this pass but it would have the + // wrong priority associated with it and will prevent hydration of parent path. + // Instead, we'll leave work left on it to render it in a separate commit. + + // TODO This time should be the time at which the server rendered response that is + // a parent to this boundary was displayed. However, since we currently don't have + // a protocol to transfer that time, we'll just estimate it by using the current + // time. This will mean that Suspense timeouts are slightly shifted to later than + // they should be. + var serverDisplayTime = requestCurrentTime(); + // Schedule a normal pri update to render this content. + workInProgress.expirationTime = computeAsyncExpiration(serverDisplayTime); + } else { + // We'll continue hydrating the rest at offscreen priority since we'll already + // be showing the right content coming from the server, it is no rush. + workInProgress.expirationTime = Never; + } return null; } if ((workInProgress.effectTag & DidCapture) !== NoEffect) { @@ -12436,56 +13796,32 @@ function updateDehydratedSuspenseComponent( workInProgress.child = null; return null; } + if (isSuspenseInstanceFallback(suspenseInstance)) { + // This boundary is in a permanent fallback state. In this case, we'll never + // get an update and we'll never be able to hydrate the final content. Let's just try the + // client side render instead. + return retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime + ); + } // We use childExpirationTime to indicate that a child might depend on context, so if // any context has changed, we need to treat is as if the input might have changed. var hasContextChanged$$1 = current$$1.childExpirationTime >= renderExpirationTime; - var suspenseInstance = current$$1.stateNode; - if ( - didReceiveUpdate || - hasContextChanged$$1 || - isSuspenseInstanceFallback(suspenseInstance) - ) { + if (didReceiveUpdate || hasContextChanged$$1) { // This boundary has changed since the first render. This means that we are now unable to // hydrate it. We might still be able to hydrate it using an earlier expiration time but // during this render we can't. Instead, we're going to delete the whole subtree and // instead inject a new real Suspense boundary to take its place, which may render content // or fallback. The real Suspense boundary will suspend for a while so we have some time // to ensure it can produce real content, but all state and pending events will be lost. - - // Alternatively, this boundary is in a permanent fallback state. In this case, we'll never - // get an update and we'll never be able to hydrate the final content. Let's just try the - // client side render instead. - - // Detach from the current dehydrated boundary. - current$$1.alternate = null; - workInProgress.alternate = null; - - // Insert a deletion in the effect list. - var returnFiber = workInProgress.return; - invariant( - returnFiber !== null, - "Suspense boundaries are never on the root. " + - "This is probably a bug in React." + return retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime ); - var last = returnFiber.lastEffect; - if (last !== null) { - last.nextEffect = current$$1; - returnFiber.lastEffect = current$$1; - } else { - returnFiber.firstEffect = returnFiber.lastEffect = current$$1; - } - current$$1.nextEffect = null; - current$$1.effectTag = Deletion; - - // Upgrade this work in progress to a real Suspense component. - workInProgress.tag = SuspenseComponent; - workInProgress.stateNode = null; - workInProgress.memoizedState = null; - // This is now an insertion. - workInProgress.effectTag |= Placement; - // Retry as a real Suspense component. - return updateSuspenseComponent(null, workInProgress, renderExpirationTime); } else if (isSuspenseInstancePending(suspenseInstance)) { // This component is still pending more data from the server, so we can't hydrate its // content. We treat it as if this component suspended itself. It might seem as if @@ -12683,6 +14019,55 @@ function updateContextConsumer( return workInProgress.child; } +function updateEventComponent$1( + current$$1, + workInProgress, + renderExpirationTime +) { + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; + + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + pushHostContextForEventComponent(workInProgress); + return workInProgress.child; +} + +function updateEventTarget(current$$1, workInProgress, renderExpirationTime) { + var type = workInProgress.type.type; + var nextProps = workInProgress.pendingProps; + var eventTargetChild = getEventTargetChildElement(type, nextProps); + + { + !(nextProps.children == null) + ? warning$1(false, "Event targets should not have children.") + : void 0; + } + if (eventTargetChild !== null) { + var child = (workInProgress.child = createFiberFromTypeAndProps( + eventTargetChild.type, + null, + eventTargetChild.props, + null, + workInProgress.mode, + renderExpirationTime + )); + child.return = workInProgress; + + if (current$$1 === null || current$$1.child === null) { + child.effectTag = Placement; + } + } else { + reconcileChildren(current$$1, workInProgress, null, renderExpirationTime); + } + pushHostContextForEventTarget(workInProgress); + return workInProgress.child; +} + function markWorkInProgressReceivedUpdate() { didReceiveUpdate = true; } @@ -12719,7 +14104,7 @@ function bailoutOnAlreadyFinishedWork( } } -function beginWork(current$$1, workInProgress, renderExpirationTime) { +function beginWork$1(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if (current$$1 !== null) { @@ -12812,8 +14197,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { // been unsuspended it has committed as a regular Suspense component. // If it needs to be retried, it should have work scheduled on it. workInProgress.effectTag |= DidCapture; - break; } + break; + } + case EventComponent: + if (enableEventAPI) { + pushHostContextForEventComponent(workInProgress); + } + break; + case EventTarget: { + if (enableEventAPI) { + pushHostContextForEventTarget(workInProgress); + } + break; } } return bailoutOnAlreadyFinishedWork( @@ -12998,920 +14394,34 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } break; } - } - invariant( - false, - "Unknown unit of work tag. This error is likely caused by a bug in " + - "React. Please file an issue." - ); -} - -var valueCursor = createCursor(null); - -var rendererSigil = void 0; -{ - // Use this to detect multiple renderers using the same context - rendererSigil = {}; -} - -var currentlyRenderingFiber = null; -var lastContextDependency = null; -var lastContextWithAllBitsObserved = null; - -var isDisallowedContextReadInDEV = false; - -function resetContextDependences() { - // This is called right before React yields execution, to ensure `readContext` - // cannot be called outside the render phase. - currentlyRenderingFiber = null; - lastContextDependency = null; - lastContextWithAllBitsObserved = null; - { - isDisallowedContextReadInDEV = false; - } -} - -function enterDisallowedContextReadInDEV() { - { - isDisallowedContextReadInDEV = true; - } -} - -function exitDisallowedContextReadInDEV() { - { - isDisallowedContextReadInDEV = false; - } -} - -function pushProvider(providerFiber, nextValue) { - var context = providerFiber.type._context; - - if (isPrimaryRenderer) { - push(valueCursor, context._currentValue, providerFiber); - - context._currentValue = nextValue; - { - !( - context._currentRenderer === undefined || - context._currentRenderer === null || - context._currentRenderer === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; - context._currentRenderer = rendererSigil; - } - } else { - push(valueCursor, context._currentValue2, providerFiber); - - context._currentValue2 = nextValue; - { - !( - context._currentRenderer2 === undefined || - context._currentRenderer2 === null || - context._currentRenderer2 === rendererSigil - ) - ? warningWithoutStack$1( - false, - "Detected multiple renderers concurrently rendering the " + - "same context provider. This is currently unsupported." - ) - : void 0; - context._currentRenderer2 = rendererSigil; - } - } -} - -function popProvider(providerFiber) { - var currentValue = valueCursor.current; - - pop(valueCursor, providerFiber); - - var context = providerFiber.type._context; - if (isPrimaryRenderer) { - context._currentValue = currentValue; - } else { - context._currentValue2 = currentValue; - } -} - -function calculateChangedBits(context, newValue, oldValue) { - if (is(oldValue, newValue)) { - // No change - return 0; - } else { - var changedBits = - typeof context._calculateChangedBits === "function" - ? context._calculateChangedBits(oldValue, newValue) - : maxSigned31BitInt; - - { - !((changedBits & maxSigned31BitInt) === changedBits) - ? warning$1( - false, - "calculateChangedBits: Expected the return value to be a " + - "31-bit integer. Instead received: %s", - changedBits - ) - : void 0; - } - return changedBits | 0; - } -} - -function scheduleWorkOnParentPath(parent, renderExpirationTime) { - // Update the child expiration time of all the ancestors, including - // the alternates. - var node = parent; - while (node !== null) { - var alternate = node.alternate; - if (node.childExpirationTime < renderExpirationTime) { - node.childExpirationTime = renderExpirationTime; - if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; + case EventComponent: { + if (enableEventAPI) { + return updateEventComponent$1( + current$$1, + workInProgress, + renderExpirationTime + ); } - } else if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; - } else { - // Neither alternate was updated, which means the rest of the - // ancestor path already has sufficient priority. break; } - node = node.return; - } -} - -function propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime -) { - var fiber = workInProgress.child; - if (fiber !== null) { - // Set the return pointer of the child to the work-in-progress fiber. - fiber.return = workInProgress; - } - while (fiber !== null) { - var nextFiber = void 0; - - // Visit this fiber. - var list = fiber.contextDependencies; - if (list !== null) { - nextFiber = fiber.child; - - var dependency = list.first; - while (dependency !== null) { - // Check if the context matches. - if ( - dependency.context === context && - (dependency.observedBits & changedBits) !== 0 - ) { - // Match! Schedule an update on this fiber. - - if (fiber.tag === ClassComponent) { - // Schedule a force update on the work-in-progress. - var update = createUpdate(renderExpirationTime); - update.tag = ForceUpdate; - // TODO: Because we don't have a work-in-progress, this will add the - // update to the current fiber, too, which means it will persist even if - // this render is thrown away. Since it's a race condition, not sure it's - // worth fixing. - enqueueUpdate(fiber, update); - } - - if (fiber.expirationTime < renderExpirationTime) { - fiber.expirationTime = renderExpirationTime; - } - var alternate = fiber.alternate; - if ( - alternate !== null && - alternate.expirationTime < renderExpirationTime - ) { - alternate.expirationTime = renderExpirationTime; - } - - scheduleWorkOnParentPath(fiber.return, renderExpirationTime); - - // Mark the expiration time on the list, too. - if (list.expirationTime < renderExpirationTime) { - list.expirationTime = renderExpirationTime; - } - - // Since we already found a match, we can stop traversing the - // dependency list. - break; - } - dependency = dependency.next; - } - } else if (fiber.tag === ContextProvider) { - // Don't scan deeper if this is a matching provider - nextFiber = fiber.type === workInProgress.type ? null : fiber.child; - } else if ( - enableSuspenseServerRenderer && - fiber.tag === DehydratedSuspenseComponent - ) { - // If a dehydrated suspense component is in this subtree, we don't know - // if it will have any context consumers in it. The best we can do is - // mark it as having updates on its children. - if (fiber.expirationTime < renderExpirationTime) { - fiber.expirationTime = renderExpirationTime; - } - var _alternate = fiber.alternate; - if ( - _alternate !== null && - _alternate.expirationTime < renderExpirationTime - ) { - _alternate.expirationTime = renderExpirationTime; - } - // This is intentionally passing this fiber as the parent - // because we want to schedule this fiber as having work - // on its children. We'll use the childExpirationTime on - // this fiber to indicate that a context has changed. - scheduleWorkOnParentPath(fiber, renderExpirationTime); - nextFiber = fiber.sibling; - } else { - // Traverse down. - nextFiber = fiber.child; - } - - if (nextFiber !== null) { - // Set the return pointer of the child to the work-in-progress fiber. - nextFiber.return = fiber; - } else { - // No child. Traverse to next sibling. - nextFiber = fiber; - while (nextFiber !== null) { - if (nextFiber === workInProgress) { - // We're back to the root of this subtree. Exit. - nextFiber = null; - break; - } - var sibling = nextFiber.sibling; - if (sibling !== null) { - // Set the return pointer of the sibling to the work-in-progress fiber. - sibling.return = nextFiber.return; - nextFiber = sibling; - break; - } - // No more siblings. Traverse up. - nextFiber = nextFiber.return; - } - } - fiber = nextFiber; - } -} - -function prepareToReadContext(workInProgress, renderExpirationTime) { - currentlyRenderingFiber = workInProgress; - lastContextDependency = null; - lastContextWithAllBitsObserved = null; - - var currentDependencies = workInProgress.contextDependencies; - if ( - currentDependencies !== null && - currentDependencies.expirationTime >= renderExpirationTime - ) { - // Context list has a pending update. Mark that this fiber performed work. - markWorkInProgressReceivedUpdate(); - } - - // Reset the work-in-progress list - workInProgress.contextDependencies = null; -} - -function readContext(context, observedBits) { - { - // This warning would fire if you read context inside a Hook like useMemo. - // Unlike the class check below, it's not enforced in production for perf. - !!isDisallowedContextReadInDEV - ? warning$1( - false, - "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()." - ) - : void 0; - } - - if (lastContextWithAllBitsObserved === context) { - // Nothing to do. We already observe everything in this context. - } else if (observedBits === false || observedBits === 0) { - // Do not observe any updates. - } else { - var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types. - if ( - typeof observedBits !== "number" || - observedBits === maxSigned31BitInt - ) { - // Observe all updates. - lastContextWithAllBitsObserved = context; - resolvedObservedBits = maxSigned31BitInt; - } else { - resolvedObservedBits = observedBits; - } - - var contextItem = { - context: context, - observedBits: resolvedObservedBits, - next: null - }; - - if (lastContextDependency === null) { - invariant( - currentlyRenderingFiber !== null, - "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()." - ); - - // This is the first dependency for this component. Create a new list. - lastContextDependency = contextItem; - currentlyRenderingFiber.contextDependencies = { - first: contextItem, - expirationTime: NoWork - }; - } else { - // Append a new context item. - lastContextDependency = lastContextDependency.next = contextItem; - } - } - return isPrimaryRenderer ? context._currentValue : context._currentValue2; -} - -// UpdateQueue is a linked list of prioritized updates. -// -// Like fibers, update queues come in pairs: a current queue, which represents -// the visible state of the screen, and a work-in-progress queue, which can be -// mutated and processed asynchronously before it is committed — a form of -// double buffering. If a work-in-progress render is discarded before finishing, -// we create a new work-in-progress by cloning the current queue. -// -// Both queues share a persistent, singly-linked list structure. To schedule an -// update, we append it to the end of both queues. Each queue maintains a -// pointer to first update in the persistent list that hasn't been processed. -// The work-in-progress pointer always has a position equal to or greater than -// the current queue, since we always work on that one. The current queue's -// pointer is only updated during the commit phase, when we swap in the -// work-in-progress. -// -// For example: -// -// Current pointer: A - B - C - D - E - F -// Work-in-progress pointer: D - E - F -// ^ -// The work-in-progress queue has -// processed more updates than current. -// -// The reason we append to both queues is because otherwise we might drop -// updates without ever processing them. For example, if we only add updates to -// the work-in-progress queue, some updates could be lost whenever a work-in -// -progress render restarts by cloning from current. Similarly, if we only add -// updates to the current queue, the updates will be lost whenever an already -// in-progress queue commits and swaps with the current queue. However, by -// adding to both queues, we guarantee that the update will be part of the next -// work-in-progress. (And because the work-in-progress queue becomes the -// current queue once it commits, there's no danger of applying the same -// update twice.) -// -// Prioritization -// -------------- -// -// Updates are not sorted by priority, but by insertion; new updates are always -// appended to the end of the list. -// -// The priority is still important, though. When processing the update queue -// during the render phase, only the updates with sufficient priority are -// included in the result. If we skip an update because it has insufficient -// priority, it remains in the queue to be processed later, during a lower -// priority render. Crucially, all updates subsequent to a skipped update also -// remain in the queue *regardless of their priority*. That means high priority -// updates are sometimes processed twice, at two separate priorities. We also -// keep track of a base state, that represents the state before the first -// update in the queue is applied. -// -// For example: -// -// Given a base state of '', and the following queue of updates -// -// A1 - B2 - C1 - D2 -// -// where the number indicates the priority, and the update is applied to the -// previous state by appending a letter, React will process these updates as -// two separate renders, one per distinct priority level: -// -// First render, at priority 1: -// Base state: '' -// Updates: [A1, C1] -// Result state: 'AC' -// -// Second render, at priority 2: -// Base state: 'A' <- The base state does not include C1, -// because B2 was skipped. -// Updates: [B2, C1, D2] <- C1 was rebased on top of B2 -// Result state: 'ABCD' -// -// Because we process updates in insertion order, and rebase high priority -// updates when preceding updates are skipped, the final result is deterministic -// regardless of priority. Intermediate state may vary according to system -// resources, but the final state is always the same. - -var UpdateState = 0; -var ReplaceState = 1; -var ForceUpdate = 2; -var CaptureUpdate = 3; - -// Global state that is reset at the beginning of calling `processUpdateQueue`. -// It should only be read right after calling `processUpdateQueue`, via -// `checkHasForceUpdateAfterProcessing`. -var hasForceUpdate = false; - -var didWarnUpdateInsideUpdate = void 0; -var currentlyProcessingQueue = void 0; -var resetCurrentlyProcessingQueue = void 0; -{ - didWarnUpdateInsideUpdate = false; - currentlyProcessingQueue = null; - resetCurrentlyProcessingQueue = function() { - currentlyProcessingQueue = null; - }; -} - -function createUpdateQueue(baseState) { - var queue = { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; - return queue; -} - -function cloneUpdateQueue(currentQueue) { - var queue = { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - - // TODO: With resuming, if we bail out and resuse the child tree, we should - // keep these effects. - firstCapturedUpdate: null, - lastCapturedUpdate: null, - - firstEffect: null, - lastEffect: null, - - firstCapturedEffect: null, - lastCapturedEffect: null - }; - return queue; -} - -function createUpdate(expirationTime) { - return { - expirationTime: expirationTime, - - tag: UpdateState, - payload: null, - callback: null, - - next: null, - nextEffect: null - }; -} - -function appendUpdateToQueue(queue, update) { - // Append the update to the end of the list. - if (queue.lastUpdate === null) { - // Queue is empty - queue.firstUpdate = queue.lastUpdate = update; - } else { - queue.lastUpdate.next = update; - queue.lastUpdate = update; - } -} - -function enqueueUpdate(fiber, update) { - // Update queues are created lazily. - var alternate = fiber.alternate; - var queue1 = void 0; - var queue2 = void 0; - if (alternate === null) { - // There's only one fiber. - queue1 = fiber.updateQueue; - queue2 = null; - if (queue1 === null) { - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - } - } else { - // There are two owners. - queue1 = fiber.updateQueue; - queue2 = alternate.updateQueue; - if (queue1 === null) { - if (queue2 === null) { - // Neither fiber has an update queue. Create new ones. - queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState); - queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState + case EventTarget: { + if (enableEventAPI) { + return updateEventTarget( + current$$1, + workInProgress, + renderExpirationTime ); - } else { - // Only one fiber has an update queue. Clone to create a new one. - queue1 = fiber.updateQueue = cloneUpdateQueue(queue2); - } - } else { - if (queue2 === null) { - // Only one fiber has an update queue. Clone to create a new one. - queue2 = alternate.updateQueue = cloneUpdateQueue(queue1); - } else { - // Both owners have an update queue. } + break; } } - if (queue2 === null || queue1 === queue2) { - // There's only a single queue. - appendUpdateToQueue(queue1, update); - } else { - // There are two queues. We need to append the update to both queues, - // while accounting for the persistent structure of the list — we don't - // want the same update to be added multiple times. - if (queue1.lastUpdate === null || queue2.lastUpdate === null) { - // One of the queues is not empty. We must add the update to both queues. - appendUpdateToQueue(queue1, update); - appendUpdateToQueue(queue2, update); - } else { - // Both queues are non-empty. The last update is the same in both lists, - // because of structural sharing. So, only append to one of the lists. - appendUpdateToQueue(queue1, update); - // But we still need to update the `lastUpdate` pointer of queue2. - queue2.lastUpdate = update; - } - } - - { - if ( - fiber.tag === ClassComponent && - (currentlyProcessingQueue === queue1 || - (queue2 !== null && currentlyProcessingQueue === queue2)) && - !didWarnUpdateInsideUpdate - ) { - warningWithoutStack$1( - false, - "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." + (function() { + { + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); - didWarnUpdateInsideUpdate = true; } - } -} - -function enqueueCapturedUpdate(workInProgress, update) { - // Captured updates go into a separate list, and only on the work-in- - // progress queue. - var workInProgressQueue = workInProgress.updateQueue; - if (workInProgressQueue === null) { - workInProgressQueue = workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - ); - } else { - // TODO: I put this here rather than createWorkInProgress so that we don't - // clone the queue unnecessarily. There's probably a better way to - // structure this. - workInProgressQueue = ensureWorkInProgressQueueIsAClone( - workInProgress, - workInProgressQueue - ); - } - - // Append the update to the end of the list. - if (workInProgressQueue.lastCapturedUpdate === null) { - // This is the first render phase update - workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update; - } else { - workInProgressQueue.lastCapturedUpdate.next = update; - workInProgressQueue.lastCapturedUpdate = update; - } -} - -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; - if (current !== null) { - // If the work-in-progress queue is equal to the current queue, - // we need to clone it first. - if (queue === current.updateQueue) { - queue = workInProgress.updateQueue = cloneUpdateQueue(queue); - } - } - return queue; -} - -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case ReplaceState: { - var _payload = update.payload; - if (typeof _payload === "function") { - // Updater function - { - enterDisallowedContextReadInDEV(); - if ( - debugRenderPhaseSideEffects || - (debugRenderPhaseSideEffectsForStrictMode && - workInProgress.mode & StrictMode) - ) { - _payload.call(instance, prevState, nextProps); - } - } - var nextState = _payload.call(instance, prevState, nextProps); - { - exitDisallowedContextReadInDEV(); - } - return nextState; - } - // State object - return _payload; - } - case CaptureUpdate: { - workInProgress.effectTag = - (workInProgress.effectTag & ~ShouldCapture) | DidCapture; - } - // Intentional fallthrough - case UpdateState: { - var _payload2 = update.payload; - var partialState = void 0; - if (typeof _payload2 === "function") { - // Updater function - { - enterDisallowedContextReadInDEV(); - if ( - debugRenderPhaseSideEffects || - (debugRenderPhaseSideEffectsForStrictMode && - workInProgress.mode & StrictMode) - ) { - _payload2.call(instance, prevState, nextProps); - } - } - partialState = _payload2.call(instance, prevState, nextProps); - { - exitDisallowedContextReadInDEV(); - } - } else { - // Partial state object - partialState = _payload2; - } - if (partialState === null || partialState === undefined) { - // Null and undefined are treated as no-ops. - return prevState; - } - // Merge the partial state and the previous state. - return Object.assign({}, prevState, partialState); - } - case ForceUpdate: { - hasForceUpdate = true; - return prevState; - } - } - return prevState; -} - -function processUpdateQueue( - workInProgress, - queue, - props, - instance, - renderExpirationTime -) { - hasForceUpdate = false; - - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - - { - currentlyProcessingQueue = queue; - } - - // These values may change as we process the queue. - var newBaseState = queue.baseState; - var newFirstUpdate = null; - var newExpirationTime = NoWork; - - // Iterate through the list of updates to compute the result. - var update = queue.firstUpdate; - var resultState = newBaseState; - while (update !== null) { - var updateExpirationTime = update.expirationTime; - if (updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstUpdate === null) { - // This is the first skipped update. It will be the first update in - // the new list. - newFirstUpdate = update; - // Since this is the first update that was skipped, the current result - // is the new base state. - newBaseState = resultState; - } - // Since this update will remain in the list, update the remaining - // expiration time. - if (newExpirationTime < updateExpirationTime) { - newExpirationTime = updateExpirationTime; - } - } else { - // This update does have sufficient priority. Process it and compute - // a new result. - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var _callback = update.callback; - if (_callback !== null) { - workInProgress.effectTag |= Callback; - // Set this to null, in case it was mutated during an aborted render. - update.nextEffect = null; - if (queue.lastEffect === null) { - queue.firstEffect = queue.lastEffect = update; - } else { - queue.lastEffect.nextEffect = update; - queue.lastEffect = update; - } - } - } - // Continue to the next update. - update = update.next; - } - - // Separately, iterate though the list of captured updates. - var newFirstCapturedUpdate = null; - update = queue.firstCapturedUpdate; - while (update !== null) { - var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime < renderExpirationTime) { - // This update does not have sufficient priority. Skip it. - if (newFirstCapturedUpdate === null) { - // This is the first skipped captured update. It will be the first - // update in the new list. - newFirstCapturedUpdate = update; - // If this is the first update that was skipped, the current result is - // the new base state. - if (newFirstUpdate === null) { - newBaseState = resultState; - } - } - // Since this update will remain in the list, update the remaining - // expiration time. - if (newExpirationTime < _updateExpirationTime) { - newExpirationTime = _updateExpirationTime; - } - } else { - // This update does have sufficient priority. Process it and compute - // a new result. - resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - ); - var _callback2 = update.callback; - if (_callback2 !== null) { - workInProgress.effectTag |= Callback; - // Set this to null, in case it was mutated during an aborted render. - update.nextEffect = null; - if (queue.lastCapturedEffect === null) { - queue.firstCapturedEffect = queue.lastCapturedEffect = update; - } else { - queue.lastCapturedEffect.nextEffect = update; - queue.lastCapturedEffect = update; - } - } - } - update = update.next; - } - - if (newFirstUpdate === null) { - queue.lastUpdate = null; - } - if (newFirstCapturedUpdate === null) { - queue.lastCapturedUpdate = null; - } else { - workInProgress.effectTag |= Callback; - } - if (newFirstUpdate === null && newFirstCapturedUpdate === null) { - // We processed every update, without skipping. That means the new base - // state is the same as the result state. - newBaseState = resultState; - } - - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = newFirstCapturedUpdate; - - // Set the remaining expiration time to be whatever is remaining in the queue. - // This should be fine because the only two other things that contribute to - // expiration time are props and context. We're already in the middle of the - // begin phase by the time we start processing the queue, so we've already - // dealt with the props. Context in components that specify - // shouldComponentUpdate is tricky; but we'll have to account for - // that regardless. - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; - - { - currentlyProcessingQueue = null; - } -} - -function callCallback(callback, context) { - invariant( - typeof callback === "function", - "Invalid argument passed as callback. Expected a function. Instead " + - "received: %s", - callback - ); - callback.call(context); -} - -function resetHasForceUpdateBeforeProcessing() { - hasForceUpdate = false; -} - -function checkHasForceUpdateAfterProcessing() { - return hasForceUpdate; -} - -function commitUpdateQueue( - finishedWork, - finishedQueue, - instance, - renderExpirationTime -) { - // If the finished render included captured updates, and there are still - // lower priority updates left over, we need to keep the captured updates - // in the queue so that they are rebased and not dropped once we process the - // queue again at the lower priority. - if (finishedQueue.firstCapturedUpdate !== null) { - // Join the captured update list to the end of the normal list. - if (finishedQueue.lastUpdate !== null) { - finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate; - finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate; - } - // Clear the list of captured updates. - finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null; - } - - // Commit the effects - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} - -function commitUpdateEffects(effect, instance) { - while (effect !== null) { - var _callback3 = effect.callback; - if (_callback3 !== null) { - effect.callback = null; - callCallback(_callback3, instance); - } - effect = effect.nextEffect; - } -} - -function createCapturedValue(value, source) { - // If the value is an error, call this function immediately after it is thrown - // so the stack is accurate. - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; + })(); } function markUpdate(workInProgress) { @@ -14032,43 +14542,19 @@ if (supportsMutation) { // eslint-disable-next-line no-labels branches: if (node.tag === HostComponent) { var instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var props = node.memoizedProps; var type = node.type; - if (isHidden) { - // This child is inside a timed out tree. Hide it. - instance = cloneHiddenInstance(instance, type, props, node); - } else { - // This child was previously inside a timed out tree. If it was not - // updated during this render, it may need to be unhidden. Clone - // again to be sure. - instance = cloneUnhiddenInstance(instance, type, props, node); - } - node.stateNode = instance; + instance = cloneHiddenInstance(instance, type, props, node); } appendInitialChild(parent, instance); } else if (node.tag === HostText) { var _instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var text = node.memoizedProps; - var rootContainerInstance = getRootHostContainer(); - var currentHostContext = getHostContext(); - if (isHidden) { - _instance = createHiddenTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } else { - _instance = createTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } - node.stateNode = _instance; + _instance = cloneHiddenTextInstance(_instance, text, node); } appendInitialChild(parent, _instance); } else if (node.tag === HostPortal) { @@ -14076,22 +14562,28 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - var current = node.alternate; - if (current !== null) { - var oldState = current.memoizedState; - var newState = node.memoizedState; - var oldIsHidden = oldState !== null; - var newIsHidden = newState !== null; - if (oldIsHidden !== newIsHidden) { - // The placeholder either just timed out or switched back to the normal - // children after having previously timed out. Toggle the visibility of - // the direct host children. - var primaryChildParent = newIsHidden ? node.child : node; + if ((node.effectTag & Update) !== NoEffect) { + // Need to toggle the visibility of the primary children. + var newIsHidden = node.memoizedState !== null; + if (newIsHidden) { + var primaryChildParent = node.child; if (primaryChildParent !== null) { - appendAllChildren(parent, primaryChildParent, true, newIsHidden); + if (primaryChildParent.child !== null) { + primaryChildParent.child.return = primaryChildParent; + appendAllChildren( + parent, + primaryChildParent, + true, + newIsHidden + ); + } + var fallbackChildParent = primaryChildParent.sibling; + if (fallbackChildParent !== null) { + fallbackChildParent.return = node; + node = fallbackChildParent; + continue; + } } - // eslint-disable-next-line no-labels - break branches; } } if (node.child !== null) { @@ -14135,43 +14627,19 @@ if (supportsMutation) { // eslint-disable-next-line no-labels branches: if (node.tag === HostComponent) { var instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var props = node.memoizedProps; var type = node.type; - if (isHidden) { - // This child is inside a timed out tree. Hide it. - instance = cloneHiddenInstance(instance, type, props, node); - } else { - // This child was previously inside a timed out tree. If it was not - // updated during this render, it may need to be unhidden. Clone - // again to be sure. - instance = cloneUnhiddenInstance(instance, type, props, node); - } - node.stateNode = instance; + instance = cloneHiddenInstance(instance, type, props, node); } appendChildToContainerChildSet(containerChildSet, instance); } else if (node.tag === HostText) { var _instance2 = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var text = node.memoizedProps; - var rootContainerInstance = getRootHostContainer(); - var currentHostContext = getHostContext(); - if (isHidden) { - _instance2 = createHiddenTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } else { - _instance2 = createTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } - node.stateNode = _instance2; + _instance2 = cloneHiddenTextInstance(_instance2, text, node); } appendChildToContainerChildSet(containerChildSet, _instance2); } else if (node.tag === HostPortal) { @@ -14179,27 +14647,28 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - var current = node.alternate; - if (current !== null) { - var oldState = current.memoizedState; - var newState = node.memoizedState; - var oldIsHidden = oldState !== null; - var newIsHidden = newState !== null; - if (oldIsHidden !== newIsHidden) { - // The placeholder either just timed out or switched back to the normal - // children after having previously timed out. Toggle the visibility of - // the direct host children. - var primaryChildParent = newIsHidden ? node.child : node; + if ((node.effectTag & Update) !== NoEffect) { + // Need to toggle the visibility of the primary children. + var newIsHidden = node.memoizedState !== null; + if (newIsHidden) { + var primaryChildParent = node.child; if (primaryChildParent !== null) { - appendAllChildrenToContainer( - containerChildSet, - primaryChildParent, - true, - newIsHidden - ); + if (primaryChildParent.child !== null) { + primaryChildParent.child.return = primaryChildParent; + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + true, + newIsHidden + ); + } + var fallbackChildParent = primaryChildParent.sibling; + if (fallbackChildParent !== null) { + fallbackChildParent.return = node; + node = fallbackChildParent; + continue; + } } - // eslint-disable-next-line no-labels - break branches; } } if (node.child !== null) { @@ -14403,11 +14872,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } else { if (!newProps) { - invariant( - workInProgress.stateNode !== null, - "We must have new props for new mounts. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(workInProgress.stateNode !== null)) { + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // This can happen when we abort work. break; } @@ -14476,11 +14947,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { updateHostText$1(current, workInProgress, oldText, newText); } else { if (typeof newText !== "string") { - invariant( - workInProgress.stateNode !== null, - "We must have new props for new mounts. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(workInProgress.stateNode !== null)) { + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // This can happen when we abort work. } var _rootContainerInstance = getRootHostContainer(); @@ -14513,37 +14986,72 @@ function completeWork(current, workInProgress, renderExpirationTime) { } var nextDidTimeout = nextState !== null; - var prevDidTimeout = current !== null && current.memoizedState !== null; - + var prevDidTimeout = false; if (current === null) { // In cases where we didn't find a suitable hydration boundary we never // downgraded this to a DehydratedSuspenseComponent, but we still need to // pop the hydration state since we might be inside the insertion tree. popHydrationState(workInProgress); - } else if (!nextDidTimeout && prevDidTimeout) { - // We just switched from the fallback to the normal children. Delete - // the fallback. - // TODO: Would it be better to store the fallback fragment on - var currentFallbackChild = current.child.sibling; - if (currentFallbackChild !== null) { - // Deletions go at the beginning of the return fiber's effect list - var first = workInProgress.firstEffect; - if (first !== null) { - workInProgress.firstEffect = currentFallbackChild; - currentFallbackChild.nextEffect = first; - } else { - workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; - currentFallbackChild.nextEffect = null; + } else { + var prevState = current.memoizedState; + prevDidTimeout = prevState !== null; + if (!nextDidTimeout && prevState !== null) { + // We just switched from the fallback to the normal children. + + // Mark the event time of the switching from fallback to normal children, + // based on the start of when we first showed the fallback. This time + var fallbackExpirationTime = prevState.fallbackExpirationTime; + markRenderEventTime(fallbackExpirationTime); + + // Delete the fallback. + // TODO: Would it be better to store the fallback fragment on + // the stateNode during the begin phase? + var currentFallbackChild = current.child.sibling; + if (currentFallbackChild !== null) { + // Deletions go at the beginning of the return fiber's effect list + var first = workInProgress.firstEffect; + if (first !== null) { + workInProgress.firstEffect = currentFallbackChild; + currentFallbackChild.nextEffect = first; + } else { + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; + currentFallbackChild.nextEffect = null; + } + currentFallbackChild.effectTag = Deletion; } - currentFallbackChild.effectTag = Deletion; } } - if (nextDidTimeout || prevDidTimeout) { - // If the children are hidden, or if they were previous hidden, schedule - // an effect to toggle their visibility. This is also used to attach a - // retry listener to the promise. - workInProgress.effectTag |= Update; + if (nextDidTimeout && !prevDidTimeout) { + // If this subtreee is running in concurrent mode we can suspend, + // otherwise we won't suspend. + // TODO: This will still suspend a synchronous tree if anything + // in the concurrent tree already suspended during this render. + // This is a known bug. + if ((workInProgress.mode & ConcurrentMode) !== NoContext) { + renderDidSuspend(); + } + } + + if (supportsPersistence) { + // TODO: Only schedule updates if not prevDidTimeout. + if (nextDidTimeout) { + // If this boundary just timed out, schedule an effect to attach a + // retry listener to the proimse. This flag is also used to hide the + // primary children. + workInProgress.effectTag |= Update; + } + } + if (supportsMutation) { + // TODO: Only schedule updates if these values are non equal, i.e. it changed. + if (nextDidTimeout || prevDidTimeout) { + // If this boundary just timed out, schedule an effect to attach a + // retry listener to the proimse. This flag is also used to hide the + // primary children. In mutation mode, we also need the flag to + // *unhide* children that were previously hidden, so check if the + // is currently timed out, too. + workInProgress.effectTag |= Update; + } } break; } @@ -14578,11 +15086,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { if (enableSuspenseServerRenderer) { if (current === null) { var _wasHydrated2 = popHydrationState(workInProgress); - invariant( - _wasHydrated2, - "A dehydrated suspense component was completed without a hydrated node. " + - "This is probably a bug in React." - ); + (function() { + if (!_wasHydrated2) { + throw ReactError( + "A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React." + ); + } + })(); skipPastDehydratedSuspenseInstance(workInProgress); } else if ((workInProgress.effectTag & DidCapture) === NoEffect) { // This boundary did not suspend so it's now hydrated. @@ -14597,12 +15107,67 @@ function completeWork(current, workInProgress, renderExpirationTime) { } break; } + case EventComponent: { + if (enableEventAPI) { + popHostContext(workInProgress); + var _rootContainerInstance2 = getRootHostContainer(); + var responder = workInProgress.type.responder; + var eventComponentInstance = workInProgress.stateNode; + + if (eventComponentInstance === null) { + var responderState = null; + if (responder.createInitialState !== undefined) { + responderState = responder.createInitialState(newProps); + } + eventComponentInstance = workInProgress.stateNode = { + currentFiber: workInProgress, + props: newProps, + responder: responder, + rootEventTypes: null, + rootInstance: _rootContainerInstance2, + state: responderState + }; + markUpdate(workInProgress); + } else { + // Update the props on the event component state node + eventComponentInstance.props = newProps; + // Update the root container, so we can properly unmount events at some point + eventComponentInstance.rootInstance = _rootContainerInstance2; + // Update the current fiber + eventComponentInstance.currentFiber = workInProgress; + updateEventComponent(eventComponentInstance); + } + } + break; + } + case EventTarget: { + if (enableEventAPI) { + popHostContext(workInProgress); + var _type = workInProgress.type.type; + var _rootContainerInstance3 = getRootHostContainer(); + var shouldUpdate = handleEventTarget( + _type, + newProps, + _rootContainerInstance3, + workInProgress + ); + // Update the latest props on the stateNode. This is used + // during the event phase to find the most current props. + workInProgress.stateNode.props = newProps; + if (shouldUpdate) { + markUpdate(workInProgress); + } + } + break; + } default: - invariant( - false, - "Unknown unit of work tag. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } return null; @@ -14619,6 +15184,16 @@ function shouldCaptureSuspense(workInProgress) { return nextState === null; } +function createCapturedValue(value, source) { + // If the value is an error, call this function immediately after it is thrown + // so the stack is accurate. + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; +} + // Module provided by RN: /** * Intercept lifecycle errors and ensure they are shown with the correct stack @@ -14907,14 +15482,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostText: case HostPortal: case IncompleteClassComponent: + case EventTarget: // Nothing to do for these component types return; default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -14950,22 +15528,23 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } else if (typeof _destroy.then === "function") { addendum = "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. " + - "Instead, you may write an async function separately " + - "and then call it from inside the effect:\n\n" + - "async function fetchComment(commentId) {\n" + - " // You can await here\n" + - "}\n\n" + + "Instead, write the async function inside your effect " + + "and call it immediately:\n\n" + "useEffect(() => {\n" + - " fetchComment(commentId);\n" + - "}, [commentId]);\n\n" + - "In the future, React will provide a more idiomatic solution for data fetching " + - "that doesn't involve writing effects manually."; + " 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://fb.me/react-hooks-data-fetching"; } else { addendum = " You returned: " + _destroy; } warningWithoutStack$1( false, - "An Effect function must not return anything besides a function, " + + "An effect function must not return anything besides a function, " + "which is used for clean-up.%s%s", addendum, getStackByFiberInDevAndProd(finishedWork) @@ -15201,15 +15780,52 @@ function commitLifeCycles( return; } case SuspenseComponent: - break; case IncompleteClassComponent: - break; + return; + case EventTarget: { + if (enableEventAPI) { + var _type = finishedWork.type.type; + var _props = finishedWork.memoizedProps; + var _instance3 = finishedWork.stateNode; + var parentInstance = null; + + var node = finishedWork.return; + // Traverse up the fiber tree until we find the parent host node. + while (node !== null) { + if (node.tag === HostComponent) { + parentInstance = node.stateNode; + break; + } else if (node.tag === HostRoot) { + parentInstance = node.stateNode.containerInfo; + break; + } + node = node.return; + } + (function() { + if (!(parentInstance !== null)) { + throw ReactError( + "This should have a parent host component initialized. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + commitEventTarget(_type, _props, _instance3, parentInstance); + } + return; + } + case EventComponent: { + if (enableEventAPI) { + mountEventComponent(finishedWork.stateNode); + } + return; + } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -15227,11 +15843,11 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { unhideInstance(node.stateNode, node.memoizedProps); } } else if (node.tag === HostText) { - var _instance3 = node.stateNode; + var _instance4 = node.stateNode; if (isHidden) { - hideTextInstance(_instance3); + hideTextInstance(_instance4); } else { - unhideTextInstance(_instance3, node.memoizedProps); + unhideTextInstance(_instance4, node.memoizedProps); } } else if ( node.tag === SuspenseComponent && @@ -15356,6 +15972,13 @@ function commitUnmount(current$$1) { } return; } + case EventComponent: { + if (enableEventAPI) { + var eventComponentInstance = current$$1.stateNode; + unmountEventComponent(eventComponentInstance); + current$$1.stateNode = null; + } + } } } @@ -15430,13 +16053,11 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { - return; - } - case HostComponent: { - return; - } - case HostText: { + case ClassComponent: + case HostComponent: + case HostText: + case EventTarget: + case EventComponent: { return; } case HostRoot: @@ -15449,11 +16070,13 @@ function commitContainer(finishedWork) { return; } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -15466,11 +16089,13 @@ function getHostParentFiber(fiber) { } parent = parent.return; } - invariant( - false, - "Expected to find a host parent. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } function isHostParent(fiber) { @@ -15552,11 +16177,13 @@ function commitPlacement(finishedWork) { isContainer = true; break; default: - invariant( - false, - "Invalid host parent fiber. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } if (parentFiber.effectTag & ContentReset) { // Reset the text content of the parent before doing any insertions @@ -15569,17 +16196,18 @@ function commitPlacement(finishedWork) { var node = finishedWork; while (true) { if (node.tag === HostComponent || node.tag === HostText) { + var stateNode = node.stateNode; if (before) { if (isContainer) { - insertInContainerBefore(parent, node.stateNode, before); + insertInContainerBefore(parent, stateNode, before); } else { - insertBefore(parent, node.stateNode, before); + insertBefore(parent, stateNode, before); } } else { if (isContainer) { - appendChildToContainer(parent, node.stateNode); + appendChildToContainer(parent, stateNode); } else { - appendChild(parent, node.stateNode); + appendChild(parent, stateNode); } } } else if (node.tag === HostPortal) { @@ -15621,11 +16249,13 @@ function unmountHostComponents(current$$1) { if (!currentParentIsValid) { var parent = node.return; findParent: while (true) { - invariant( - parent !== null, - "Expected to find a host parent. This error is likely caused by " + - "a bug in React. Please file an issue." - ); + (function() { + if (!(parent !== null)) { + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); switch (parent.tag) { case HostComponent: currentParent = parent.stateNode; @@ -15728,6 +16358,13 @@ function commitWork(current$$1, finishedWork) { commitHookEffectList(UnmountMutation, MountMutation, finishedWork); return; } + case Profiler: { + return; + } + case SuspenseComponent: { + commitSuspenseComponent(finishedWork); + return; + } } commitContainer(finishedWork); @@ -15775,11 +16412,13 @@ function commitWork(current$$1, finishedWork) { return; } case HostText: { - invariant( - finishedWork.stateNode !== null, - "This should have a text node initialized. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(finishedWork.stateNode !== null)) { + throw ReactError( + "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var textInstance = finishedWork.stateNode; var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps @@ -15789,6 +16428,9 @@ function commitWork(current$$1, finishedWork) { commitTextUpdate(textInstance, oldText, newText); return; } + case EventTarget: { + return; + } case HostRoot: { return; } @@ -15796,63 +16438,75 @@ function commitWork(current$$1, finishedWork) { return; } case SuspenseComponent: { - var newState = finishedWork.memoizedState; - - var newDidTimeout = void 0; - var primaryChildParent = finishedWork; - if (newState === null) { - newDidTimeout = false; - } else { - newDidTimeout = true; - primaryChildParent = finishedWork.child; - if (newState.timedOutAt === NoWork) { - // If the children had not already timed out, record the time. - // This is used to compute the elapsed time during subsequent - // attempts to render the children. - newState.timedOutAt = requestCurrentTime(); - } - } - - if (primaryChildParent !== null) { - hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); - } - - // If this boundary just timed out, then it will have a set of thenables. - // For each thenable, attach a listener so that when it resolves, React - // attempts to re-render the boundary in the primary (pre-timeout) state. - var thenables = finishedWork.updateQueue; - if (thenables !== null) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; - if (retryCache === null) { - retryCache = finishedWork.stateNode = new PossiblyWeakSet$1(); - } - thenables.forEach(function(thenable) { - // Memoize using the boundary fiber to prevent redundant listeners. - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - if (enableSchedulerTracing) { - retry = tracing.unstable_wrap(retry); - } - if (!retryCache.has(thenable)) { - retryCache.add(thenable); - thenable.then(retry, retry); - } - }); - } - + commitSuspenseComponent(finishedWork); return; } case IncompleteClassComponent: { return; } + case EventComponent: { + return; + } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + } + } +} + +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + + var newDidTimeout = void 0; + var primaryChildParent = finishedWork; + if (newState === null) { + newDidTimeout = false; + } else { + newDidTimeout = true; + primaryChildParent = finishedWork.child; + if (newState.fallbackExpirationTime === NoWork) { + // If the children had not already timed out, record the time. + // This is used to compute the elapsed time during subsequent + // attempts to render the children. + // We model this as a normal pri expiration time since that's + // how we infer start time for updates. + newState.fallbackExpirationTime = computeAsyncExpirationNoBucket( + requestCurrentTime() ); } } + + if (supportsMutation && primaryChildParent !== null) { + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + } + + // If this boundary just timed out, then it will have a set of thenables. + // For each thenable, attach a listener so that when it resolves, React + // attempts to re-render the boundary in the primary (pre-timeout) state. + var thenables = finishedWork.updateQueue; + if (thenables !== null) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + if (retryCache === null) { + retryCache = finishedWork.stateNode = new PossiblyWeakSet$1(); + } + thenables.forEach(function(thenable) { + // Memoize using the boundary fiber to prevent redundant listeners. + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + if (!retryCache.has(thenable)) { + if (enableSchedulerTracing) { + retry = tracing.unstable_wrap(retry); + } + retryCache.add(thenable); + thenable.then(retry, retry); + } + }); + } } function commitResetTextContent(current$$1) { @@ -15981,48 +16635,8 @@ function throwException( // This is a thenable. var thenable = value; - // Find the earliest timeout threshold of all the placeholders in the - // ancestor path. We could avoid this traversal by storing the thresholds on - // the stack, but we choose not to because we only hit this path if we're - // IO-bound (i.e. if something suspends). Whereas the stack is used even in - // the non-IO- bound case. - var _workInProgress = returnFiber; - var earliestTimeoutMs = -1; - var startTimeMs = -1; - do { - if (_workInProgress.tag === SuspenseComponent) { - var current$$1 = _workInProgress.alternate; - if (current$$1 !== null) { - var currentState = current$$1.memoizedState; - if (currentState !== null) { - // Reached a boundary that already timed out. Do not search - // any further. - var timedOutAt = currentState.timedOutAt; - startTimeMs = expirationTimeToMs(timedOutAt); - // Do not search any further. - break; - } - } - var timeoutPropMs = _workInProgress.pendingProps.maxDuration; - if (typeof timeoutPropMs === "number") { - if (timeoutPropMs <= 0) { - earliestTimeoutMs = 0; - } else if ( - earliestTimeoutMs === -1 || - timeoutPropMs < earliestTimeoutMs - ) { - earliestTimeoutMs = timeoutPropMs; - } - } - } - // If there is a DehydratedSuspenseComponent we don't have to do anything because - // if something suspends inside it, we will simply leave that as dehydrated. It - // will never timeout. - _workInProgress = _workInProgress.return; - } while (_workInProgress !== null); - // Schedule the nearest Suspense to re-render the timed out view. - _workInProgress = returnFiber; + var _workInProgress = returnFiber; do { if ( _workInProgress.tag === SuspenseComponent && @@ -16048,7 +16662,7 @@ function throwException( // Note: It doesn't matter whether the component that suspended was // inside a concurrent mode tree. If the Suspense is outside of it, we // should *not* suspend the commit. - if ((_workInProgress.mode & ConcurrentMode) === NoEffect) { + if ((_workInProgress.mode & ConcurrentMode) === NoContext) { _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete. @@ -16086,41 +16700,6 @@ function throwException( attachPingListener(root, renderExpirationTime, thenable); - var absoluteTimeoutMs = void 0; - if (earliestTimeoutMs === -1) { - // If no explicit threshold is given, default to an arbitrarily large - // value. The actual size doesn't matter because the threshold for the - // whole tree will be clamped to the expiration time. - absoluteTimeoutMs = maxSigned31BitInt; - } else { - if (startTimeMs === -1) { - // This suspend happened outside of any already timed-out - // placeholders. We don't know exactly when the update was - // scheduled, but we can infer an approximate start time from the - // expiration time. First, find the earliest uncommitted expiration - // time in the tree, including work that is suspended. Then subtract - // the offset used to compute an async update's expiration time. - // This will cause high priority (interactive) work to expire - // earlier than necessary, but we can account for this by adjusting - // for the Just Noticeable Difference. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; - } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; - } - - // Mark the earliest timeout in the suspended fiber's ancestor path. - // After completing the root, we'll take the largest of all the - // suspended fiber's timeouts and use it to compute a timeout for the - // whole tree. - renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); - _workInProgress.effectTag |= ShouldCapture; _workInProgress.expirationTime = renderExpirationTime; return; @@ -16134,13 +16713,15 @@ function throwException( var retryCache = _workInProgress.memoizedState; if (retryCache === null) { retryCache = _workInProgress.memoizedState = new PossiblyWeakSet(); - var _current = _workInProgress.alternate; - invariant( - _current, - "A dehydrated suspense boundary must commit before trying to render. " + - "This is probably a bug in React." - ); - _current.memoizedState = retryCache; + var current$$1 = _workInProgress.alternate; + (function() { + if (!current$$1) { + throw ReactError( + "A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React." + ); + } + })(); + current$$1.memoizedState = retryCache; } // Memoize using the boundary fiber to prevent redundant listeners. if (!retryCache.has(thenable)) { @@ -16244,11 +16825,13 @@ function unwindWork(workInProgress, renderExpirationTime) { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); var _effectTag = workInProgress.effectTag; - invariant( - (_effectTag & DidCapture) === NoEffect, - "The root failed to unmount after an error. This is likely a bug in " + - "React. Please file an issue." - ); + (function() { + if (!((_effectTag & DidCapture) === NoEffect)) { + throw ReactError( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + } + })(); workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } @@ -16285,6 +16868,12 @@ function unwindWork(workInProgress, renderExpirationTime) { case ContextProvider: popProvider(workInProgress); return null; + case EventComponent: + case EventTarget: + if (enableEventAPI) { + popHostContext(workInProgress); + } + return null; default: return null; } @@ -16319,1518 +16908,200 @@ function unwindInterruptedWork(interruptedWork) { } } +// TODO: Ahaha Andrew is bad at spellling +// DEV stuff +var ceil = Math.ceil; + var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; +var ReactShouldWarnActingUpdates = + ReactSharedInternals.ReactShouldWarnActingUpdates; -var didWarnAboutStateTransition = void 0; -var didWarnSetStateChildContext = void 0; -var warnAboutUpdateOnUnmounted = void 0; -var warnAboutInvalidUpdates = void 0; +var NotWorking = 0; +var BatchedPhase = 1; +var LegacyUnbatchedPhase = 2; +var RenderPhase = 4; +var CommitPhase = 5; -if (enableSchedulerTracing) { - // Provide explicit error message when production+profiling bundle of e.g. react-dom - // is used with production (non-profiling) bundle of scheduler/tracing - invariant( - tracing.__interactionsRef != null && - tracing.__interactionsRef.current != null, - "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 http://fb.me/react-profiling" - ); -} +var RootIncomplete = 0; +var RootErrored = 1; +var RootSuspended = 2; +var RootCompleted = 3; -{ - didWarnAboutStateTransition = false; - didWarnSetStateChildContext = false; - var didWarnStateUpdateForUnmountedComponent = {}; +// The phase of work we're currently in +var workPhase = NotWorking; +// The root we're working on +var workInProgressRoot = null; +// The fiber we're working on +var workInProgress = null; +// The expiration time we're rendering +var renderExpirationTime = NoWork; +// Whether to root completed, errored, suspended, etc. +var workInProgressRootExitStatus = RootIncomplete; +// Most recent event time among processed updates during this render. +// This is conceptually a time stamp but expressed in terms of an ExpirationTime +// because we deal mostly with expiration times in the hot path, so this avoids +// the conversion happening in the hot path. +var workInProgressRootMostRecentEventTime = Sync; - warnAboutUpdateOnUnmounted = function(fiber, isClass) { - // We show the whole stack but dedupe on the top component's name because - // the problematic code almost always lies inside that component. - var componentName = getComponentName(fiber.type) || "ReactComponent"; - if (didWarnStateUpdateForUnmountedComponent[componentName]) { - return; - } - warningWithoutStack$1( - false, - "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.%s", - isClass - ? "the componentWillUnmount method" - : "a useEffect cleanup function", - getStackByFiberInDevAndProd(fiber) - ); - didWarnStateUpdateForUnmountedComponent[componentName] = true; - }; - - warnAboutInvalidUpdates = function(instance) { - switch (phase) { - case "getChildContext": - if (didWarnSetStateChildContext) { - return; - } - warningWithoutStack$1( - false, - "setState(...): Cannot call setState() inside getChildContext()" - ); - didWarnSetStateChildContext = true; - break; - case "render": - if (didWarnAboutStateTransition) { - return; - } - warningWithoutStack$1( - false, - "Cannot update during an existing state transition (such as within " + - "`render`). Render methods should be a pure function of props and state." - ); - didWarnAboutStateTransition = true; - break; - } - }; -} - -var isWorking = false; - -// The next work in progress fiber that we're currently working on. -var nextUnitOfWork = null; -var nextRoot = null; -// The time at which we're currently rendering work. -var nextRenderExpirationTime = NoWork; -var nextLatestAbsoluteTimeoutMs = -1; -var nextRenderDidError = false; - -// The next fiber with an effect that we're currently committing. var nextEffect = null; - -var isCommitting$1 = false; -var rootWithPendingPassiveEffects = null; -var passiveEffectCallbackHandle = null; -var passiveEffectCallback = null; - +var hasUncaughtError = false; +var firstUncaughtError = null; var legacyErrorBoundariesThatAlreadyFailed = null; -// Used for performance tracking. +var rootDoesHavePassiveEffects = false; +var rootWithPendingPassiveEffects = null; +var pendingPassiveEffectsExpirationTime = NoWork; + +var rootsWithPendingDiscreteUpdates = null; + +// Use these to prevent an infinite loop of nested updates +var NESTED_UPDATE_LIMIT = 50; +var nestedUpdateCount = 0; +var rootWithNestedUpdates = null; + +var NESTED_PASSIVE_UPDATE_LIMIT = 50; +var nestedPassiveUpdateCount = 0; + var interruptedBy = null; -var stashedWorkInProgressProperties = void 0; -var replayUnitOfWork = void 0; -var mayReplayFailedUnitOfWork = void 0; -var isReplayingFailedUnitOfWork = void 0; -var originalReplayError = void 0; -var rethrowOriginalError = void 0; -if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - stashedWorkInProgressProperties = null; - mayReplayFailedUnitOfWork = true; - isReplayingFailedUnitOfWork = false; - originalReplayError = null; - replayUnitOfWork = function(failedUnitOfWork, thrownValue, isYieldy) { - if ( - thrownValue !== null && - typeof thrownValue === "object" && - typeof thrownValue.then === "function" - ) { - // Don't replay promises. Treat everything else like an error. - // TODO: Need to figure out a different strategy if/when we add - // support for catching other types. - return; - } +// Expiration times are computed by adding to the current time (the start +// time). However, if two updates are scheduled within the same event, we +// should treat their start times as simultaneous, even if the actual clock +// time has advanced between the first and second call. - // Restore the original state of the work-in-progress - if (stashedWorkInProgressProperties === null) { - // This should never happen. Don't throw because this code is DEV-only. - warningWithoutStack$1( - false, - "Could not replay rendering after an error. This is likely a bug in React. " + - "Please file an issue." - ); - return; - } - assignFiberPropertiesInDEV( - failedUnitOfWork, - stashedWorkInProgressProperties - ); +// In other words, because expiration times determine how updates are batched, +// we want all updates of like priority that occur within the same event to +// receive the same expiration time. Otherwise we get tearing. +var currentEventTime = NoWork; - switch (failedUnitOfWork.tag) { - case HostRoot: - popHostContainer(failedUnitOfWork); - popTopLevelContextObject(failedUnitOfWork); - break; - case HostComponent: - popHostContext(failedUnitOfWork); - break; - case ClassComponent: { - var Component = failedUnitOfWork.type; - if (isContextProvider(Component)) { - popContext(failedUnitOfWork); - } - break; - } - case HostPortal: - popHostContainer(failedUnitOfWork); - break; - case ContextProvider: - popProvider(failedUnitOfWork); - break; - } - // Replay the begin phase. - isReplayingFailedUnitOfWork = true; - originalReplayError = thrownValue; - invokeGuardedCallback(null, workLoop, null, isYieldy); - isReplayingFailedUnitOfWork = false; - originalReplayError = null; - if (hasCaughtError()) { - var replayError = clearCaughtError(); - if (replayError != null && thrownValue != null) { - try { - // Reading the expando property is intentionally - // inside `try` because it might be a getter or Proxy. - if (replayError._suppressLogging) { - // Also suppress logging for the original error. - thrownValue._suppressLogging = true; - } - } catch (inner) { - // Ignore. - } - } - } else { - // If the begin phase did not fail the second time, set this pointer - // back to the original value. - nextUnitOfWork = failedUnitOfWork; - } - }; - rethrowOriginalError = function() { - throw originalReplayError; - }; -} - -function resetStack() { - if (nextUnitOfWork !== null) { - var interruptedWork = nextUnitOfWork.return; - while (interruptedWork !== null) { - unwindInterruptedWork(interruptedWork); - interruptedWork = interruptedWork.return; - } +function requestCurrentTime() { + if (workPhase === RenderPhase || workPhase === CommitPhase) { + // We're inside React, so it's fine to read the actual time. + return msToExpirationTime(now()); } - - { - ReactStrictModeWarnings.discardPendingWarnings(); - checkThatStackIsEmpty(); + // We're not inside React, so we may be in the middle of a browser event. + if (currentEventTime !== NoWork) { + // Use the same start time for all updates until we enter React again. + return currentEventTime; } - - nextRoot = null; - nextRenderExpirationTime = NoWork; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = false; - nextUnitOfWork = null; -} - -function commitAllHostEffects() { - while (nextEffect !== null) { - { - setCurrentFiber(nextEffect); - } - recordEffect(); - - var effectTag = nextEffect.effectTag; - - if (effectTag & ContentReset) { - commitResetTextContent(nextEffect); - } - - if (effectTag & Ref) { - var current$$1 = nextEffect.alternate; - if (current$$1 !== null) { - commitDetachRef(current$$1); - } - } - - // The following switch statement is only concerned about placement, - // updates, and deletions. To avoid needing to add a case for every - // possible bitmap value, we remove the secondary effects from the - // effect tag and switch on that value. - var primaryEffectTag = effectTag & (Placement | Update | Deletion); - switch (primaryEffectTag) { - case Placement: { - commitPlacement(nextEffect); - // Clear the "placement" from effect tag so that we know that this is inserted, before - // any life-cycles like componentDidMount gets called. - // TODO: findDOMNode doesn't rely on this any more but isMounted - // does and isMounted is deprecated anyway so we should be able - // to kill this. - nextEffect.effectTag &= ~Placement; - break; - } - case PlacementAndUpdate: { - // Placement - commitPlacement(nextEffect); - // Clear the "placement" from effect tag so that we know that this is inserted, before - // any life-cycles like componentDidMount gets called. - nextEffect.effectTag &= ~Placement; - - // Update - var _current = nextEffect.alternate; - commitWork(_current, nextEffect); - break; - } - case Update: { - var _current2 = nextEffect.alternate; - commitWork(_current2, nextEffect); - break; - } - case Deletion: { - commitDeletion(nextEffect); - break; - } - } - nextEffect = nextEffect.nextEffect; - } - - { - resetCurrentFiber(); - } -} - -function commitBeforeMutationLifecycles() { - while (nextEffect !== null) { - { - setCurrentFiber(nextEffect); - } - - var effectTag = nextEffect.effectTag; - if (effectTag & Snapshot) { - recordEffect(); - var current$$1 = nextEffect.alternate; - commitBeforeMutationLifeCycles(current$$1, nextEffect); - } - - nextEffect = nextEffect.nextEffect; - } - - { - resetCurrentFiber(); - } -} - -function commitAllLifeCycles(finishedRoot, committedExpirationTime) { - { - ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); - ReactStrictModeWarnings.flushLegacyContextWarning(); - - if (warnAboutDeprecatedLifecycles) { - ReactStrictModeWarnings.flushPendingDeprecationWarnings(); - } - } - while (nextEffect !== null) { - { - setCurrentFiber(nextEffect); - } - var effectTag = nextEffect.effectTag; - - if (effectTag & (Update | Callback)) { - recordEffect(); - var current$$1 = nextEffect.alternate; - commitLifeCycles( - finishedRoot, - current$$1, - nextEffect, - committedExpirationTime - ); - } - - if (effectTag & Ref) { - recordEffect(); - commitAttachRef(nextEffect); - } - - if (effectTag & Passive) { - rootWithPendingPassiveEffects = finishedRoot; - } - - nextEffect = nextEffect.nextEffect; - } - { - resetCurrentFiber(); - } -} - -function commitPassiveEffects(root, firstEffect) { - rootWithPendingPassiveEffects = null; - passiveEffectCallbackHandle = null; - passiveEffectCallback = null; - - // Set this to true to prevent re-entrancy - var previousIsRendering = isRendering; - isRendering = true; - - var effect = firstEffect; - do { - { - setCurrentFiber(effect); - } - - if (effect.effectTag & Passive) { - var didError = false; - var error = void 0; - { - invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); - if (hasCaughtError()) { - didError = true; - error = clearCaughtError(); - } - } - if (didError) { - captureCommitPhaseError(effect, error); - } - } - effect = effect.nextEffect; - } while (effect !== null); - { - resetCurrentFiber(); - } - - isRendering = previousIsRendering; - - // Check if work was scheduled by one of the effects - var rootExpirationTime = root.expirationTime; - if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); - } - // Flush any sync work that was scheduled by effects - if (!isBatchingUpdates && !isRendering) { - performSyncWork(); - } -} - -function isAlreadyFailedLegacyErrorBoundary(instance) { - return ( - legacyErrorBoundariesThatAlreadyFailed !== null && - legacyErrorBoundariesThatAlreadyFailed.has(instance) - ); -} - -function markLegacyErrorBoundaryAsFailed(instance) { - if (legacyErrorBoundariesThatAlreadyFailed === null) { - legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); - } else { - legacyErrorBoundariesThatAlreadyFailed.add(instance); - } -} - -function flushPassiveEffects() { - if (passiveEffectCallbackHandle !== null) { - cancelPassiveEffects(passiveEffectCallbackHandle); - } - if (passiveEffectCallback !== null) { - // We call the scheduled callback instead of commitPassiveEffects directly - // to ensure tracing works correctly. - passiveEffectCallback(); - } -} - -function commitRoot(root, finishedWork) { - isWorking = true; - isCommitting$1 = true; - startCommitTimer(); - - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug " + - "related to the return field. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - committedExpirationTime !== NoWork, - "Cannot commit an incomplete root. This error is likely caused by a " + - "bug in React. Please file an issue." - ); - root.pendingCommitExpirationTime = NoWork; - - // Update the pending priority levels to account for the work that we are - // about to commit. This needs to happen before calling the lifecycles, since - // they may schedule additional updates. - var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; - var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; - var earliestRemainingTimeBeforeCommit = - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit - ? childExpirationTimeBeforeCommit - : updateExpirationTimeBeforeCommit; - markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); - - var prevInteractions = null; - if (enableSchedulerTracing) { - // Restore any pending interactions at this point, - // So that cascading work triggered during the render phase will be accounted for. - prevInteractions = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - } - - // Reset this to null before calling lifecycles - ReactCurrentOwner$2.current = null; - - var firstEffect = void 0; - if (finishedWork.effectTag > PerformedWork) { - // A fiber's effect list consists only of its children, not itself. So if - // the root has an effect, we need to add it to the end of the list. The - // resulting list is the set that would belong to the root's parent, if - // it had one; that is, all the effects in the tree including the root. - if (finishedWork.lastEffect !== null) { - finishedWork.lastEffect.nextEffect = finishedWork; - firstEffect = finishedWork.firstEffect; - } else { - firstEffect = finishedWork; - } - } else { - // There is no effect on the root. - firstEffect = finishedWork.firstEffect; - } - - prepareForCommit(root.containerInfo); - - // Invoke instances of getSnapshotBeforeUpdate before mutation. - nextEffect = firstEffect; - startCommitSnapshotEffectsTimer(); - while (nextEffect !== null) { - var didError = false; - var error = void 0; - { - invokeGuardedCallback(null, commitBeforeMutationLifecycles, null); - if (hasCaughtError()) { - didError = true; - error = clearCaughtError(); - } - } - if (didError) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, error); - // Clean-up - if (nextEffect !== null) { - nextEffect = nextEffect.nextEffect; - } - } - } - stopCommitSnapshotEffectsTimer(); - - if (enableProfilerTimer) { - // Mark the current commit time to be shared by all Profilers in this batch. - // This enables them to be grouped later. - recordCommitTime(); - } - - // Commit all the side-effects within a tree. We'll do this in two passes. - // The first pass performs all the host insertions, updates, deletions and - // ref unmounts. - nextEffect = firstEffect; - startCommitHostEffectsTimer(); - while (nextEffect !== null) { - var _didError = false; - var _error = void 0; - { - invokeGuardedCallback(null, commitAllHostEffects, null); - if (hasCaughtError()) { - _didError = true; - _error = clearCaughtError(); - } - } - if (_didError) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, _error); - // Clean-up - if (nextEffect !== null) { - nextEffect = nextEffect.nextEffect; - } - } - } - stopCommitHostEffectsTimer(); - - resetAfterCommit(root.containerInfo); - - // The work-in-progress tree is now the current tree. This must come after - // the first pass of the commit phase, so that the previous tree is still - // current during componentWillUnmount, but before the second pass, so that - // the finished work is current during componentDidMount/Update. - root.current = finishedWork; - - // In the second pass we'll perform all life-cycles and ref callbacks. - // Life-cycles happen as a separate pass so that all placements, updates, - // and deletions in the entire tree have already been invoked. - // This pass also triggers any renderer-specific initial effects. - nextEffect = firstEffect; - startCommitLifeCyclesTimer(); - while (nextEffect !== null) { - var _didError2 = false; - var _error2 = void 0; - { - invokeGuardedCallback( - null, - commitAllLifeCycles, - null, - root, - committedExpirationTime - ); - if (hasCaughtError()) { - _didError2 = true; - _error2 = clearCaughtError(); - } - } - if (_didError2) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, _error2); - if (nextEffect !== null) { - nextEffect = nextEffect.nextEffect; - } - } - } - - if (firstEffect !== null && rootWithPendingPassiveEffects !== null) { - // This commit included a passive effect. These do not need to fire until - // after the next paint. Schedule an callback to fire them in an async - // event. To ensure serial execution, the callback will be flushed early if - // we enter rootWithPendingPassiveEffects commit phase before then. - var callback = commitPassiveEffects.bind(null, root, firstEffect); - if (enableSchedulerTracing) { - // TODO: Avoid this extra callback by mutating the tracing ref directly, - // like we do at the beginning of commitRoot. I've opted not to do that - // here because that code is still in flux. - callback = tracing.unstable_wrap(callback); - } - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return schedulePassiveEffects(callback); - } - ); - passiveEffectCallback = callback; - } - - isCommitting$1 = false; - isWorking = false; - stopCommitLifeCyclesTimer(); - stopCommitTimer(); - onCommitRoot(finishedWork.stateNode); - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCommitWork(finishedWork); - } - - var updateExpirationTimeAfterCommit = finishedWork.expirationTime; - var childExpirationTimeAfterCommit = finishedWork.childExpirationTime; - var earliestRemainingTimeAfterCommit = - childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit - ? childExpirationTimeAfterCommit - : updateExpirationTimeAfterCommit; - if (earliestRemainingTimeAfterCommit === NoWork) { - // If there's no remaining work, we can clear the set of already failed - // error boundaries. - legacyErrorBoundariesThatAlreadyFailed = null; - } - onCommit(root, earliestRemainingTimeAfterCommit); - - if (enableSchedulerTracing) { - tracing.__interactionsRef.current = prevInteractions; - - var subscriber = void 0; - - try { - subscriber = tracing.__subscriberRef.current; - if (subscriber !== null && root.memoizedInteractions.size > 0) { - var threadID = computeThreadID( - committedExpirationTime, - root.interactionThreadID - ); - subscriber.onWorkStopped(root.memoizedInteractions, threadID); - } - } catch (error) { - // It's not safe for commitRoot() to throw. - // Store the error for now and we'll re-throw in finishRendering(). - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } - } finally { - // Clear completed interactions from the pending Map. - // Unless the render was suspended or cascading work was scheduled, - // In which case– leave pending interactions until the subsequent render. - var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - // Only decrement the pending interaction count if we're done. - // If there's still work at the current priority, - // That indicates that we are waiting for suspense data. - if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { - pendingInteractionMap.delete(scheduledExpirationTime); - - scheduledInteractions.forEach(function(interaction) { - interaction.__count--; - - if (subscriber !== null && interaction.__count === 0) { - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - // It's not safe for commitRoot() to throw. - // Store the error for now and we'll re-throw in finishRendering(). - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } - } - } - }); - } - }); - } - } -} - -function resetChildExpirationTime(workInProgress, renderTime) { - if (renderTime !== Never && workInProgress.childExpirationTime === Never) { - // The children of this component are hidden. Don't bubble their - // expiration times. - return; - } - - var newChildExpirationTime = NoWork; - - // Bubble up the earliest expiration time. - if (enableProfilerTimer && workInProgress.mode & ProfileMode) { - // We're in profiling mode. - // Let's use this same traversal to update the render durations. - var actualDuration = workInProgress.actualDuration; - var treeBaseDuration = workInProgress.selfBaseDuration; - - // When a fiber is cloned, its actualDuration is reset to 0. - // This value will only be updated if work is done on the fiber (i.e. it doesn't bailout). - // When work is done, it should bubble to the parent's actualDuration. - // If the fiber has not been cloned though, (meaning no work was done), - // Then this value will reflect the amount of time spent working on a previous render. - // In that case it should not bubble. - // We determine whether it was cloned by comparing the child pointer. - var shouldBubbleActualDurations = - workInProgress.alternate === null || - workInProgress.child !== workInProgress.alternate.child; - - var child = workInProgress.child; - while (child !== null) { - var childUpdateExpirationTime = child.expirationTime; - var childChildExpirationTime = child.childExpirationTime; - if (childUpdateExpirationTime > newChildExpirationTime) { - newChildExpirationTime = childUpdateExpirationTime; - } - if (childChildExpirationTime > newChildExpirationTime) { - newChildExpirationTime = childChildExpirationTime; - } - if (shouldBubbleActualDurations) { - actualDuration += child.actualDuration; - } - treeBaseDuration += child.treeBaseDuration; - child = child.sibling; - } - workInProgress.actualDuration = actualDuration; - workInProgress.treeBaseDuration = treeBaseDuration; - } else { - var _child = workInProgress.child; - while (_child !== null) { - var _childUpdateExpirationTime = _child.expirationTime; - var _childChildExpirationTime = _child.childExpirationTime; - if (_childUpdateExpirationTime > newChildExpirationTime) { - newChildExpirationTime = _childUpdateExpirationTime; - } - if (_childChildExpirationTime > newChildExpirationTime) { - newChildExpirationTime = _childChildExpirationTime; - } - _child = _child.sibling; - } - } - - workInProgress.childExpirationTime = newChildExpirationTime; -} - -function completeUnitOfWork(workInProgress) { - // Attempt to complete the current unit of work, then move to the - // next sibling. If there are no more siblings, return to the - // parent fiber. - while (true) { - // The current, flushed, state of this fiber is the alternate. - // Ideally nothing should rely on this, but relying on it here - // means that we don't need an additional field on the work in - // progress. - var current$$1 = workInProgress.alternate; - { - setCurrentFiber(workInProgress); - } - - var returnFiber = workInProgress.return; - var siblingFiber = workInProgress.sibling; - - if ((workInProgress.effectTag & Incomplete) === NoEffect) { - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - // Don't replay if it fails during completion phase. - mayReplayFailedUnitOfWork = false; - } - // This fiber completed. - // Remember we're completing this unit so we can find a boundary if it fails. - nextUnitOfWork = workInProgress; - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - startProfilerTimer(workInProgress); - } - nextUnitOfWork = completeWork( - current$$1, - workInProgress, - nextRenderExpirationTime - ); - if (workInProgress.mode & ProfileMode) { - // Update render duration assuming we didn't error. - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); - } - } else { - nextUnitOfWork = completeWork( - current$$1, - workInProgress, - nextRenderExpirationTime - ); - } - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - // We're out of completion phase so replaying is fine now. - mayReplayFailedUnitOfWork = true; - } - stopWorkTimer(workInProgress); - resetChildExpirationTime(workInProgress, nextRenderExpirationTime); - { - resetCurrentFiber(); - } - - if (nextUnitOfWork !== null) { - // Completing this fiber spawned new work. Work on that next. - return nextUnitOfWork; - } - - if ( - returnFiber !== null && - // Do not append effects to parents if a sibling failed to complete - (returnFiber.effectTag & Incomplete) === NoEffect - ) { - // Append all the effects of the subtree and this fiber onto the effect - // list of the parent. The completion order of the children affects the - // side-effect order. - if (returnFiber.firstEffect === null) { - returnFiber.firstEffect = workInProgress.firstEffect; - } - if (workInProgress.lastEffect !== null) { - if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; - } - returnFiber.lastEffect = workInProgress.lastEffect; - } - - // If this fiber had side-effects, we append it AFTER the children's - // side-effects. We can perform certain side-effects earlier if - // needed, by doing multiple passes over the effect list. We don't want - // to schedule our own side-effect on our own list because if end up - // reusing children we'll schedule this effect onto itself since we're - // at the end. - var effectTag = workInProgress.effectTag; - // Skip both NoWork and PerformedWork tags when creating the effect list. - // PerformedWork effect is read by React DevTools but shouldn't be committed. - if (effectTag > PerformedWork) { - if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = workInProgress; - } else { - returnFiber.firstEffect = workInProgress; - } - returnFiber.lastEffect = workInProgress; - } - } - - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); - } - - if (siblingFiber !== null) { - // If there is more work to do in this returnFiber, do that next. - return siblingFiber; - } else if (returnFiber !== null) { - // If there's no more work in this returnFiber. Complete the returnFiber. - workInProgress = returnFiber; - continue; - } else { - // We've reached the root. - return null; - } - } else { - if (enableProfilerTimer && workInProgress.mode & ProfileMode) { - // Record the render duration for the fiber that errored. - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); - - // Include the time spent working on failed children before continuing. - var actualDuration = workInProgress.actualDuration; - var child = workInProgress.child; - while (child !== null) { - actualDuration += child.actualDuration; - child = child.sibling; - } - workInProgress.actualDuration = actualDuration; - } - - // This fiber did not complete because something threw. Pop values off - // the stack without entering the complete phase. If this is a boundary, - // capture values if possible. - var next = unwindWork(workInProgress, nextRenderExpirationTime); - // Because this fiber did not complete, don't reset its expiration time. - if (workInProgress.effectTag & DidCapture) { - // Restarting an error boundary - stopFailedWorkTimer(workInProgress); - } else { - stopWorkTimer(workInProgress); - } - - { - resetCurrentFiber(); - } - - if (next !== null) { - stopWorkTimer(workInProgress); - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); - } - - // If completing this work spawned new work, do that next. We'll come - // back here again. - // Since we're restarting, remove anything that is not a host effect - // from the effect tag. - next.effectTag &= HostEffectMask; - return next; - } - - if (returnFiber !== null) { - // Mark the parent fiber as incomplete and clear its effect list. - returnFiber.firstEffect = returnFiber.lastEffect = null; - returnFiber.effectTag |= Incomplete; - } - - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); - } - - if (siblingFiber !== null) { - // If there is more work to do in this returnFiber, do that next. - return siblingFiber; - } else if (returnFiber !== null) { - // If there's no more work in this returnFiber. Complete the returnFiber. - workInProgress = returnFiber; - continue; - } else { - return null; - } - } - } - - // Without this explicit null return Flow complains of invalid return type - // TODO Remove the above while(true) loop - // eslint-disable-next-line no-unreachable - return null; -} - -function performUnitOfWork(workInProgress) { - // The current, flushed, state of this fiber is the alternate. - // Ideally nothing should rely on this, but relying on it here - // means that we don't need an additional field on the work in - // progress. - var current$$1 = workInProgress.alternate; - - // See if beginning this work spawns more work. - startWorkTimer(workInProgress); - { - setCurrentFiber(workInProgress); - } - - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - stashedWorkInProgressProperties = assignFiberPropertiesInDEV( - stashedWorkInProgressProperties, - workInProgress - ); - } - - var next = void 0; - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - startProfilerTimer(workInProgress); - } - - next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); - workInProgress.memoizedProps = workInProgress.pendingProps; - - if (workInProgress.mode & ProfileMode) { - // Record the render duration assuming we didn't bailout (or error). - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); - } - } else { - next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); - workInProgress.memoizedProps = workInProgress.pendingProps; - } - - { - resetCurrentFiber(); - if (isReplayingFailedUnitOfWork) { - // Currently replaying a failed unit of work. This should be unreachable, - // because the render phase is meant to be idempotent, and it should - // have thrown again. Since it didn't, rethrow the original error, so - // React's internal stack is not misaligned. - rethrowOriginalError(); - } - } - if (true && ReactFiberInstrumentation_1.debugTool) { - ReactFiberInstrumentation_1.debugTool.onBeginWork(workInProgress); - } - - if (next === null) { - // If this doesn't spawn new work, complete the current work. - next = completeUnitOfWork(workInProgress); - } - - ReactCurrentOwner$2.current = null; - - return next; -} - -function workLoop(isYieldy) { - if (!isYieldy) { - // Flush work without yielding - while (nextUnitOfWork !== null) { - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - } - } else { - // Flush asynchronous work until there's a higher priority event - while (nextUnitOfWork !== null && !shouldYield$$1()) { - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - } - } -} - -function renderRoot(root, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused " + - "by a bug in React. Please file an issue." - ); - - flushPassiveEffects(); - - isWorking = true; - var previousDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - - var expirationTime = root.nextExpirationTimeToWorkOn; - - // Check if we're starting from a fresh stack, or if we're resuming from - // previously yielded work. - if ( - expirationTime !== nextRenderExpirationTime || - root !== nextRoot || - nextUnitOfWork === null - ) { - // Reset the stack and start working from the root. - resetStack(); - nextRoot = root; - nextRenderExpirationTime = expirationTime; - nextUnitOfWork = createWorkInProgress( - nextRoot.current, - null, - nextRenderExpirationTime - ); - root.pendingCommitExpirationTime = NoWork; - - if (enableSchedulerTracing) { - // Determine which interactions this batch of work currently includes, - // So that we can accurately attribute time spent working on it, - var interactions = new Set(); - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - if (scheduledExpirationTime >= expirationTime) { - scheduledInteractions.forEach(function(interaction) { - return interactions.add(interaction); - }); - } - }); - - // Store the current set of interactions on the FiberRoot for a few reasons: - // We can re-use it in hot functions like renderRoot() without having to recalculate it. - // We will also use it in commitWork() to pass to any Profiler onRender() hooks. - // This also provides DevTools with a way to access it when the onCommitRoot() hook is called. - root.memoizedInteractions = interactions; - - if (interactions.size > 0) { - var subscriber = tracing.__subscriberRef.current; - if (subscriber !== null) { - var threadID = computeThreadID( - expirationTime, - root.interactionThreadID - ); - try { - subscriber.onWorkStarted(interactions, threadID); - } catch (error) { - // Work thrown by an interaction tracing subscriber should be rethrown, - // But only once it's safe (to avoid leaving the scheduler in an invalid state). - // Store the error for now and we'll re-throw in finishRendering(). - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } - } - } - } - } - } - - var prevInteractions = null; - if (enableSchedulerTracing) { - // We're about to start new traced work. - // Restore pending interactions so cascading work triggered during the render phase will be accounted for. - prevInteractions = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - } - - var didFatal = false; - - startWorkLoopTimer(nextUnitOfWork); - - do { - try { - workLoop(isYieldy); - } catch (thrownValue) { - resetContextDependences(); - resetHooks(); - - // Reset in case completion throws. - // This is only used in DEV and when replaying is on. - var mayReplay = void 0; - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - mayReplay = mayReplayFailedUnitOfWork; - mayReplayFailedUnitOfWork = true; - } - - if (nextUnitOfWork === null) { - // This is a fatal error. - didFatal = true; - onUncaughtError(thrownValue); - } else { - if (enableProfilerTimer && nextUnitOfWork.mode & ProfileMode) { - // Record the time spent rendering before an error was thrown. - // This avoids inaccurate Profiler durations in the case of a suspended render. - stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, true); - } - - { - // Reset global debug state - // We assume this is defined in DEV - resetCurrentlyProcessingQueue(); - } - - if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - if (mayReplay) { - var failedUnitOfWork = nextUnitOfWork; - replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy); - } - } - - // TODO: we already know this isn't true in some cases. - // At least this shows a nicer error message until we figure out the cause. - // https://github.com/facebook/react/issues/12449#issuecomment-386727431 - invariant( - nextUnitOfWork !== null, - "Failed to replay rendering after an error. This " + - "is likely caused by a bug in React. Please file an issue " + - "with a reproducing case to help us find it." - ); - - var sourceFiber = nextUnitOfWork; - var returnFiber = sourceFiber.return; - if (returnFiber === null) { - // This is the root. The root could capture its own errors. However, - // we don't know if it errors before or after we pushed the host - // context. This information is needed to avoid a stack mismatch. - // Because we're not sure, treat this as a fatal error. We could track - // which phase it fails in, but doesn't seem worth it. At least - // for now. - didFatal = true; - onUncaughtError(thrownValue); - } else { - throwException( - root, - returnFiber, - sourceFiber, - thrownValue, - nextRenderExpirationTime - ); - nextUnitOfWork = completeUnitOfWork(sourceFiber); - continue; - } - } - } - break; - } while (true); - - if (enableSchedulerTracing) { - // Traced work is done for now; restore the previous interactions. - tracing.__interactionsRef.current = prevInteractions; - } - - // We're done performing work. Time to clean up. - isWorking = false; - ReactCurrentDispatcher.current = previousDispatcher; - resetContextDependences(); - resetHooks(); - - // Yield back to main thread. - if (didFatal) { - var _didCompleteRoot = false; - stopWorkLoopTimer(interruptedBy, _didCompleteRoot); - interruptedBy = null; - // There was a fatal error. - { - resetStackAfterFatalErrorInDev(); - } - // `nextRoot` points to the in-progress root. A non-null value indicates - // that we're in the middle of an async render. Set it to null to indicate - // there's no more work to be done in the current batch. - nextRoot = null; - onFatal(root); - return; - } - - if (nextUnitOfWork !== null) { - // There's still remaining async work in this tree, but we ran out of time - // in the current frame. Yield back to the renderer. Unless we're - // interrupted by a higher priority update, we'll continue later from where - // we left off. - var _didCompleteRoot2 = false; - stopWorkLoopTimer(interruptedBy, _didCompleteRoot2); - interruptedBy = null; - onYield(root); - return; - } - - // We completed the whole tree. - var didCompleteRoot = true; - stopWorkLoopTimer(interruptedBy, didCompleteRoot); - var rootWorkInProgress = root.current.alternate; - invariant( - rootWorkInProgress !== null, - "Finished root should have a work-in-progress. This error is likely " + - "caused by a bug in React. Please file an issue." - ); - - // `nextRoot` points to the in-progress root. A non-null value indicates - // that we're in the middle of an async render. Set it to null to indicate - // there's no more work to be done in the current batch. - nextRoot = null; - interruptedBy = null; - - if (nextRenderDidError) { - // There was an error - if (hasLowerPriorityWork(root, expirationTime)) { - // There's lower priority work. If so, it may have the effect of fixing - // the exception that was just thrown. Exit without committing. This is - // similar to a suspend, but without a timeout because we're not waiting - // for a promise to resolve. React will restart at the lower - // priority level. - markSuspendedPriorityLevel(root, expirationTime); - var suspendedExpirationTime = expirationTime; - var rootExpirationTime = root.expirationTime; - onSuspend( - root, - rootWorkInProgress, - suspendedExpirationTime, - rootExpirationTime, - -1 // Indicates no timeout - ); - return; - } else if ( - // There's no lower priority work, but we're rendering asynchronously. - // Synchronously attempt to render the same level one more time. This is - // similar to a suspend, but without a timeout because we're not waiting - // for a promise to resolve. - !root.didError && - isYieldy - ) { - root.didError = true; - var _suspendedExpirationTime = (root.nextExpirationTimeToWorkOn = expirationTime); - var _rootExpirationTime = (root.expirationTime = Sync); - onSuspend( - root, - rootWorkInProgress, - _suspendedExpirationTime, - _rootExpirationTime, - -1 // Indicates no timeout - ); - return; - } - } - - if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { - // The tree was suspended. - var _suspendedExpirationTime2 = expirationTime; - markSuspendedPriorityLevel(root, _suspendedExpirationTime2); - - // Find the earliest uncommitted expiration time in the tree, including - // work that is suspended. The timeout threshold cannot be longer than - // the overall expiration. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - expirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime); - if (earliestExpirationTimeMs < nextLatestAbsoluteTimeoutMs) { - nextLatestAbsoluteTimeoutMs = earliestExpirationTimeMs; - } - - // Subtract the current time from the absolute timeout to get the number - // of milliseconds until the timeout. In other words, convert an absolute - // timestamp to a relative time. This is the value that is passed - // to `setTimeout`. - var currentTimeMs = expirationTimeToMs(requestCurrentTime()); - var msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs; - msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout; - - // TODO: Account for the Just Noticeable Difference - - var _rootExpirationTime2 = root.expirationTime; - onSuspend( - root, - rootWorkInProgress, - _suspendedExpirationTime2, - _rootExpirationTime2, - msUntilTimeout - ); - return; - } - - // Ready to commit. - onComplete(root, rootWorkInProgress, expirationTime); -} - -function captureCommitPhaseError(sourceFiber, value) { - var expirationTime = Sync; - var fiber = sourceFiber.return; - while (fiber !== null) { - switch (fiber.tag) { - case ClassComponent: - var ctor = fiber.type; - var instance = fiber.stateNode; - if ( - typeof ctor.getDerivedStateFromError === "function" || - (typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance)) - ) { - var errorInfo = createCapturedValue(value, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, expirationTime); - enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); - return; - } - break; - case HostRoot: { - var _errorInfo = createCapturedValue(value, sourceFiber); - var _update = createRootErrorUpdate(fiber, _errorInfo, expirationTime); - enqueueUpdate(fiber, _update); - scheduleWork(fiber, expirationTime); - return; - } - } - fiber = fiber.return; - } - - if (sourceFiber.tag === HostRoot) { - // Error was thrown at the root. There is no parent, so the root - // itself should capture it. - var rootFiber = sourceFiber; - var _errorInfo2 = createCapturedValue(value, rootFiber); - var _update2 = createRootErrorUpdate( - rootFiber, - _errorInfo2, - expirationTime - ); - enqueueUpdate(rootFiber, _update2); - scheduleWork(rootFiber, expirationTime); - } -} - -function computeThreadID(expirationTime, interactionThreadID) { - // Interaction threads are unique per root and expiration time. - return expirationTime * 1000 + interactionThreadID; + // This is the first update since React yielded. Compute a new start time. + currentEventTime = msToExpirationTime(now()); + return currentEventTime; } function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(); - - var expirationTime = void 0; if ((fiber.mode & ConcurrentMode) === NoContext) { - // Outside of concurrent mode, updates are always synchronous. - expirationTime = Sync; - } else if (isWorking && !isCommitting$1) { - // During render phase, updates expire during as the current render. - expirationTime = nextRenderExpirationTime; - } else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = Sync; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = computeInteractiveExpiration(currentTime); - break; - case scheduler.unstable_NormalPriority: - // This is a normal, concurrent update - expirationTime = computeAsyncExpiration(currentTime); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = Never; - break; - default: - invariant( - false, - "Unknown priority level. This error is likely caused by a bug in " + - "React. Please file an issue." - ); - } - - // If we're in the middle of rendering a tree, do not update at the same - // expiration time that is already rendering. - if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { - expirationTime -= 1; - } + return Sync; } - // Keep track of the lowest pending interactive expiration time. This - // allows us to synchronously flush all interactive updates - // when needed. - // TODO: Move this to renderer? - if ( - priorityLevel === scheduler.unstable_UserBlockingPriority && - (lowestPriorityPendingInteractiveExpirationTime === NoWork || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) - ) { - lowestPriorityPendingInteractiveExpirationTime = expirationTime; + if (workPhase === RenderPhase) { + // Use whatever time we're already rendering + return renderExpirationTime; + } + + // Compute an expiration time based on the Scheduler priority. + var expirationTime = void 0; + var priorityLevel = getCurrentPriorityLevel(); + switch (priorityLevel) { + case ImmediatePriority: + expirationTime = Sync; + break; + case UserBlockingPriority: + // TODO: Rename this to computeUserBlockingExpiration + expirationTime = computeInteractiveExpiration(currentTime); + break; + case NormalPriority: + case LowPriority: + // TODO: Handle LowPriority + // TODO: Rename this to... something better. + expirationTime = computeAsyncExpiration(currentTime); + break; + case IdlePriority: + expirationTime = Never; + break; + default: + (function() { + { + throw ReactError("Expected a valid priority level"); + } + })(); + } + + // If we're in the middle of rendering a tree, do not update at the same + // expiration time that is already rendering. + if (workInProgressRoot !== null && expirationTime === renderExpirationTime) { + // This is a trick to move this update into a separate batch + expirationTime -= 1; } return expirationTime; } -function renderDidSuspend(root, absoluteTimeoutMs, suspendedTime) { - // Schedule the timeout. - if ( - absoluteTimeoutMs >= 0 && - nextLatestAbsoluteTimeoutMs < absoluteTimeoutMs - ) { - nextLatestAbsoluteTimeoutMs = absoluteTimeoutMs; - } -} +function scheduleUpdateOnFiber(fiber, expirationTime) { + checkForNestedUpdates(); + warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber); -function renderDidError() { - nextRenderDidError = true; -} - -function pingSuspendedRoot(root, thenable, pingTime) { - // A promise that previously suspended React from committing has resolved. - // If React is still suspended, try again at the previous level (pingTime). - - var pingCache = root.pingCache; - if (pingCache !== null) { - // The thenable resolved, so we no longer need to memoize, because it will - // never be thrown again. - pingCache.delete(thenable); + var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (root === null) { + warnAboutUpdateOnUnmountedFiberInDEV(fiber); + return; } - if (nextRoot !== null && nextRenderExpirationTime === pingTime) { - // Received a ping at the same priority level at which we're currently - // rendering. Restart from the root. - nextRoot = null; - } else { - // Confirm that the root is still suspended at this level. Otherwise exit. - if (isPriorityLevelSuspended(root, pingTime)) { - // Ping at the original level - markPingedPriorityLevel(root, pingTime); - var rootExpirationTime = root.expirationTime; - if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); - } - } - } -} + root.pingTime = NoWork; -function retryTimedOutBoundary(boundaryFiber) { - var currentTime = requestCurrentTime(); - var retryTime = computeExpirationForFiber(currentTime, boundaryFiber); - var root = scheduleWorkToRoot(boundaryFiber, retryTime); - if (root !== null) { - markPendingPriorityLevel(root, retryTime); - var rootExpirationTime = root.expirationTime; - if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); - } - } -} - -function resolveRetryThenable(boundaryFiber, thenable) { - // The boundary fiber (a Suspense component) previously timed out and was - // rendered in its fallback state. One of the promises that suspended it has - // resolved, which means at least part of the tree was likely unblocked. Try - var retryCache = void 0; - if (enableSuspenseServerRenderer) { - switch (boundaryFiber.tag) { - case SuspenseComponent: - retryCache = boundaryFiber.stateNode; - break; - case DehydratedSuspenseComponent: - retryCache = boundaryFiber.memoizedState; - break; - default: - invariant( - false, - "Pinged unknown suspense boundary type. " + - "This is probably a bug in React." - ); - } - } else { - retryCache = boundaryFiber.stateNode; - } - if (retryCache !== null) { - // The thenable resolved, so we no longer need to memoize, because it will - // never be thrown again. - retryCache.delete(thenable); - } - - retryTimedOutBoundary(boundaryFiber); -} - -function scheduleWorkToRoot(fiber, expirationTime) { + checkForInterruption(fiber, expirationTime); recordScheduleUpdate(); - { - if (fiber.tag === ClassComponent) { - var instance = fiber.stateNode; - warnAboutInvalidUpdates(instance); + if (expirationTime === Sync) { + if (workPhase === LegacyUnbatchedPhase) { + // This is a legacy edge case. The initial mount of a ReactDOM.render-ed + // root inside of batchedUpdates should be synchronous, but layout updates + // should be deferred until the end of the batch. + var callback = renderRoot(root, Sync, true); + while (callback !== null) { + callback = callback(true); + } + } else { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + if (workPhase === NotWorking) { + // Flush the synchronous work now, wnless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initated + // updates, to preserve historical behavior of sync mode. + flushImmediateQueue(); + } } + } else { + // TODO: computeExpirationForFiber also reads the priority. Pass the + // priority as an argument to that function and this one. + var priorityLevel = getCurrentPriorityLevel(); + if (priorityLevel === UserBlockingPriority) { + // This is the result of a discrete event. Track the lowest priority + // discrete update per root so we can flush them early, if needed. + if (rootsWithPendingDiscreteUpdates === null) { + rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); + } else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); + if ( + lastDiscreteTime === undefined || + lastDiscreteTime > expirationTime + ) { + rootsWithPendingDiscreteUpdates.set(root, expirationTime); + } + } + } + scheduleCallbackForRoot(root, priorityLevel, expirationTime); } +} +var scheduleWork = scheduleUpdateOnFiber; +// This is split into a separate function so we can mark a fiber with pending +// work without treating it as a typical update that originates from an event; +// e.g. retrying a Suspense boundary isn't an update, but it does schedule work +// on a fiber. +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { // Update the source fiber's expiration time if (fiber.expirationTime < expirationTime) { fiber.expirationTime = expirationTime; @@ -17869,56 +17140,1576 @@ function scheduleWorkToRoot(fiber, expirationTime) { } } - if (enableSchedulerTracing) { - if (root !== null) { - var interactions = tracing.__interactionsRef.current; - if (interactions.size > 0) { - var pendingInteractionMap = root.pendingInteractionMap; - var pendingInteractions = pendingInteractionMap.get(expirationTime); - if (pendingInteractions != null) { - interactions.forEach(function(interaction) { - if (!pendingInteractions.has(interaction)) { - // Update the pending async work count for previously unscheduled interaction. - interaction.__count++; - } - - pendingInteractions.add(interaction); - }); - } else { - pendingInteractionMap.set(expirationTime, new Set(interactions)); - - // Update the pending async work count for the current interactions. - interactions.forEach(function(interaction) { - interaction.__count++; - }); - } - - var subscriber = tracing.__subscriberRef.current; - if (subscriber !== null) { - var threadID = computeThreadID( - expirationTime, - root.interactionThreadID - ); - subscriber.onWorkScheduled(interactions, threadID); - } - } + if (root !== null) { + // Update the first and last pending expiration times in this root + var firstPendingTime = root.firstPendingTime; + if (expirationTime > firstPendingTime) { + root.firstPendingTime = expirationTime; + } + var lastPendingTime = root.lastPendingTime; + if (lastPendingTime === NoWork || expirationTime < lastPendingTime) { + root.lastPendingTime = expirationTime; } } + return root; } -function warnIfNotCurrentlyBatchingInDev(fiber) { +// Use this function, along with runRootCallback, to ensure that only a single +// callback per root is scheduled. It's still possible to call renderRoot +// directly, but scheduling via this function helps avoid excessive callbacks. +// It works by storing the callback node and expiration time on the root. When a +// new callback comes in, it compares the expiration time to determine if it +// should cancel the previous one. It also relies on commitRoot scheduling a +// callback to render the next level, because that means we don't need a +// separate callback per expiration time. +function scheduleCallbackForRoot(root, priorityLevel, expirationTime) { + var existingCallbackExpirationTime = root.callbackExpirationTime; + if (existingCallbackExpirationTime < expirationTime) { + // New callback has higher priority than the existing one. + var existingCallbackNode = root.callbackNode; + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + root.callbackExpirationTime = expirationTime; + + var options = null; + if (expirationTime !== Sync && expirationTime !== Never) { + var timeout = expirationTimeToMs(expirationTime) - now(); + if (timeout > 5000) { + // Sanity check. Should never take longer than 5 seconds. + // TODO: Add internal warning? + timeout = 5000; + } + options = { timeout: timeout }; + } + + root.callbackNode = scheduleCallback( + priorityLevel, + runRootCallback.bind( + null, + root, + renderRoot.bind(null, root, expirationTime) + ), + options + ); + if ( + enableUserTimingAPI && + expirationTime !== Sync && + workPhase !== RenderPhase && + workPhase !== CommitPhase + ) { + // Scheduled an async callback, and we're not already working. Add an + // entry to the flamegraph that shows we're waiting for a callback + // to fire. + startRequestCallbackTimer(); + } + } + + // Add the current set of interactions to the pending set associated with + // this root. + schedulePendingInteraction(root, expirationTime); +} + +function runRootCallback(root, callback, isSync) { + var prevCallbackNode = root.callbackNode; + var continuation = null; + try { + continuation = callback(isSync); + if (continuation !== null) { + return runRootCallback.bind(null, root, continuation); + } else { + return null; + } + } finally { + // If the callback exits without returning a continuation, remove the + // corresponding callback node from the root. Unless the callback node + // has changed, which implies that it was already cancelled by a high + // priority update. + if (continuation === null && prevCallbackNode === root.callbackNode) { + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + } + } +} + +function flushInteractiveUpdates$1() { + if (workPhase === RenderPhase || workPhase === CommitPhase) { + // Can't synchronously flush interactive updates if React is already + // working. This is currently a no-op. + // TODO: Should we fire a warning? This happens if you synchronously invoke + // an input event inside an effect, like with `element.click()`. + return; + } + flushPendingDiscreteUpdates(); +} + +function resolveLocksOnRoot(root, expirationTime) { + var firstBatch = root.firstBatch; + if ( + firstBatch !== null && + firstBatch._defer && + firstBatch._expirationTime >= expirationTime + ) { + root.finishedWork = root.current.alternate; + root.pendingCommitExpirationTime = expirationTime; + scheduleCallback(NormalPriority, function() { + firstBatch._onComplete(); + return null; + }); + return true; + } else { + return false; + } +} + +function interactiveUpdates$1(fn, a, b, c) { + if (workPhase === NotWorking) { + // TODO: Remove this call. Instead of doing this automatically, the caller + // should explicitly call flushInteractiveUpdates. + flushPendingDiscreteUpdates(); + } + return runWithPriority(UserBlockingPriority, fn.bind(null, a, b, c)); +} + +function flushPendingDiscreteUpdates() { + if (rootsWithPendingDiscreteUpdates !== null) { + // For each root with pending discrete updates, schedule a callback to + // immediately flush them. + var roots = rootsWithPendingDiscreteUpdates; + rootsWithPendingDiscreteUpdates = null; + roots.forEach(function(expirationTime, root) { + scheduleCallback( + ImmediatePriority, + renderRoot.bind(null, root, expirationTime) + ); + }); + // Now flush the immediate queue. + flushImmediateQueue(); + } +} + +function batchedUpdates$1(fn, a) { + if (workPhase !== NotWorking) { + // We're already working, or inside a batch, so batchedUpdates is a no-op. + return fn(a); + } + workPhase = BatchedPhase; + try { + return fn(a); + } finally { + workPhase = NotWorking; + // Flush the immediate callbacks that were scheduled during this batch + flushImmediateQueue(); + } +} + +function prepareFreshStack(root, expirationTime) { + root.pendingCommitExpirationTime = NoWork; + + var timeoutHandle = root.timeoutHandle; + if (timeoutHandle !== noTimeout) { + // The root previous suspended and scheduled a timeout to commit a fallback + // state. Now that we have additional work, cancel the timeout. + root.timeoutHandle = noTimeout; + // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above + cancelTimeout(timeoutHandle); + } + + if (workInProgress !== null) { + var interruptedWork = workInProgress.return; + while (interruptedWork !== null) { + unwindInterruptedWork(interruptedWork); + interruptedWork = interruptedWork.return; + } + } + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null, expirationTime); + renderExpirationTime = expirationTime; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootMostRecentEventTime = Sync; + { - if (isRendering === false && isBatchingUpdates === false) { + ReactStrictModeWarnings.discardPendingWarnings(); + } +} + +function renderRoot(root, expirationTime, isSync) { + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Should not already be working."); + } + })(); + + if (enableUserTimingAPI && expirationTime !== Sync) { + var didExpire = isSync; + stopRequestCallbackTimer(didExpire); + } + + if (root.firstPendingTime < expirationTime) { + // If there's no work left at this expiration time, exit immediately. This + // happens when multiple callbacks are scheduled for a single root, but an + // earlier callback flushes the work of a later one. + return null; + } + + if (root.pendingCommitExpirationTime === expirationTime) { + // There's already a pending commit at this expiration time. + root.pendingCommitExpirationTime = NoWork; + return commitRoot.bind(null, root, expirationTime); + } + + flushPassiveEffects(); + + // If the root or expiration time have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteraction(root, expirationTime); + } + + // If we have a work-in-progress fiber, it means there's still work to do + // in this root. + if (workInProgress !== null) { + var prevWorkPhase = workPhase; + workPhase = RenderPhase; + var prevDispatcher = ReactCurrentDispatcher.current; + if (prevDispatcher === null) { + // The React isomorphic package does not include a default dispatcher. + // Instead the first renderer will lazily attach one, in order to give + // nicer error messages. + prevDispatcher = ContextOnlyDispatcher; + } + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + startWorkLoopTimer(workInProgress); + + // TODO: Fork renderRoot into renderRootSync and renderRootAsync + if (isSync) { + if (expirationTime !== Sync) { + // An async update expired. There may be other expired updates on + // this root. We should render all the expired work in a + // single batch. + var currentTime = requestCurrentTime(); + if (currentTime < expirationTime) { + // Restart at the current time. + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher.current = prevDispatcher; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + return renderRoot.bind(null, root, currentTime); + } + } + } else { + // Since we know we're in a React event, we can clear the current + // event time. The next update will compute a new event time. + currentEventTime = NoWork; + } + + do { + try { + if (isSync) { + workLoopSync(); + } else { + workLoop(); + } + break; + } catch (thrownValue) { + // Reset module-level state that was set during the render phase. + resetContextDependences(); + resetHooks(); + + var sourceFiber = workInProgress; + if (sourceFiber === null || sourceFiber.return === null) { + // Expected to be working on a non-root fiber. This is a fatal error + // because there's no ancestor that can handle it; the root is + // supposed to capture all errors that weren't caught by an error + // boundary. + prepareFreshStack(root, expirationTime); + workPhase = prevWorkPhase; + throw thrownValue; + } + + if (enableProfilerTimer && sourceFiber.mode & ProfileMode) { + // Record the time spent rendering before an error was thrown. This + // avoids inaccurate Profiler durations in the case of a + // suspended render. + stopProfilerTimerIfRunningAndRecordDelta(sourceFiber, true); + } + + var returnFiber = sourceFiber.return; + throwException( + root, + returnFiber, + sourceFiber, + thrownValue, + renderExpirationTime + ); + workInProgress = completeUnitOfWork(sourceFiber); + } + } while (true); + + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher.current = prevDispatcher; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + + if (workInProgress !== null) { + // There's still work left over. Return a continuation. + stopInterruptedWorkLoopTimer(); + if (expirationTime !== Sync) { + startRequestCallbackTimer(); + } + return renderRoot.bind(null, root, expirationTime); + } + } + + // We now have a consistent tree. The next step is either to commit it, or, if + // something suspended, wait to commit it after a timeout. + stopFinishedWorkLoopTimer(); + + var isLocked = resolveLocksOnRoot(root, expirationTime); + if (isLocked) { + // This root has a lock that prevents it from committing. Exit. If we begin + // work on the root again, without any intervening updates, it will finish + // without doing additional work. + return null; + } + + // Set this to null to indicate there's no in-progress render. + workInProgressRoot = null; + + switch (workInProgressRootExitStatus) { + case RootIncomplete: { + (function() { + { + throw ReactError("Should have a work-in-progress."); + } + })(); + } + // Flow knows about invariant, so it compains if I add a break statement, + // but eslint doesn't know about invariant, so it complains if I do. + // eslint-disable-next-line no-fallthrough + case RootErrored: { + // An error was thrown. First check if there is lower priority work + // scheduled on this root. + var lastPendingTime = root.lastPendingTime; + if (root.lastPendingTime < expirationTime) { + // There's lower priority work. Before raising the error, try rendering + // at the lower priority to see if it fixes it. Use a continuation to + // maintain the existing priority and position in the queue. + return renderRoot.bind(null, root, lastPendingTime); + } + if (!isSync) { + // If we're rendering asynchronously, it's possible the error was + // caused by tearing due to a mutation during an event. Try rendering + // one more time without yiedling to events. + prepareFreshStack(root, expirationTime); + scheduleCallback( + ImmediatePriority, + renderRoot.bind(null, root, expirationTime) + ); + return null; + } + // If we're already rendering synchronously, commit the root in its + // errored state. + return commitRoot.bind(null, root, expirationTime); + } + case RootSuspended: { + if (!isSync) { + var _lastPendingTime = root.lastPendingTime; + if (root.lastPendingTime < expirationTime) { + // There's lower priority work. It might be unsuspended. Try rendering + // at that level. + return renderRoot.bind(null, root, _lastPendingTime); + } + // If workInProgressRootMostRecentEventTime is Sync, that means we didn't + // track any event times. That can happen if we retried but nothing switched + // from fallback to content. There's no reason to delay doing no work. + if (workInProgressRootMostRecentEventTime !== Sync) { + var msUntilTimeout = computeMsUntilTimeout( + workInProgressRootMostRecentEventTime, + expirationTime + ); + // Don't bother with a very short suspense time. + if (msUntilTimeout > 10) { + // The render is suspended, it hasn't timed out, and there's no lower + // priority work to do. Instead of committing the fallback + // immediately, wait for more data to arrive. + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root, expirationTime), + msUntilTimeout + ); + return null; + } + } + } + // The work expired. Commit immediately. + return commitRoot.bind(null, root, expirationTime); + } + case RootCompleted: { + // The work completed. Ready to commit. + return commitRoot.bind(null, root, expirationTime); + } + default: { + (function() { + { + throw ReactError("Unknown root exit status."); + } + })(); + } + } +} + +function markRenderEventTime(expirationTime) { + if (expirationTime < workInProgressRootMostRecentEventTime) { + workInProgressRootMostRecentEventTime = expirationTime; + } +} + +function renderDidSuspend() { + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootSuspended; + } +} + +function renderDidError() { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) { + workInProgressRootExitStatus = RootErrored; + } +} + +function inferTimeFromExpirationTime(expirationTime) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; +} + +function workLoopSync() { + // Already timed out, so perform work without checking if we need to yield. + while (workInProgress !== null) { + workInProgress = performUnitOfWork(workInProgress); + } +} + +function workLoop() { + // Perform work until Scheduler asks us to yield + while (workInProgress !== null && !shouldYield()) { + workInProgress = performUnitOfWork(workInProgress); + } +} + +function performUnitOfWork(unitOfWork) { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current$$1 = unitOfWork.alternate; + + startWorkTimer(unitOfWork); + setCurrentFiber(unitOfWork); + + var next = void 0; + if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoContext) { + startProfilerTimer(unitOfWork); + next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime); + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); + } else { + next = beginWork$$1(current$$1, unitOfWork, renderExpirationTime); + } + + resetCurrentFiber(); + unitOfWork.memoizedProps = unitOfWork.pendingProps; + if (next === null) { + // If this doesn't spawn new work, complete the current work. + next = completeUnitOfWork(unitOfWork); + } + + ReactCurrentOwner$2.current = null; + return next; +} + +function completeUnitOfWork(unitOfWork) { + // Attempt to complete the current unit of work, then move to the next + // sibling. If there are no more siblings, return to the parent fiber. + workInProgress = unitOfWork; + do { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current$$1 = workInProgress.alternate; + var returnFiber = workInProgress.return; + + // Check if the work completed or if something threw. + if ((workInProgress.effectTag & Incomplete) === NoEffect) { + setCurrentFiber(workInProgress); + var next = void 0; + if ( + !enableProfilerTimer || + (workInProgress.mode & ProfileMode) === NoContext + ) { + next = completeWork(current$$1, workInProgress, renderExpirationTime); + } else { + startProfilerTimer(workInProgress); + next = completeWork(current$$1, workInProgress, renderExpirationTime); + // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + } + stopWorkTimer(workInProgress); + resetCurrentFiber(); + resetChildExpirationTime(workInProgress); + + if (next !== null) { + // Completing this fiber spawned new work. Work on that next. + return next; + } + + if ( + returnFiber !== null && + // Do not append effects to parents if a sibling failed to complete + (returnFiber.effectTag & Incomplete) === NoEffect + ) { + // Append all the effects of the subtree and this fiber onto the effect + // list of the parent. The completion order of the children affects the + // side-effect order. + if (returnFiber.firstEffect === null) { + returnFiber.firstEffect = workInProgress.firstEffect; + } + if (workInProgress.lastEffect !== null) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; + } + returnFiber.lastEffect = workInProgress.lastEffect; + } + + // If this fiber had side-effects, we append it AFTER the children's + // side-effects. We can perform certain side-effects earlier if needed, + // by doing multiple passes over the effect list. We don't want to + // schedule our own side-effect on our own list because if end up + // reusing children we'll schedule this effect onto itself since we're + // at the end. + var effectTag = workInProgress.effectTag; + + // Skip both NoWork and PerformedWork tags when creating the effect + // list. PerformedWork effect is read by React DevTools but shouldn't be + // committed. + if (effectTag > PerformedWork) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = workInProgress; + } else { + returnFiber.firstEffect = workInProgress; + } + returnFiber.lastEffect = workInProgress; + } + } + } else { + // This fiber did not complete because something threw. Pop values off + // the stack without entering the complete phase. If this is a boundary, + // capture values if possible. + var _next = unwindWork(workInProgress, renderExpirationTime); + + // Because this fiber did not complete, don't reset its expiration time. + + if ( + enableProfilerTimer && + (workInProgress.mode & ProfileMode) !== NoContext + ) { + // Record the render duration for the fiber that errored. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + + // Include the time spent working on failed children before continuing. + var actualDuration = workInProgress.actualDuration; + var child = workInProgress.child; + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + workInProgress.actualDuration = actualDuration; + } + + if (_next !== null) { + // If completing this work spawned new work, do that next. We'll come + // back here again. + // Since we're restarting, remove anything that is not a host effect + // from the effect tag. + // TODO: The name stopFailedWorkTimer is misleading because Suspense + // also captures and restarts. + stopFailedWorkTimer(workInProgress); + _next.effectTag &= HostEffectMask; + return _next; + } + stopWorkTimer(workInProgress); + + if (returnFiber !== null) { + // Mark the parent fiber as incomplete and clear its effect list. + returnFiber.firstEffect = returnFiber.lastEffect = null; + returnFiber.effectTag |= Incomplete; + } + } + + var siblingFiber = workInProgress.sibling; + if (siblingFiber !== null) { + // If there is more work to do in this returnFiber, do that next. + return siblingFiber; + } + // Otherwise, return to the parent + workInProgress = returnFiber; + } while (workInProgress !== null); + + // We've reached the root. + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootCompleted; + } + return null; +} + +function resetChildExpirationTime(completedWork) { + if ( + renderExpirationTime !== Never && + completedWork.childExpirationTime === Never + ) { + // The children of this component are hidden. Don't bubble their + // expiration times. + return; + } + + var newChildExpirationTime = NoWork; + + // Bubble up the earliest expiration time. + if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoContext) { + // In profiling mode, resetChildExpirationTime is also used to reset + // profiler durations. + var actualDuration = completedWork.actualDuration; + var treeBaseDuration = completedWork.selfBaseDuration; + + // When a fiber is cloned, its actualDuration is reset to 0. This value will + // only be updated if work is done on the fiber (i.e. it doesn't bailout). + // When work is done, it should bubble to the parent's actualDuration. If + // the fiber has not been cloned though, (meaning no work was done), then + // this value will reflect the amount of time spent working on a previous + // render. In that case it should not bubble. We determine whether it was + // cloned by comparing the child pointer. + var shouldBubbleActualDurations = + completedWork.alternate === null || + completedWork.child !== completedWork.alternate.child; + + var child = completedWork.child; + while (child !== null) { + var childUpdateExpirationTime = child.expirationTime; + var childChildExpirationTime = child.childExpirationTime; + if (childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childUpdateExpirationTime; + } + if (childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childChildExpirationTime; + } + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + completedWork.actualDuration = actualDuration; + completedWork.treeBaseDuration = treeBaseDuration; + } else { + var _child = completedWork.child; + while (_child !== null) { + var _childUpdateExpirationTime = _child.expirationTime; + var _childChildExpirationTime = _child.childExpirationTime; + if (_childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childUpdateExpirationTime; + } + if (_childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childChildExpirationTime; + } + _child = _child.sibling; + } + } + + completedWork.childExpirationTime = newChildExpirationTime; +} + +function commitRoot(root, expirationTime) { + runWithPriority( + ImmediatePriority, + commitRootImpl.bind(null, root, expirationTime) + ); + // If there are passive effects, schedule a callback to flush them. This goes + // outside commitRootImpl so that it inherits the priority of the render. + if (rootWithPendingPassiveEffects !== null) { + var priorityLevel = getCurrentPriorityLevel(); + scheduleCallback(priorityLevel, function() { + flushPassiveEffects(); + return null; + }); + } + return null; +} + +function commitRootImpl(root, expirationTime) { + flushPassiveEffects(); + flushRenderPhaseStrictModeWarningsInDEV(); + + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Should not already be working."); + } + })(); + var finishedWork = root.current.alternate; + (function() { + if (!(finishedWork !== null)) { + throw ReactError("Should have a work-in-progress root."); + } + })(); + + // commitRoot never returns a continuation; it always finishes synchronously. + // So we can clear these now to allow a new callback to be scheduled. + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + + startCommitTimer(); + + // Update the first and last pending times on this root. The new first + // pending time is whatever is left on the root fiber. + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; + var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + var firstPendingTimeBeforeCommit = + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit; + root.firstPendingTime = firstPendingTimeBeforeCommit; + if (firstPendingTimeBeforeCommit < root.lastPendingTime) { + // This usually means we've finished all the work, but it can also happen + // when something gets downprioritized during render, like a hidden tree. + root.lastPendingTime = firstPendingTimeBeforeCommit; + } + + if (root === workInProgressRoot) { + // We can reset these now that they are finished. + workInProgressRoot = null; + workInProgress = null; + renderExpirationTime = NoWork; + } else { + } + // This indicates that the last root we worked on is not the same one that + // we're committing now. This most commonly happens when a suspended root + // times out. + + // Get the list of effects. + var firstEffect = void 0; + if (finishedWork.effectTag > PerformedWork) { + // A fiber's effect list consists only of its children, not itself. So if + // the root has an effect, we need to add it to the end of the list. The + // resulting list is the set that would belong to the root's parent, if it + // had one; that is, all the effects in the tree including the root. + if (finishedWork.lastEffect !== null) { + finishedWork.lastEffect.nextEffect = finishedWork; + firstEffect = finishedWork.firstEffect; + } else { + firstEffect = finishedWork; + } + } else { + // There is no effect on the root. + firstEffect = finishedWork.firstEffect; + } + + if (firstEffect !== null) { + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + // Reset this to null before calling lifecycles + ReactCurrentOwner$2.current = null; + + // The commit phase is broken into several sub-phases. We do a separate pass + // of the effect list for each phase: all mutation effects come before all + // layout effects, and so on. + + // The first phase a "before mutation" phase. We use this phase to read the + // state of the host tree right before we mutate it. This is where + // getSnapshotBeforeUpdate is called. + startCommitSnapshotEffectsTimer(); + prepareForCommit(root.containerInfo); + nextEffect = firstEffect; + do { + { + invokeGuardedCallback(null, commitBeforeMutationEffects, null); + if (hasCaughtError()) { + (function() { + if (!(nextEffect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var error = clearCaughtError(); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + stopCommitSnapshotEffectsTimer(); + + if (enableProfilerTimer) { + // Mark the current commit time to be shared by all Profilers in this + // batch. This enables them to be grouped later. + recordCommitTime(); + } + + // The next phase is the mutation phase, where we mutate the host tree. + startCommitHostEffectsTimer(); + nextEffect = firstEffect; + do { + { + invokeGuardedCallback(null, commitMutationEffects, null); + if (hasCaughtError()) { + (function() { + if (!(nextEffect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var _error = clearCaughtError(); + captureCommitPhaseError(nextEffect, _error); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + stopCommitHostEffectsTimer(); + resetAfterCommit(root.containerInfo); + + // The work-in-progress tree is now the current tree. This must come after + // the mutation phase, so that the previous tree is still current during + // componentWillUnmount, but before the layout phase, so that the finished + // work is current during componentDidMount/Update. + root.current = finishedWork; + + // The next phase is the layout phase, where we call effects that read + // the host tree after it's been mutated. The idiomatic use case for this is + // layout, but class component lifecycles also fire here for legacy reasons. + startCommitLifeCyclesTimer(); + nextEffect = firstEffect; + do { + { + invokeGuardedCallback( + null, + commitLayoutEffects, + null, + root, + expirationTime + ); + if (hasCaughtError()) { + (function() { + if (!(nextEffect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var _error2 = clearCaughtError(); + captureCommitPhaseError(nextEffect, _error2); + nextEffect = nextEffect.nextEffect; + } + } + } while (nextEffect !== null); + stopCommitLifeCyclesTimer(); + + nextEffect = null; + + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + workPhase = prevWorkPhase; + } else { + // No effects. + root.current = finishedWork; + // Measure these anyway so the flamegraph explicitly shows that there were + // no effects. + // TODO: Maybe there's a better way to report this. + startCommitSnapshotEffectsTimer(); + stopCommitSnapshotEffectsTimer(); + if (enableProfilerTimer) { + recordCommitTime(); + } + startCommitHostEffectsTimer(); + stopCommitHostEffectsTimer(); + startCommitLifeCyclesTimer(); + stopCommitLifeCyclesTimer(); + } + + stopCommitTimer(); + + if (rootDoesHavePassiveEffects) { + // This commit has passive effects. Stash a reference to them. But don't + // schedule a callback until after flushing layout work. + rootDoesHavePassiveEffects = false; + rootWithPendingPassiveEffects = root; + pendingPassiveEffectsExpirationTime = expirationTime; + } else { + if (enableSchedulerTracing) { + // If there are no passive effects, then we can complete the pending + // interactions. Otherwise, we'll wait until after the passive effects + // are flushed. + finishPendingInteractions(root, expirationTime); + } + } + + // Check if there's remaining work on this root + var remainingExpirationTime = root.firstPendingTime; + if (remainingExpirationTime !== NoWork) { + var currentTime = requestCurrentTime(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + remainingExpirationTime + ); + scheduleCallbackForRoot(root, priorityLevel, remainingExpirationTime); + } else { + // If there's no remaining work, we can clear the set of already failed + // error boundaries. + legacyErrorBoundariesThatAlreadyFailed = null; + } + + onCommitRoot(finishedWork.stateNode); + + if (remainingExpirationTime === Sync) { + // Count the number of times the root synchronously re-renders without + // finishing. If there are too many, it indicates an infinite update loop. + if (root === rootWithNestedUpdates) { + nestedUpdateCount++; + } else { + nestedUpdateCount = 0; + rootWithNestedUpdates = root; + } + } else { + nestedUpdateCount = 0; + } + + if (hasUncaughtError) { + hasUncaughtError = false; + var _error3 = firstUncaughtError; + firstUncaughtError = null; + throw _error3; + } + + if (workPhase === LegacyUnbatchedPhase) { + // This is a legacy edge case. We just committed the initial mount of + // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired + // synchronously, but layout updates should be deferred until the end + // of the batch. + return null; + } + + // If layout work was scheduled, flush it now. + flushImmediateQueue(); + return null; +} + +function commitBeforeMutationEffects() { + while (nextEffect !== null) { + if ((nextEffect.effectTag & Snapshot) !== NoEffect) { + setCurrentFiber(nextEffect); + recordEffect(); + + var current$$1 = nextEffect.alternate; + commitBeforeMutationLifeCycles(current$$1, nextEffect); + + resetCurrentFiber(); + } + nextEffect = nextEffect.nextEffect; + } +} + +function commitMutationEffects() { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + + var effectTag = nextEffect.effectTag; + + if (effectTag & ContentReset) { + commitResetTextContent(nextEffect); + } + + if (effectTag & Ref) { + var current$$1 = nextEffect.alternate; + if (current$$1 !== null) { + commitDetachRef(current$$1); + } + } + + // The following switch statement is only concerned about placement, + // updates, and deletions. To avoid needing to add a case for every possible + // bitmap value, we remove the secondary effects from the effect tag and + // switch on that value. + var primaryEffectTag = effectTag & (Placement | Update | Deletion); + switch (primaryEffectTag) { + case Placement: { + commitPlacement(nextEffect); + // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + // TODO: findDOMNode doesn't rely on this any more but isMounted does + // and isMounted is deprecated anyway so we should be able to kill this. + nextEffect.effectTag &= ~Placement; + break; + } + case PlacementAndUpdate: { + // Placement + commitPlacement(nextEffect); + // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + nextEffect.effectTag &= ~Placement; + + // Update + var _current = nextEffect.alternate; + commitWork(_current, nextEffect); + break; + } + case Update: { + var _current2 = nextEffect.alternate; + commitWork(_current2, nextEffect); + break; + } + case Deletion: { + commitDeletion(nextEffect); + break; + } + } + + // TODO: Only record a mutation effect if primaryEffectTag is non-zero. + recordEffect(); + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} + +function commitLayoutEffects(root, committedExpirationTime) { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect !== null) { + setCurrentFiber(nextEffect); + + var effectTag = nextEffect.effectTag; + + if (effectTag & (Update | Callback)) { + recordEffect(); + var current$$1 = nextEffect.alternate; + commitLifeCycles(root, current$$1, nextEffect, committedExpirationTime); + } + + if (effectTag & Ref) { + recordEffect(); + commitAttachRef(nextEffect); + } + + if (effectTag & Passive) { + rootDoesHavePassiveEffects = true; + } + + resetCurrentFiber(); + nextEffect = nextEffect.nextEffect; + } +} + +function flushPassiveEffects() { + if (rootWithPendingPassiveEffects === null) { + return false; + } + var root = rootWithPendingPassiveEffects; + var expirationTime = pendingPassiveEffectsExpirationTime; + rootWithPendingPassiveEffects = null; + pendingPassiveEffectsExpirationTime = NoWork; + + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Cannot flush passive effects while already rendering."); + } + })(); + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + + // Note: This currently assumes there are no passive effects on the root + // fiber, because the root is not part of its own effect list. This could + // change in the future. + var effect = root.current.firstEffect; + while (effect !== null) { + { + setCurrentFiber(effect); + invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + if (hasCaughtError()) { + (function() { + if (!(effect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var error = clearCaughtError(); + captureCommitPhaseError(effect, error); + } + resetCurrentFiber(); + } + effect = effect.nextEffect; + } + + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + finishPendingInteractions(root, expirationTime); + } + + workPhase = prevWorkPhase; + flushImmediateQueue(); + + // If additional passive effects were scheduled, increment a counter. If this + // exceeds the limit, we'll fire a warning. + nestedPassiveUpdateCount = + rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1; + + return true; +} + +function isAlreadyFailedLegacyErrorBoundary(instance) { + return ( + legacyErrorBoundariesThatAlreadyFailed !== null && + legacyErrorBoundariesThatAlreadyFailed.has(instance) + ); +} + +function markLegacyErrorBoundaryAsFailed(instance) { + if (legacyErrorBoundariesThatAlreadyFailed === null) { + legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); + } else { + legacyErrorBoundariesThatAlreadyFailed.add(instance); + } +} + +function prepareToThrowUncaughtError(error) { + if (!hasUncaughtError) { + hasUncaughtError = true; + firstUncaughtError = error; + } +} +var onUncaughtError = prepareToThrowUncaughtError; + +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); + enqueueUpdate(rootFiber, update); + var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); + if (root !== null) { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + } +} + +function captureCommitPhaseError(sourceFiber, error) { + if (sourceFiber.tag === HostRoot) { + // Error was thrown at the root. There is no parent, so the root + // itself should capture it. + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + return; + } + + var fiber = sourceFiber.return; + while (fiber !== null) { + if (fiber.tag === HostRoot) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + return; + } else if (fiber.tag === ClassComponent) { + var ctor = fiber.type; + var instance = fiber.stateNode; + if ( + typeof ctor.getDerivedStateFromError === "function" || + (typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance)) + ) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createClassErrorUpdate( + fiber, + errorInfo, + // TODO: This is always sync + Sync + ); + enqueueUpdate(fiber, update); + var root = markUpdateTimeFromFiberToRoot(fiber, Sync); + if (root !== null) { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + } + return; + } + } + fiber = fiber.return; + } +} + +function pingSuspendedRoot(root, thenable, suspendedTime) { + var pingCache = root.pingCache; + if (pingCache !== null) { + // The thenable resolved, so we no longer need to memoize, because it will + // never be thrown again. + pingCache.delete(thenable); + } + + if (workInProgressRoot === root && renderExpirationTime === suspendedTime) { + // Received a ping at the same priority level at which we're currently + // rendering. Restart from the root. Don't need to schedule a ping because + // we're already working on this tree. + prepareFreshStack(root, renderExpirationTime); + return; + } + + var lastPendingTime = root.lastPendingTime; + if (lastPendingTime < suspendedTime) { + // The root is no longer suspended at this time. + return; + } + + var pingTime = root.pingTime; + if (pingTime !== NoWork && pingTime < suspendedTime) { + // There's already a lower priority ping scheduled. + return; + } + + // Mark the time at which this ping was scheduled. + root.pingTime = suspendedTime; + + var currentTime = requestCurrentTime(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + suspendedTime + ); + scheduleCallbackForRoot(root, priorityLevel, suspendedTime); +} + +function retryTimedOutBoundary(boundaryFiber) { + // The boundary fiber (a Suspense component) previously timed out and was + // rendered in its fallback state. One of the promises that suspended it has + // resolved, which means at least part of the tree was likely unblocked. Try + // rendering again, at a new expiration time. + var currentTime = requestCurrentTime(); + var retryTime = computeExpirationForFiber(currentTime, boundaryFiber); + // TODO: Special case idle priority? + var priorityLevel = inferPriorityFromExpirationTime(currentTime, retryTime); + var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); + if (root !== null) { + scheduleCallbackForRoot(root, priorityLevel, retryTime); + } +} + +function resolveRetryThenable(boundaryFiber, thenable) { + var retryCache = void 0; + if (enableSuspenseServerRenderer) { + switch (boundaryFiber.tag) { + case SuspenseComponent: + retryCache = boundaryFiber.stateNode; + break; + case DehydratedSuspenseComponent: + retryCache = boundaryFiber.memoizedState; + break; + default: + (function() { + { + throw ReactError( + "Pinged unknown suspense boundary type. This is probably a bug in React." + ); + } + })(); + } + } else { + retryCache = boundaryFiber.stateNode; + } + + if (retryCache !== null) { + // The thenable resolved, so we no longer need to memoize, because it will + // never be thrown again. + retryCache.delete(thenable); + } + + retryTimedOutBoundary(boundaryFiber); +} + +// Computes the next Just Noticeable Difference (JND) boundary. +// The theory is that a person can't tell the difference between small differences in time. +// Therefore, if we wait a bit longer than necessary that won't translate to a noticeable +// difference in the experience. However, waiting for longer might mean that we can avoid +// showing an intermediate loading state. The longer we have already waited, the harder it +// is to tell small differences in time. Therefore, the longer we've already waited, +// the longer we can wait additionally. At some point we have to give up though. +// We pick a train model where the next boundary commits at a consistent schedule. +// These particular numbers are vague estimates. We expect to adjust them based on research. +function jnd(timeElapsed) { + return timeElapsed < 120 + ? 120 + : timeElapsed < 480 + ? 480 + : timeElapsed < 1080 + ? 1080 + : timeElapsed < 1920 + ? 1920 + : timeElapsed < 3000 + ? 3000 + : timeElapsed < 4320 + ? 4320 + : ceil(timeElapsed / 1960) * 1960; +} + +function computeMsUntilTimeout(mostRecentEventTime, committedExpirationTime) { + if (disableYielding) { + // Timeout immediately when yielding is disabled. + return 0; + } + + var eventTimeMs = inferTimeFromExpirationTime(mostRecentEventTime); + var currentTimeMs = now(); + var timeElapsed = currentTimeMs - eventTimeMs; + + var msUntilTimeout = jnd(timeElapsed) - timeElapsed; + + // Compute the time until this render pass would expire. + var timeUntilExpirationMs = + expirationTimeToMs(committedExpirationTime) - currentTimeMs; + + // Clamp the timeout to the expiration time. + // TODO: Once the event time is exact instead of inferred from expiration time + // we don't need this. + if (timeUntilExpirationMs < msUntilTimeout) { + msUntilTimeout = timeUntilExpirationMs; + } + + // This is the value that is passed to `setTimeout`. + return msUntilTimeout; +} + +function checkForNestedUpdates() { + if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { + nestedUpdateCount = 0; + rootWithNestedUpdates = null; + (function() { + { + throw ReactError( + "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." + ); + } + })(); + } + + { + if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) { + nestedPassiveUpdateCount = 0; + warning$1( + false, + "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." + ); + } + } +} + +function flushRenderPhaseStrictModeWarningsInDEV() { + { + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + ReactStrictModeWarnings.flushLegacyContextWarning(); + + if (warnAboutDeprecatedLifecycles) { + ReactStrictModeWarnings.flushPendingDeprecationWarnings(); + } + } +} + +function stopFinishedWorkLoopTimer() { + var didCompleteRoot = true; + stopWorkLoopTimer(interruptedBy, didCompleteRoot); + interruptedBy = null; +} + +function stopInterruptedWorkLoopTimer() { + // TODO: Track which fiber caused the interruption. + var didCompleteRoot = false; + stopWorkLoopTimer(interruptedBy, didCompleteRoot); + interruptedBy = null; +} + +function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { + if ( + enableUserTimingAPI && + workInProgressRoot !== null && + updateExpirationTime > renderExpirationTime + ) { + interruptedBy = fiberThatReceivedUpdate; + } +} + +var didWarnStateUpdateForUnmountedComponent = null; +function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { + { + var tag = fiber.tag; + if ( + tag !== HostRoot && + tag !== ClassComponent && + tag !== FunctionComponent && + tag !== ForwardRef && + tag !== MemoComponent && + tag !== SimpleMemoComponent + ) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } + // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. + var componentName = getComponentName(fiber.type) || "ReactComponent"; + if (didWarnStateUpdateForUnmountedComponent !== null) { + if (didWarnStateUpdateForUnmountedComponent.has(componentName)) { + return; + } + didWarnStateUpdateForUnmountedComponent.add(componentName); + } else { + didWarnStateUpdateForUnmountedComponent = new Set([componentName]); + } + warningWithoutStack$1( + false, + "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.%s", + tag === ClassComponent + ? "the componentWillUnmount method" + : "a useEffect cleanup function", + getStackByFiberInDevAndProd(fiber) + ); + } +} + +var beginWork$$1 = void 0; +if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + var dummyFiber = null; + beginWork$$1 = function(current$$1, unitOfWork, expirationTime) { + // If a component throws an error, we replay it again in a synchronously + // dispatched event, so that the debugger will treat it as an uncaught + // error See ReactErrorUtils for more information. + + // Before entering the begin phase, copy the work-in-progress onto a dummy + // fiber. If beginWork throws, we'll use this to reset the state. + var originalWorkInProgressCopy = assignFiberPropertiesInDEV( + dummyFiber, + unitOfWork + ); + try { + return beginWork$1(current$$1, unitOfWork, expirationTime); + } catch (originalError) { + if ( + originalError !== null && + typeof originalError === "object" && + typeof originalError.then === "function" + ) { + // Don't replay promises. Treat everything else like an error. + throw originalError; + } + + // Keep this code in sync with renderRoot; any changes here must have + // corresponding changes there. + resetContextDependences(); + resetHooks(); + + // Unwind the failed stack frame + unwindInterruptedWork(unitOfWork); + + // Restore the original properties of the fiber. + assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); + + if (enableProfilerTimer && unitOfWork.mode & ProfileMode) { + // Reset the profiler timer. + startProfilerTimer(unitOfWork); + } + + // Run beginWork again. + invokeGuardedCallback( + null, + beginWork$1, + null, + current$$1, + unitOfWork, + expirationTime + ); + + if (hasCaughtError()) { + var replayError = clearCaughtError(); + // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. + // Rethrow this error instead of the original one. + throw replayError; + } else { + // This branch is reachable if the render phase is impure. + throw originalError; + } + } + }; +} else { + beginWork$$1 = beginWork$1; +} + +var didWarnAboutUpdateInRender = false; +var didWarnAboutUpdateInGetChildContext = false; +function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { + { + if (fiber.tag === ClassComponent) { + switch (phase) { + case "getChildContext": + if (didWarnAboutUpdateInGetChildContext) { + return; + } + warningWithoutStack$1( + false, + "setState(...): Cannot call setState() inside getChildContext()" + ); + didWarnAboutUpdateInGetChildContext = true; + break; + case "render": + if (didWarnAboutUpdateInRender) { + return; + } + warningWithoutStack$1( + false, + "Cannot update during an existing state transition (such as " + + "within `render`). Render methods should be a pure function of " + + "props and state." + ); + didWarnAboutUpdateInRender = true; + break; + } + } + } +} + +function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { + { + if ( + workPhase === NotWorking && + ReactShouldWarnActingUpdates.current === false + ) { warningWithoutStack$1( false, "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" + + "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." + + "This ensures that you're testing the behavior the user would see " + + "in the browser." + " Learn more at https://fb.me/react-wrap-tests-with-act" + "%s", getComponentName(fiber.type), @@ -17928,652 +18719,157 @@ function warnIfNotCurrentlyBatchingInDev(fiber) { } } -function scheduleWork(fiber, expirationTime) { - var root = scheduleWorkToRoot(fiber, expirationTime); - if (root === null) { - { - switch (fiber.tag) { - case ClassComponent: - warnAboutUpdateOnUnmounted(fiber, true); - break; - case FunctionComponent: - case ForwardRef: - case MemoComponent: - case SimpleMemoComponent: - warnAboutUpdateOnUnmounted(fiber, false); - break; - } - } +var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; + +function computeThreadID(root, expirationTime) { + // Interaction threads are unique per root and expiration time. + return expirationTime * 1000 + root.interactionThreadID; +} + +function schedulePendingInteraction(root, expirationTime) { + // This is called when work is scheduled on a root. It sets up a pending + // interaction, which is completed once the work commits. + if (!enableSchedulerTracing) { return; } - if ( - !isWorking && - nextRenderExpirationTime !== NoWork && - expirationTime > nextRenderExpirationTime - ) { - // This is an interruption. (Used for performance tracking.) - interruptedBy = fiber; - resetStack(); - } - markPendingPriorityLevel(root, expirationTime); - if ( - // If we're in the render phase, we don't need to schedule this root - // for an update, because we'll do it before we exit... - !isWorking || - isCommitting$1 || - // ...unless this is a different root than the one we're rendering. - nextRoot !== root - ) { - var rootExpirationTime = root.expirationTime; - requestWork(root, rootExpirationTime); - } - if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { - // Reset this back to zero so subsequent updates don't throw. - nestedUpdateCount = 0; - invariant( - false, - "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." - ); - } -} + var interactions = tracing.__interactionsRef.current; + if (interactions.size > 0) { + var pendingInteractionMap = root.pendingInteractionMap; + var pendingInteractions = pendingInteractionMap.get(expirationTime); + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (!pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } -// TODO: Everything below this is written as if it has been lifted to the -// renderers. I'll do this in a follow-up. - -// Linked-list of roots -var firstScheduledRoot = null; -var lastScheduledRoot = null; - -var callbackExpirationTime = NoWork; -var callbackID = void 0; -var isRendering = false; -var nextFlushedRoot = null; -var nextFlushedExpirationTime = NoWork; -var lowestPriorityPendingInteractiveExpirationTime = NoWork; -var hasUnhandledError = false; -var unhandledError = null; - -var isBatchingUpdates = false; -var isUnbatchingUpdates = false; - -var completedBatches = null; - -var originalStartTimeMs = now$$1(); -var currentRendererTime = msToExpirationTime(originalStartTimeMs); -var currentSchedulerTime = currentRendererTime; - -// Use these to prevent an infinite loop of nested updates -var NESTED_UPDATE_LIMIT = 50; -var nestedUpdateCount = 0; -var lastCommittedRootDuringThisBatch = null; - -function recomputeCurrentRendererTime() { - var currentTimeMs = now$$1() - originalStartTimeMs; - currentRendererTime = msToExpirationTime(currentTimeMs); -} - -function scheduleCallbackWithExpirationTime(root, expirationTime) { - if (callbackExpirationTime !== NoWork) { - // A callback is already scheduled. Check its expiration time (timeout). - if (expirationTime < callbackExpirationTime) { - // Existing callback has sufficient timeout. Exit. - return; + pendingInteractions.add(interaction); + }); } else { - if (callbackID !== null) { - // Existing callback has insufficient timeout. Cancel and schedule a - // new one. - cancelDeferredCallback$$1(callbackID); - } + pendingInteractionMap.set(expirationTime, new Set(interactions)); + + // Update the pending async work count for the current interactions. + interactions.forEach(function(interaction) { + interaction.__count++; + }); } - // The request callback timer is already running. Don't start a new one. - } else { - startRequestCallbackTimer(); + + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID(root, expirationTime); + subscriber.onWorkScheduled(interactions, threadID); + } + } +} + +function startWorkOnPendingInteraction(root, expirationTime) { + // This is called when new work is started on a root. + if (!enableSchedulerTracing) { + return; } - callbackExpirationTime = expirationTime; - var currentMs = now$$1() - originalStartTimeMs; - var expirationTimeMs = expirationTimeToMs(expirationTime); - var timeout = expirationTimeMs - currentMs; - callbackID = scheduleDeferredCallback$$1(performAsyncWork, { - timeout: timeout + // Determine which interactions this batch of work currently includes, So that + // we can accurately attribute time spent working on it, And so that cascading + // work triggered during the render phase will be associated with it. + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if (scheduledExpirationTime >= expirationTime) { + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + } }); -} -// For every call to renderRoot, one of onFatal, onComplete, onSuspend, and -// onYield is called upon exiting. We use these in lieu of returning a tuple. -// I've also chosen not to inline them into renderRoot because these will -// eventually be lifted into the renderer. -function onFatal(root) { - root.finishedWork = null; -} + // Store the current set of interactions on the FiberRoot for a few reasons: + // We can re-use it in hot functions like renderRoot() without having to + // recalculate it. We will also use it in commitWork() to pass to any Profiler + // onRender() hooks. This also provides DevTools with a way to access it when + // the onCommitRoot() hook is called. + root.memoizedInteractions = interactions; -function onComplete(root, finishedWork, expirationTime) { - root.pendingCommitExpirationTime = expirationTime; - root.finishedWork = finishedWork; -} - -function onSuspend( - root, - finishedWork, - suspendedExpirationTime, - rootExpirationTime, - msUntilTimeout -) { - root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYield$$1()) { - // Don't wait an additional tick. Commit the tree immediately. - root.pendingCommitExpirationTime = suspendedExpirationTime; - root.finishedWork = finishedWork; - } else if (msUntilTimeout > 0) { - // Wait `msUntilTimeout` milliseconds before committing. - root.timeoutHandle = scheduleTimeout( - onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), - msUntilTimeout - ); - } -} - -function onYield(root) { - root.finishedWork = null; -} - -function onTimeout(root, finishedWork, suspendedExpirationTime) { - // The root timed out. Commit it. - root.pendingCommitExpirationTime = suspendedExpirationTime; - root.finishedWork = finishedWork; - // Read the current time before entering the commit phase. We can be - // certain this won't cause tearing related to batching of event updates - // because we're at the top of a timer event. - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - flushRoot(root, suspendedExpirationTime); -} - -function onCommit(root, expirationTime) { - root.expirationTime = expirationTime; - root.finishedWork = null; -} - -function requestCurrentTime() { - // requestCurrentTime is called by the scheduler to compute an expiration - // time. - // - // Expiration times are computed by adding to the current time (the start - // time). However, if two updates are scheduled within the same event, we - // should treat their start times as simultaneous, even if the actual clock - // time has advanced between the first and second call. - - // In other words, because expiration times determine how updates are batched, - // we want all updates of like priority that occur within the same event to - // receive the same expiration time. Otherwise we get tearing. - // - // We keep track of two separate times: the current "renderer" time and the - // current "scheduler" time. The renderer time can be updated whenever; it - // only exists to minimize the calls performance.now. - // - // But the scheduler time can only be updated if there's no pending work, or - // if we know for certain that we're not in the middle of an event. - - if (isRendering) { - // We're already rendering. Return the most recently read time. - return currentSchedulerTime; - } - // Check if there's pending work. - findHighestPriorityRoot(); - if ( - nextFlushedExpirationTime === NoWork || - nextFlushedExpirationTime === Never - ) { - // If there's no pending work, or if the pending work is offscreen, we can - // read the current time without risk of tearing. - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - return currentSchedulerTime; - } - // There's already pending work. We might be in the middle of a browser - // event. If we were to read the current time, it could cause multiple updates - // within the same event to receive different expiration times, leading to - // tearing. Return the last read time. During the next idle callback, the - // time will be updated. - return currentSchedulerTime; -} - -// requestWork is called by the scheduler whenever a root receives an update. -// It's up to the renderer to call renderRoot at some point in the future. -function requestWork(root, expirationTime) { - addRootToSchedule(root, expirationTime); - if (isRendering) { - // Prevent reentrancy. Remaining work will be scheduled at the end of - // the currently rendering batch. - return; - } - - if (isBatchingUpdates) { - // Flush work at the end of the batch. - if (isUnbatchingUpdates) { - // ...unless we're inside unbatchedUpdates, in which case we should - // flush it now. - nextFlushedRoot = root; - nextFlushedExpirationTime = Sync; - performWorkOnRoot(root, Sync, false); - } - return; - } - - // TODO: Get rid of Sync and use current time? - if (expirationTime === Sync) { - performSyncWork(); - } else { - scheduleCallbackWithExpirationTime(root, expirationTime); - } -} - -function addRootToSchedule(root, expirationTime) { - // Add the root to the schedule. - // Check if this root is already part of the schedule. - if (root.nextScheduledRoot === null) { - // This root is not already scheduled. Add it. - root.expirationTime = expirationTime; - if (lastScheduledRoot === null) { - firstScheduledRoot = lastScheduledRoot = root; - root.nextScheduledRoot = root; - } else { - lastScheduledRoot.nextScheduledRoot = root; - lastScheduledRoot = root; - lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; - } - } else { - // This root is already scheduled, but its priority may have increased. - var remainingExpirationTime = root.expirationTime; - if (expirationTime > remainingExpirationTime) { - // Update the priority. - root.expirationTime = expirationTime; - } - } -} - -function findHighestPriorityRoot() { - var highestPriorityWork = NoWork; - var highestPriorityRoot = null; - if (lastScheduledRoot !== null) { - var previousScheduledRoot = lastScheduledRoot; - var root = firstScheduledRoot; - while (root !== null) { - var remainingExpirationTime = root.expirationTime; - if (remainingExpirationTime === NoWork) { - // This root no longer has work. Remove it from the scheduler. - - // TODO: This check is redudant, but Flow is confused by the branch - // below where we set lastScheduledRoot to null, even though we break - // from the loop right after. - invariant( - previousScheduledRoot !== null && lastScheduledRoot !== null, - "Should have a previous and last root. This error is likely " + - "caused by a bug in React. Please file an issue." - ); - if (root === root.nextScheduledRoot) { - // This is the only root in the list. - root.nextScheduledRoot = null; - firstScheduledRoot = lastScheduledRoot = null; - break; - } else if (root === firstScheduledRoot) { - // This is the first root in the list. - var next = root.nextScheduledRoot; - firstScheduledRoot = next; - lastScheduledRoot.nextScheduledRoot = next; - root.nextScheduledRoot = null; - } else if (root === lastScheduledRoot) { - // This is the last root in the list. - lastScheduledRoot = previousScheduledRoot; - lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; - root.nextScheduledRoot = null; - break; - } else { - previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot; - root.nextScheduledRoot = null; - } - root = previousScheduledRoot.nextScheduledRoot; - } else { - if (remainingExpirationTime > highestPriorityWork) { - // Update the priority, if it's higher - highestPriorityWork = remainingExpirationTime; - highestPriorityRoot = root; - } - if (root === lastScheduledRoot) { - break; - } - if (highestPriorityWork === Sync) { - // Sync is highest priority by definition so - // we can stop searching. - break; - } - previousScheduledRoot = root; - root = root.nextScheduledRoot; - } - } - } - - nextFlushedRoot = highestPriorityRoot; - nextFlushedExpirationTime = highestPriorityWork; -} - -function performAsyncWork(didTimeout) { - if (didTimeout) { - // The callback timed out. That means at least one update has expired. - // Iterate through the root schedule. If they contain expired work, set - // the next render expiration time to the current time. This has the effect - // of flushing all expired work in a single batch, instead of flushing each - // level one at a time. - if (firstScheduledRoot !== null) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - didExpireAtExpirationTime(root, currentRendererTime); - // The root schedule is circular, so this is never null. - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); - } - } - performWork(NoWork, true); -} - -function performSyncWork() { - performWork(Sync, false); -} - -function performWork(minExpirationTime, isYieldy) { - // Keep working on roots until there's no more work, or until there's a higher - // priority event. - findHighestPriorityRoot(); - - if (isYieldy) { - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - - if (enableUserTimingAPI) { - var didExpire = nextFlushedExpirationTime > currentRendererTime; - var timeout = expirationTimeToMs(nextFlushedExpirationTime); - stopRequestCallbackTimer(didExpire, timeout); - } - - while ( - nextFlushedRoot !== null && - nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime && - !(shouldYield$$1() && currentRendererTime > nextFlushedExpirationTime) - ) { - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ); - findHighestPriorityRoot(); - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - } - } else { - while ( - nextFlushedRoot !== null && - nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime - ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); - findHighestPriorityRoot(); - } - } - - // We're done flushing work. Either we ran out of time in this callback, - // or there's no more work left with sufficient priority. - - // If we're inside a callback, set this to false since we just completed it. - if (isYieldy) { - callbackExpirationTime = NoWork; - callbackID = null; - } - // If there's work left over, schedule a new callback. - if (nextFlushedExpirationTime !== NoWork) { - scheduleCallbackWithExpirationTime( - nextFlushedRoot, - nextFlushedExpirationTime - ); - } - - // Clean-up. - finishRendering(); -} - -function flushRoot(root, expirationTime) { - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely " + - "means you attempted to commit from inside a lifecycle method." - ); - // Perform work on root as if the given expiration time is the current time. - // This has the effect of synchronously flushing all work up to and - // including the given time. - nextFlushedRoot = root; - nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, false); - // Flush any sync work that was scheduled by lifecycles - performSyncWork(); -} - -function finishRendering() { - nestedUpdateCount = 0; - lastCommittedRootDuringThisBatch = null; - - if (completedBatches !== null) { - var batches = completedBatches; - completedBatches = null; - for (var i = 0; i < batches.length; i++) { - var batch = batches[i]; + if (interactions.size > 0) { + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID(root, expirationTime); try { - batch._onComplete(); + subscriber.onWorkStarted(interactions, threadID); } catch (error) { - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); } } } - - if (hasUnhandledError) { - var error = unhandledError; - unhandledError = null; - hasUnhandledError = false; - throw error; - } } -function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused " + - "by a bug in React. Please file an issue." - ); - - isRendering = true; - - // Check if this is async work or sync/expired work. - if (!isYieldy) { - // Flush work without yielding. - // TODO: Non-yieldy work does not necessarily imply expired work. A renderer - // may want to perform some work without yielding, but also without - // requiring the root to complete (by triggering placeholders). - - var finishedWork = root.finishedWork; - if (finishedWork !== null) { - // This root is already complete. We can commit it. - completeRoot(root, finishedWork, expirationTime); - } else { - root.finishedWork = null; - // If this root previously suspended, clear its existing timeout, since - // we're about to try rendering again. - var timeoutHandle = root.timeoutHandle; - if (timeoutHandle !== noTimeout) { - root.timeoutHandle = noTimeout; - // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above - cancelTimeout(timeoutHandle); - } - renderRoot(root, isYieldy); - finishedWork = root.finishedWork; - if (finishedWork !== null) { - // We've completed the root. Commit it. - completeRoot(root, finishedWork, expirationTime); - } - } - } else { - // Flush async work. - var _finishedWork = root.finishedWork; - if (_finishedWork !== null) { - // This root is already complete. We can commit it. - completeRoot(root, _finishedWork, expirationTime); - } else { - root.finishedWork = null; - // If this root previously suspended, clear its existing timeout, since - // we're about to try rendering again. - var _timeoutHandle = root.timeoutHandle; - if (_timeoutHandle !== noTimeout) { - root.timeoutHandle = noTimeout; - // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above - cancelTimeout(_timeoutHandle); - } - renderRoot(root, isYieldy); - _finishedWork = root.finishedWork; - if (_finishedWork !== null) { - // We've completed the root. Check the if we should yield one more time - // before committing. - if (!shouldYield$$1()) { - // Still time left. Commit the root. - completeRoot(root, _finishedWork, expirationTime); - } else { - // There's no time left. Mark this root as complete. We'll come - // back and commit it later. - root.finishedWork = _finishedWork; - } - } - } +function finishPendingInteractions(root, committedExpirationTime) { + if (!enableSchedulerTracing) { + return; } - isRendering = false; -} + var earliestRemainingTimeAfterCommit = root.firstPendingTime; -function completeRoot(root, finishedWork, expirationTime) { - // Check if there's a batch that matches this expiration time. - var firstBatch = root.firstBatch; - if (firstBatch !== null && firstBatch._expirationTime >= expirationTime) { - if (completedBatches === null) { - completedBatches = [firstBatch]; - } else { - completedBatches.push(firstBatch); - } - if (firstBatch._defer) { - // This root is blocked from committing by a batch. Unschedule it until - // we receive another update. - root.finishedWork = finishedWork; - root.expirationTime = NoWork; - return; - } - } + var subscriber = void 0; - // Commit the root. - root.finishedWork = null; - - // Check if this is a nested update (a sync update scheduled during the - // commit phase). - if (root === lastCommittedRootDuringThisBatch) { - // If the next root is the same as the previous root, this is a nested - // update. To prevent an infinite loop, increment the nested update count. - nestedUpdateCount++; - } else { - // Reset whenever we switch roots. - lastCommittedRootDuringThisBatch = root; - nestedUpdateCount = 0; - } - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); - } - ); -} - -function onUncaughtError(error) { - invariant( - nextFlushedRoot !== null, - "Should be working on a root. This error is likely caused by a bug in " + - "React. Please file an issue." - ); - // Unschedule this root so we don't work on it again until there's - // another update. - nextFlushedRoot.expirationTime = NoWork; - if (!hasUnhandledError) { - hasUnhandledError = true; - unhandledError = error; - } -} - -// TODO: Batching should be implemented at the renderer level, not inside -// the reconciler. -function batchedUpdates$1(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = true; try { - return fn(a); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - if (!isBatchingUpdates && !isRendering) { - performSyncWork(); + subscriber = tracing.__subscriberRef.current; + if (subscriber !== null && root.memoizedInteractions.size > 0) { + var threadID = computeThreadID(root, committedExpirationTime); + subscriber.onWorkStopped(root.memoizedInteractions, threadID); } - } -} + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); + } finally { + // Clear completed interactions from the pending Map. + // Unless the render was suspended or cascading work was scheduled, + // In which case– leave pending interactions until the subsequent render. + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + // Only decrement the pending interaction count if we're done. + // If there's still work at the current priority, + // That indicates that we are waiting for suspense data. + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { + pendingInteractionMap.delete(scheduledExpirationTime); -function interactiveUpdates$1(fn, a, b) { - // If there are any pending interactive updates, synchronously flush them. - // This needs to happen before we read any handlers, because the effect of - // the previous event may influence which handlers are called during - // this event. - if ( - !isBatchingUpdates && - !isRendering && - lowestPriorityPendingInteractiveExpirationTime !== NoWork - ) { - // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); - lowestPriorityPendingInteractiveExpirationTime = NoWork; - } - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = true; - try { - return scheduler.unstable_runWithPriority( - scheduler.unstable_UserBlockingPriority, - function() { - return fn(a, b); + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); + } + } + }); } - ); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - if (!isBatchingUpdates && !isRendering) { - performSyncWork(); - } + }); } } -function flushInteractiveUpdates$1() { - if ( - !isRendering && - lowestPriorityPendingInteractiveExpirationTime !== NoWork - ) { - // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); - lowestPriorityPendingInteractiveExpirationTime = NoWork; - } -} +// This lets us hook into Fiber to debug what it's doing. +// See https://github.com/facebook/react/pull/8033. +// This is not part of the public API, not even for React DevTools. +// You may only inject a debugTool if you work on React Fiber itself. +var ReactFiberInstrumentation = { + debugTool: null +}; + +var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; // 0 is PROD, 1 is DEV. // Might add PROFILE later. @@ -18680,13 +18976,20 @@ function findHostInstance(component) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } else { - invariant( - false, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - ); + (function() { + { + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } + })(); } } var hostFiber = findCurrentHostFiber(fiber); @@ -18701,13 +19004,20 @@ function findHostInstanceWithWarning(component, methodName) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } else { - invariant( - false, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - ); + (function() { + { + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } + })(); } } var hostFiber = findCurrentHostFiber(fiber); @@ -18784,7 +19094,18 @@ function getPublicRootInstance(container) { } } +var shouldSuspendImpl = function(fiber) { + return false; +}; + +function shouldSuspend(fiber) { + return shouldSuspendImpl(fiber); +} + +var overrideHookState = null; var overrideProps = null; +var scheduleUpdate = null; +var setSuspenseHandler = null; { var copyWithSetImpl = function(obj, path, idx, value) { @@ -18802,6 +19123,33 @@ var overrideProps = null; return copyWithSetImpl(obj, path, 0, value); }; + // Support DevTools editable values for useState and useReducer. + overrideHookState = function(fiber, id, path, value) { + // For now, the "id" of stateful hooks is just the stateful hook index. + // This may change in the future with e.g. nested hooks. + var currentHook = fiber.memoizedState; + while (currentHook !== null && id > 0) { + currentHook = currentHook.next; + id--; + } + if (currentHook !== null) { + flushPassiveEffects(); + + var newState = copyWithSet(currentHook.memoizedState, path, value); + currentHook.memoizedState = newState; + currentHook.baseState = newState; + + // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + + scheduleWork(fiber, Sync); + } + }; + // Support DevTools props for function components, forwardRef, memo, host components, etc. overrideProps = function(fiber, path, value) { flushPassiveEffects(); @@ -18811,6 +19159,15 @@ var overrideProps = null; } scheduleWork(fiber, Sync); }; + + scheduleUpdate = function(fiber) { + flushPassiveEffects(); + scheduleWork(fiber, Sync); + }; + + setSuspenseHandler = function(newShouldSuspendImpl) { + shouldSuspendImpl = newShouldSuspendImpl; + }; } function injectIntoDevTools(devToolsConfig) { @@ -18819,7 +19176,10 @@ function injectIntoDevTools(devToolsConfig) { return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: overrideHookState, overrideProps: overrideProps, + setSuspenseHandler: setSuspenseHandler, + scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { var hostFiber = findCurrentHostFiber(fiber); @@ -18863,7 +19223,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.8.3"; +var ReactVersion = "16.8.6"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -18901,10 +19261,36 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * prop](docs/view.html#onlayout) instead. */ measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + // We can't call FabricUIManager here because it won't be loaded in paper + // at initialization time. See https://github.com/facebook/react/pull/15490 + // for more info. + nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }, /** @@ -18923,10 +19309,36 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * has been completed in native. */ measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + // We can't call FabricUIManager here because it won't be loaded in paper + // at initialization time. See https://github.com/facebook/react/pull/15490 + // for more info. + nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }, /** @@ -18942,12 +19354,56 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + return; + } else { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + + UIManager.measureLayout( + findNodeHandle(this), + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + } }, /** @@ -18957,17 +19413,6 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * Manipulation](docs/direct-manipulation.html)). */ setNativeProps: function(nativeProps) { - { - if (warnAboutDeprecatedSetNativeProps) { - warningWithoutStack$1( - false, - "Warning: Calling ref.setNativeProps(nativeProps) " + - "is deprecated and will be removed in a future release. " + - "Use the setNativeProps export from the react-native package instead." + - "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" - ); - } - } // Class components don't have viewConfig -> validateAttributes. // Nor does it make sense to set native props on a non-native component. // Instead, find the nearest host component and set props on it. @@ -18989,6 +19434,26 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { return; } + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + return; + } + + { + if (warnAboutDeprecatedSetNativeProps) { + warningWithoutStack$1( + false, + "Warning: Calling ref.setNativeProps(nativeProps) " + + "is deprecated and will be removed in a future release. " + + "Use the setNativeProps export from the react-native package instead." + + "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" + ); + } + } + var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; var viewConfig = @@ -19033,13 +19498,18 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { // true without actually implementing them (setting them to undefined // isn't allowed by ReactClass) var NativeMethodsMixin_DEV = NativeMethodsMixin; - invariant( - !NativeMethodsMixin_DEV.componentWillMount && - !NativeMethodsMixin_DEV.componentWillReceiveProps && - !NativeMethodsMixin_DEV.UNSAFE_componentWillMount && - !NativeMethodsMixin_DEV.UNSAFE_componentWillReceiveProps, - "Do not override existing functions." - ); + (function() { + if ( + !( + !NativeMethodsMixin_DEV.componentWillMount && + !NativeMethodsMixin_DEV.componentWillReceiveProps && + !NativeMethodsMixin_DEV.UNSAFE_componentWillMount && + !NativeMethodsMixin_DEV.UNSAFE_componentWillReceiveProps + ) + ) { + throw ReactError("Do not override existing functions."); + } + })(); // TODO (bvaughn) Remove cWM and cWRP in a future version of React Native, // Once these lifecycles have been remove from the reconciler. NativeMethodsMixin_DEV.componentWillMount = function() { @@ -19167,10 +19637,36 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { */ ReactNativeComponent.prototype.measure = function measure(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + // We can't call FabricUIManager here because it won't be loaded in paper + // at initialization time. See https://github.com/facebook/react/pull/15490 + // for more info. + nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }; /** @@ -19190,10 +19686,36 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { ReactNativeComponent.prototype.measureInWindow = function measureInWindow( callback ) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + // We can't call FabricUIManager here because it won't be loaded in paper + // at initialization time. See https://github.com/facebook/react/pull/15490 + // for more info. + nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }; /** @@ -19208,12 +19730,56 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + return; + } else { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + + UIManager.measureLayout( + findNodeHandle(this), + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + } }; /** @@ -19226,18 +19792,6 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { ReactNativeComponent.prototype.setNativeProps = function setNativeProps( nativeProps ) { - { - if (warnAboutDeprecatedSetNativeProps) { - warningWithoutStack$1( - false, - "Warning: Calling ref.setNativeProps(nativeProps) " + - "is deprecated and will be removed in a future release. " + - "Use the setNativeProps export from the react-native package instead." + - "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" - ); - } - } - // Class components don't have viewConfig -> validateAttributes. // Nor does it make sense to set native props on a non-native component. // Instead, find the nearest host component and set props on it. @@ -19259,6 +19813,26 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { return; } + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + return; + } + + { + if (warnAboutDeprecatedSetNativeProps) { + warningWithoutStack$1( + false, + "Warning: Calling ref.setNativeProps(nativeProps) " + + "is deprecated and will be removed in a future release. " + + "Use the setNativeProps export from the react-native package instead." + + "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" + ); + } + } + var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; var viewConfig = diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index ef16155a0..5fbb834c7 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -18,30 +18,93 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), React = require("react"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), - TextInputState = require("TextInputState"); -var scheduler = require("scheduler"), - ExceptionsManager = require("ExceptionsManager"); -function invariant(condition, format, a, b, c, d, e, f) { - if (!condition) { - condition = void 0; - if (void 0 === format) - condition = Error( - "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." - ); - else { - var args = [a, b, c, d, e, f], - argIndex = 0; - condition = Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - condition.name = "Invariant Violation"; - } - condition.framesToPop = 1; - throw condition; - } + TextInputState = require("TextInputState"), + Scheduler = require("scheduler"); +var ExceptionsManager = require("ExceptionsManager"); +function ReactError(message) { + message = Error(message); + message.name = "Invariant Violation"; + return message; } +var eventPluginOrder = null, + namesToPlugins = {}; +function recomputePluginOrdering() { + if (eventPluginOrder) + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName], + pluginIndex = eventPluginOrder.indexOf(pluginName); + if (!(-1 < pluginIndex)) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." + ); + if (!plugins[pluginIndex]) { + if (!pluginModule.extractEvents) + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); + plugins[pluginIndex] = pluginModule; + pluginIndex = pluginModule.eventTypes; + for (var eventName in pluginIndex) { + var JSCompiler_inline_result = void 0; + var dispatchConfig = pluginIndex[eventName], + pluginModule$jscomp$0 = pluginModule, + eventName$jscomp$0 = eventName; + if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName$jscomp$0 + + "`." + ); + eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + if (phasedRegistrationNames) { + for (JSCompiler_inline_result in phasedRegistrationNames) + phasedRegistrationNames.hasOwnProperty( + JSCompiler_inline_result + ) && + publishRegistrationName( + phasedRegistrationNames[JSCompiler_inline_result], + pluginModule$jscomp$0, + eventName$jscomp$0 + ); + JSCompiler_inline_result = !0; + } else + dispatchConfig.registrationName + ? (publishRegistrationName( + dispatchConfig.registrationName, + pluginModule$jscomp$0, + eventName$jscomp$0 + ), + (JSCompiler_inline_result = !0)) + : (JSCompiler_inline_result = !1); + if (!JSCompiler_inline_result) + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); + } + } + } +} +function publishRegistrationName(registrationName, pluginModule) { + if (registrationNameModules[registrationName]) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); + registrationNameModules[registrationName] = pluginModule; +} +var plugins = [], + eventNameDispatchConfigs = {}, + registrationNameModules = {}; function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -83,88 +146,13 @@ function invokeGuardedCallbackAndCatchFirstError( hasError = !1; caughtError = null; } else - invariant( - !1, + throw ReactError( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ), - (error = void 0); + ); hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); } } -var eventPluginOrder = null, - namesToPlugins = {}; -function recomputePluginOrdering() { - if (eventPluginOrder) - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName], - pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - -1 < pluginIndex, - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.", - pluginName - ); - if (!plugins[pluginIndex]) { - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.", - pluginName - ); - plugins[pluginIndex] = pluginModule; - pluginIndex = pluginModule.eventTypes; - for (var eventName in pluginIndex) { - var JSCompiler_inline_result = void 0; - var dispatchConfig = pluginIndex[eventName], - pluginModule$jscomp$0 = pluginModule, - eventName$jscomp$0 = eventName; - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0), - "EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.", - eventName$jscomp$0 - ); - eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - if (phasedRegistrationNames) { - for (JSCompiler_inline_result in phasedRegistrationNames) - phasedRegistrationNames.hasOwnProperty( - JSCompiler_inline_result - ) && - publishRegistrationName( - phasedRegistrationNames[JSCompiler_inline_result], - pluginModule$jscomp$0, - eventName$jscomp$0 - ); - JSCompiler_inline_result = !0; - } else - dispatchConfig.registrationName - ? (publishRegistrationName( - dispatchConfig.registrationName, - pluginModule$jscomp$0, - eventName$jscomp$0 - ), - (JSCompiler_inline_result = !0)) - : (JSCompiler_inline_result = !1); - invariant( - JSCompiler_inline_result, - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); - } - } - } -} -function publishRegistrationName(registrationName, pluginModule) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.", - registrationName - ); - registrationNameModules[registrationName] = pluginModule; -} -var plugins = [], - eventNameDispatchConfigs = {}, - registrationNameModules = {}, - getFiberCurrentPropsFromNode = null, +var getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; function executeDispatch(event, listener, inst) { @@ -176,10 +164,8 @@ function executeDispatch(event, listener, inst) { function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + if (Array.isArray(dispatchListener)) + throw ReactError("executeDirectDispatch(...): Invalid `event`."); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -190,10 +176,10 @@ function executeDirectDispatch(event) { return dispatchListener; } function accumulateInto(current, next) { - invariant( - null != next, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); if (null == current) return next; if (Array.isArray(current)) { if (Array.isArray(next)) return current.push.apply(current, next), current; @@ -227,10 +213,10 @@ function executeDispatchesAndReleaseTopLevel(e) { } var injection = { injectEventPluginOrder: function(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." - ); + if (eventPluginOrder) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); recomputePluginOrdering(); }, @@ -240,15 +226,19 @@ var injection = { for (pluginName in injectedNamesToPlugins) if (injectedNamesToPlugins.hasOwnProperty(pluginName)) { var pluginModule = injectedNamesToPlugins[pluginName]; - (namesToPlugins.hasOwnProperty(pluginName) && - namesToPlugins[pluginName] === pluginModule) || - (invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.", - pluginName - ), - (namesToPlugins[pluginName] = pluginModule), - (isOrderingDirty = !0)); + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + if (namesToPlugins[pluginName]) + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = !0; + } } isOrderingDirty && recomputePluginOrdering(); } @@ -284,12 +274,14 @@ function getListener(inst, registrationName) { inst = !1; } if (inst) return null; - invariant( - !listener || "function" === typeof listener, - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + if (listener && "function" !== typeof listener) + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); return listener; } function getParent(inst) { @@ -450,10 +442,10 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { return new this(dispatchConfig, targetInst, nativeEvent, nativeInst); } function releasePooledEvent(event) { - invariant( - event instanceof this, - "Trying to release an event instance into a pool of a different type." - ); + if (!(event instanceof this)) + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); event.destructor(); 10 > this.eventPool.length && this.eventPool.push(event); } @@ -488,7 +480,7 @@ function timestampForTouch(touch) { } function getTouchIdentifier(_ref) { _ref = _ref.identifier; - invariant(null != _ref, "Touch object is missing identifier."); + if (null == _ref) throw ReactError("Touch object is missing identifier."); return _ref; } function recordTouchStart(touch) { @@ -601,10 +593,10 @@ var ResponderTouchHistoryStore = { touchHistory: touchHistory }; function accumulate(current, next) { - invariant( - null != next, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulate(...): Accumulated items must not be null or undefined." + ); return null == current ? next : Array.isArray(current) @@ -969,11 +961,10 @@ var eventTypes$1 = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + if (!bubbleDispatchConfig && !directDispatchConfig) + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); topLevelType = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -1004,14 +995,10 @@ function getInstanceFromTag(tag) { var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { - if ((target = getInstanceFromNode(target))) { - invariant( - !1, + if (getInstanceFromNode(target)) + throw ReactError( "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." ); - var props = getFiberCurrentPropsFromNode(target.stateNode); - null(target.stateNode, target.type, props); - } } function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); @@ -1059,19 +1046,18 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - if ( - events && - (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ), - hasRethrowError) - ) - throw ((events = rethrowError), - (hasRethrowError = !1), - (rethrowError = null), - events); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasRethrowError) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); + } }); } RCTEventEmitter.register({ @@ -1118,7 +1104,7 @@ getInstanceFromNode = getInstanceFromTag; getNodeFromInstance = function(inst) { var tag = inst.stateNode._nativeTag; void 0 === tag && (tag = inst.stateNode.canonical._nativeTag); - invariant(tag, "All native instances should have a tag."); + if (!tag) throw ReactError("All native instances should have a tag."); return tag; }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ @@ -1146,8 +1132,11 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, - MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; +hasSymbol && Symbol.for("react.event_component"); +hasSymbol && Symbol.for("react.event_target"); +hasSymbol && Symbol.for("react.event_target.touch_hit"); +var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1205,80 +1194,83 @@ function isFiberMountedImpl(fiber) { return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { - invariant( - 2 === isFiberMountedImpl(fiber), - "Unable to find node on an unmounted component." - ); + if (2 !== isFiberMountedImpl(fiber)) + throw ReactError("Unable to find node on an unmounted component."); } function findCurrentFiberUsingSlowPath(fiber) { var alternate = fiber.alternate; - if (!alternate) - return ( - (alternate = isFiberMountedImpl(fiber)), - invariant( - 3 !== alternate, - "Unable to find node on an unmounted component." - ), - 1 === alternate ? null : fiber - ); + if (!alternate) { + alternate = isFiberMountedImpl(fiber); + if (3 === alternate) + throw ReactError("Unable to find node on an unmounted component."); + return 1 === alternate ? null : fiber; + } for (var a = fiber, b = alternate; ; ) { - var parentA = a.return, - parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) break; - if (parentA.child === parentB.child) { - for (var child = parentA.child; child; ) { - if (child === a) return assertIsMounted(parentA), fiber; - if (child === b) return assertIsMounted(parentA), alternate; - child = child.sibling; + var parentA = a.return; + if (null === parentA) break; + var parentB = parentA.alternate; + if (null === parentB) { + b = parentA.return; + if (null !== b) { + a = b; + continue; } - invariant(!1, "Unable to find node on an unmounted component."); + break; + } + if (parentA.child === parentB.child) { + for (parentB = parentA.child; parentB; ) { + if (parentB === a) return assertIsMounted(parentA), fiber; + if (parentB === b) return assertIsMounted(parentA), alternate; + parentB = parentB.sibling; + } + throw ReactError("Unable to find node on an unmounted component."); } if (a.return !== b.return) (a = parentA), (b = parentB); else { - child = !1; - for (var _child = parentA.child; _child; ) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentA; b = parentB; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentA; a = parentB; break; } _child = _child.sibling; } - if (!child) { + if (!didFindChild) { for (_child = parentB.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentB; b = parentA; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentB; a = parentA; break; } _child = _child.sibling; } - invariant( - child, - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." - ); + if (!didFindChild) + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." - ); + if (a.alternate !== b) + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + if (3 !== a.tag) + throw ReactError("Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { @@ -1527,86 +1519,72 @@ function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { }; } var ReactNativeFiberHostComponent = (function() { - function ReactNativeFiberHostComponent(tag, viewConfig) { - if (!(this instanceof ReactNativeFiberHostComponent)) - throw new TypeError("Cannot call a class as a function"); - this._nativeTag = tag; - this._children = []; - this.viewConfig = viewConfig; - } - ReactNativeFiberHostComponent.prototype.blur = function() { - TextInputState.blurTextInput(this._nativeTag); - }; - ReactNativeFiberHostComponent.prototype.focus = function() { - TextInputState.focusTextInput(this._nativeTag); - }; - ReactNativeFiberHostComponent.prototype.measure = function(callback) { - UIManager.measure( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; - ReactNativeFiberHostComponent.prototype.measureInWindow = function( - callback - ) { - UIManager.measureInWindow( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; - ReactNativeFiberHostComponent.prototype.measureLayout = function( - relativeToNativeNode, - onSuccess, - onFail - ) { + function ReactNativeFiberHostComponent(tag, viewConfig) { + if (!(this instanceof ReactNativeFiberHostComponent)) + throw new TypeError("Cannot call a class as a function"); + this._nativeTag = tag; + this._children = []; + this.viewConfig = viewConfig; + } + ReactNativeFiberHostComponent.prototype.blur = function() { + TextInputState.blurTextInput(this._nativeTag); + }; + ReactNativeFiberHostComponent.prototype.focus = function() { + TextInputState.focusTextInput(this._nativeTag); + }; + ReactNativeFiberHostComponent.prototype.measure = function(callback) { + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + ReactNativeFiberHostComponent.prototype.measureInWindow = function(callback) { + UIManager.measureInWindow( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + ReactNativeFiberHostComponent.prototype.measureLayout = function( + relativeToNativeNode, + onSuccess, + onFail + ) { + var relativeNode = void 0; + "number" === typeof relativeToNativeNode + ? (relativeNode = relativeToNativeNode) + : relativeToNativeNode._nativeTag + ? (relativeNode = relativeToNativeNode._nativeTag) + : relativeToNativeNode.canonical && + relativeToNativeNode.canonical._nativeTag && + (relativeNode = relativeToNativeNode.canonical._nativeTag); + null != relativeNode && UIManager.measureLayout( this._nativeTag, - relativeToNativeNode, + relativeNode, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); - }; - ReactNativeFiberHostComponent.prototype.setNativeProps = function( - nativeProps - ) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes + }; + ReactNativeFiberHostComponent.prototype.setNativeProps = function( + nativeProps + ) { + nativeProps = diffProperties( + null, + emptyObject, + nativeProps, + this.viewConfig.validAttributes + ); + null != nativeProps && + UIManager.updateView( + this._nativeTag, + this.viewConfig.uiViewClassName, + nativeProps ); - null != nativeProps && - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps - ); - }; - return ReactNativeFiberHostComponent; - })(), - now$1 = - "object" === typeof performance && "function" === typeof performance.now - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }, - scheduledCallback = null, - frameDeadline = 0; -function setTimeoutCallback() { - frameDeadline = now$1() + 5; - var callback = scheduledCallback; - scheduledCallback = null; - null !== callback && callback(); -} -function scheduleDeferredCallback$1(callback) { - scheduledCallback = callback; - return setTimeout(setTimeoutCallback, 1); -} + }; + return ReactNativeFiberHostComponent; +})(); function shim$1() { - invariant( - !1, + throw ReactError( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } @@ -1637,24 +1615,8 @@ function finalizeInitialChildren(parentInstance) { return !1; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout; -function commitUpdate(instance, updatePayloadTODO, type, oldProps, newProps) { - updatePayloadTODO = instance.viewConfig; - instanceProps[instance._nativeTag] = newProps; - oldProps = diffProperties( - null, - oldProps, - newProps, - updatePayloadTODO.validAttributes - ); - null != oldProps && - UIManager.updateView( - instance._nativeTag, - updatePayloadTODO.uiViewClassName, - oldProps - ); -} -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; + cancelTimeout = clearTimeout, + BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { @@ -1738,10 +1700,10 @@ function popTopLevelContextObject(fiber) { pop(contextStackCursor, fiber); } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." - ); + if (contextStackCursor.current !== emptyContextObject) + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } @@ -1751,12 +1713,13 @@ function processChildContext(fiber, type, parentContext) { if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) - invariant( - contextKey in fiber, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + if (!(contextKey in fiber)) + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { @@ -1775,10 +1738,10 @@ function pushContextProvider(workInProgress) { } function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." - ); + if (!instance) + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); didChange ? ((type = processChildContext(workInProgress, type, previousContext)), (instance.__reactInternalMemoizedMergedChildContext = type), @@ -1812,6 +1775,122 @@ function injectInternals(internals) { } catch (err) {} return !0; } +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, + Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, + Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, + Scheduler_now = Scheduler.unstable_now, + Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel, + Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, + Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, + Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, + Scheduler_LowPriority = Scheduler.unstable_LowPriority, + Scheduler_IdlePriority = Scheduler.unstable_IdlePriority, + fakeCallbackNode = {}, + shouldYield = Scheduler.unstable_shouldYield, + immediateQueue = null, + immediateQueueCallbackNode = null, + isFlushingImmediate = !1, + initialTimeMs = Scheduler_now(), + now = + 1e4 > initialTimeMs + ? Scheduler_now + : function() { + return Scheduler_now() - initialTimeMs; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return 99; + case Scheduler_UserBlockingPriority: + return 98; + case Scheduler_NormalPriority: + return 97; + case Scheduler_LowPriority: + return 96; + case Scheduler_IdlePriority: + return 95; + default: + throw ReactError("Unknown priority level."); + } +} +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case 99: + return Scheduler_ImmediatePriority; + case 98: + return Scheduler_UserBlockingPriority; + case 97: + return Scheduler_NormalPriority; + case 96: + return Scheduler_LowPriority; + case 95: + return Scheduler_IdlePriority; + default: + throw ReactError("Unknown priority level."); + } +} +function runWithPriority(reactPriorityLevel, fn) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(reactPriorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + if (99 === reactPriorityLevel) + return ( + null === immediateQueue + ? ((immediateQueue = [callback]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueueImpl + ))) + : immediateQueue.push(callback), + fakeCallbackNode + ); + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); +} +function flushImmediateQueue() { + null !== immediateQueueCallbackNode && + Scheduler_cancelCallback(immediateQueueCallbackNode); + flushImmediateQueueImpl(); +} +function flushImmediateQueueImpl() { + if (!isFlushingImmediate && null !== immediateQueue) { + isFlushingImmediate = !0; + var i = 0; + try { + for (; i < immediateQueue.length; i++) { + var callback = immediateQueue[i]; + do callback = callback(!0); + while (null !== callback); + } + immediateQueue = null; + } catch (error) { + throw (null !== immediateQueue && + (immediateQueue = immediateQueue.slice(i + 1)), + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueue + ), + error); + } finally { + isFlushingImmediate = !1; + } + } +} +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (1073741823 === expirationTime) return 99; + if (1 === expirationTime) return 95; + currentTime = + 10 * (1073741822 - expirationTime) - 10 * (1073741822 - currentTime); + return 0 >= currentTime + ? 99 + : 250 >= currentTime + ? 98 + : 5250 >= currentTime + ? 97 + : 95; +} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -1935,11 +2014,10 @@ function createFiberFromTypeAndProps( owner = null; break a; } - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (null == type ? type : typeof type) + + "." ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -1981,94 +2059,17 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } -function markPendingPriorityLevel(root, expirationTime) { - root.didError = !1; - var earliestPendingTime = root.earliestPendingTime; - 0 === earliestPendingTime - ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime < expirationTime - ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime > expirationTime && - (root.latestPendingTime = expirationTime); - findNextExpirationTimeToWorkOn(expirationTime, root); -} -function markCommittedPriorityLevels(root, earliestRemainingTime) { - root.didError = !1; - if (0 === earliestRemainingTime) - (root.earliestPendingTime = 0), - (root.latestPendingTime = 0), - (root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0); - else { - earliestRemainingTime < root.latestPingedTime && - (root.latestPingedTime = 0); - var latestPendingTime = root.latestPendingTime; - 0 !== latestPendingTime && - (latestPendingTime > earliestRemainingTime - ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime > earliestRemainingTime && - (root.earliestPendingTime = root.latestPendingTime)); - latestPendingTime = root.earliestSuspendedTime; - 0 === latestPendingTime - ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime < root.latestSuspendedTime - ? ((root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0), - markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime > latestPendingTime && - markPendingPriorityLevel(root, earliestRemainingTime); - } - findNextExpirationTimeToWorkOn(0, root); -} -function markSuspendedPriorityLevel(root, suspendedTime) { - root.didError = !1; - root.latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); - var earliestPendingTime = root.earliestPendingTime, - latestPendingTime = root.latestPendingTime; - earliestPendingTime === suspendedTime - ? (root.earliestPendingTime = - latestPendingTime === suspendedTime - ? (root.latestPendingTime = 0) - : latestPendingTime) - : latestPendingTime === suspendedTime && - (root.latestPendingTime = earliestPendingTime); - earliestPendingTime = root.earliestSuspendedTime; - latestPendingTime = root.latestSuspendedTime; - 0 === earliestPendingTime - ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : earliestPendingTime < suspendedTime - ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime > suspendedTime && - (root.latestSuspendedTime = suspendedTime); - findNextExpirationTimeToWorkOn(suspendedTime, root); -} -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestPendingTime = root.earliestPendingTime; - root = root.earliestSuspendedTime; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); - return renderExpirationTime; -} -function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { - var earliestSuspendedTime = root.earliestSuspendedTime, - latestSuspendedTime = root.latestSuspendedTime, - earliestPendingTime = root.earliestPendingTime, - latestPingedTime = root.latestPingedTime; - earliestPendingTime = - 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; - 0 === earliestPendingTime && - (0 === completedExpirationTime || - latestSuspendedTime < completedExpirationTime) && - (earliestPendingTime = latestSuspendedTime); - completedExpirationTime = earliestPendingTime; - 0 !== completedExpirationTime && - earliestSuspendedTime > completedExpirationTime && - (completedExpirationTime = earliestSuspendedTime); - root.nextExpirationTimeToWorkOn = earliestPendingTime; - root.expirationTime = completedExpirationTime; +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pingCache = this.pendingChildren = null; + this.pendingCommitExpirationTime = 0; + this.finishedWork = null; + this.timeoutHandle = -1; + this.pendingContext = this.context = null; + this.hydrate = hydrate; + this.callbackNode = this.firstBatch = null; + this.pingTime = this.lastPendingTime = this.firstPendingTime = this.callbackExpirationTime = 0; } function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); @@ -2139,6 +2140,285 @@ function readLazyComponentType(lazyComponent) { throw result; } } +var valueCursor = { current: null }, + currentlyRenderingFiber = null, + lastContextDependency = null, + lastContextWithAllBitsObserved = null; +function resetContextDependences() { + lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; +} +function pushProvider(providerFiber, nextValue) { + var context = providerFiber.type._context; + push(valueCursor, context._currentValue, providerFiber); + context._currentValue = nextValue; +} +function popProvider(providerFiber) { + var currentValue = valueCursor.current; + pop(valueCursor, providerFiber); + providerFiber.type._context._currentValue = currentValue; +} +function prepareToReadContext(workInProgress, renderExpirationTime) { + currentlyRenderingFiber = workInProgress; + lastContextWithAllBitsObserved = lastContextDependency = null; + var currentDependencies = workInProgress.contextDependencies; + null !== currentDependencies && + currentDependencies.expirationTime >= renderExpirationTime && + (didReceiveUpdate = !0); + workInProgress.contextDependencies = null; +} +function readContext(context, observedBits) { + if ( + lastContextWithAllBitsObserved !== context && + !1 !== observedBits && + 0 !== observedBits + ) { + if ("number" !== typeof observedBits || 1073741823 === observedBits) + (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); + observedBits = { context: context, observedBits: observedBits, next: null }; + if (null === lastContextDependency) { + if (null === currentlyRenderingFiber) + throw ReactError( + "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()." + ); + lastContextDependency = observedBits; + currentlyRenderingFiber.contextDependencies = { + first: observedBits, + expirationTime: 0 + }; + } else lastContextDependency = lastContextDependency.next = observedBits; + } + return context._currentValue; +} +var hasForceUpdate = !1; +function createUpdateQueue(baseState) { + return { + baseState: baseState, + firstUpdate: null, + lastUpdate: null, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; +} +function cloneUpdateQueue(currentQueue) { + return { + baseState: currentQueue.baseState, + firstUpdate: currentQueue.firstUpdate, + lastUpdate: currentQueue.lastUpdate, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; +} +function createUpdate(expirationTime) { + return { + expirationTime: expirationTime, + tag: 0, + payload: null, + callback: null, + next: null, + nextEffect: null + }; +} +function appendUpdateToQueue(queue, update) { + null === queue.lastUpdate + ? (queue.firstUpdate = queue.lastUpdate = update) + : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); +} +function enqueueUpdate(fiber, update) { + var alternate = fiber.alternate; + if (null === alternate) { + var queue1 = fiber.updateQueue; + var queue2 = null; + null === queue1 && + (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); + } else + (queue1 = fiber.updateQueue), + (queue2 = alternate.updateQueue), + null === queue1 + ? null === queue2 + ? ((queue1 = fiber.updateQueue = createUpdateQueue( + fiber.memoizedState + )), + (queue2 = alternate.updateQueue = createUpdateQueue( + alternate.memoizedState + ))) + : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) + : null === queue2 && + (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); + null === queue2 || queue1 === queue2 + ? appendUpdateToQueue(queue1, update) + : null === queue1.lastUpdate || null === queue2.lastUpdate + ? (appendUpdateToQueue(queue1, update), + appendUpdateToQueue(queue2, update)) + : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); +} +function enqueueCapturedUpdate(workInProgress, update) { + var workInProgressQueue = workInProgress.updateQueue; + workInProgressQueue = + null === workInProgressQueue + ? (workInProgress.updateQueue = createUpdateQueue( + workInProgress.memoizedState + )) + : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); + null === workInProgressQueue.lastCapturedUpdate + ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) + : ((workInProgressQueue.lastCapturedUpdate.next = update), + (workInProgressQueue.lastCapturedUpdate = update)); +} +function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { + var current = workInProgress.alternate; + null !== current && + queue === current.updateQueue && + (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); + return queue; +} +function getStateFromUpdate( + workInProgress, + queue, + update, + prevState, + nextProps, + instance +) { + switch (update.tag) { + case 1: + return ( + (workInProgress = update.payload), + "function" === typeof workInProgress + ? workInProgress.call(instance, prevState, nextProps) + : workInProgress + ); + case 3: + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; + case 0: + workInProgress = update.payload; + nextProps = + "function" === typeof workInProgress + ? workInProgress.call(instance, prevState, nextProps) + : workInProgress; + if (null === nextProps || void 0 === nextProps) break; + return Object.assign({}, prevState, nextProps); + case 2: + hasForceUpdate = !0; + } + return prevState; +} +function processUpdateQueue( + workInProgress, + queue, + props, + instance, + renderExpirationTime +) { + hasForceUpdate = !1; + queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); + for ( + var newBaseState = queue.baseState, + newFirstUpdate = null, + newExpirationTime = 0, + update = queue.firstUpdate, + resultState = newBaseState; + null !== update; + + ) { + var updateExpirationTime = update.expirationTime; + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && + ((newFirstUpdate = update), (newBaseState = resultState)), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : (updateExpirationTime < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = updateExpirationTime), + (resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), + null !== update.callback && + ((workInProgress.effectTag |= 32), + (update.nextEffect = null), + null === queue.lastEffect + ? (queue.firstEffect = queue.lastEffect = update) + : ((queue.lastEffect.nextEffect = update), + (queue.lastEffect = update)))); + update = update.next; + } + updateExpirationTime = null; + for (update = queue.firstCapturedUpdate; null !== update; ) { + var _updateExpirationTime = update.expirationTime; + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && + ((updateExpirationTime = update), + null === newFirstUpdate && (newBaseState = resultState)), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), + null !== update.callback && + ((workInProgress.effectTag |= 32), + (update.nextEffect = null), + null === queue.lastCapturedEffect + ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) + : ((queue.lastCapturedEffect.nextEffect = update), + (queue.lastCapturedEffect = update)))); + update = update.next; + } + null === newFirstUpdate && (queue.lastUpdate = null); + null === updateExpirationTime + ? (queue.lastCapturedUpdate = null) + : (workInProgress.effectTag |= 32); + null === newFirstUpdate && + null === updateExpirationTime && + (newBaseState = resultState); + queue.baseState = newBaseState; + queue.firstUpdate = newFirstUpdate; + queue.firstCapturedUpdate = updateExpirationTime; + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = resultState; +} +function commitUpdateQueue(finishedWork, finishedQueue, instance) { + null !== finishedQueue.firstCapturedUpdate && + (null !== finishedQueue.lastUpdate && + ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), + (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), + (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} +function commitUpdateEffects(effect, instance) { + for (; null !== effect; ) { + var _callback3 = effect.callback; + if (null !== _callback3) { + effect.callback = null; + var context = instance; + if ("function" !== typeof _callback3) + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + _callback3 + ); + _callback3.call(context); + } + effect = effect.nextEffect; + } +} var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, @@ -2173,30 +2453,30 @@ var classComponentUpdater = { void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternalFiber; var currentTime = requestCurrentTime(); currentTime = computeExpirationForFiber(currentTime, inst); var update = createUpdate(currentTime); - update.tag = ReplaceState; + update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternalFiber; var currentTime = requestCurrentTime(); currentTime = computeExpirationForFiber(currentTime, inst); var update = createUpdate(currentTime); - update.tag = ForceUpdate; + update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2321,17 +2601,19 @@ function coerceRef(returnFiber, current$$1, element) { if (element._owner) { element = element._owner; var inst = void 0; - element && - (invariant( - 1 === element.tag, - "Function components cannot have refs. Did you mean to use React.forwardRef()?" - ), - (inst = element.stateNode)); - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.", - returnFiber - ); + if (element) { + if (1 !== element.tag) + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + inst = element.stateNode; + } + if (!inst) + throw ReactError( + "Missing owner for string ref " + + returnFiber + + ". This error is likely caused by a bug in React. Please file an issue." + ); var stringRef = "" + returnFiber; if ( null !== current$$1 && @@ -2348,27 +2630,27 @@ function coerceRef(returnFiber, current$$1, element) { current$$1._stringRef = stringRef; return current$$1; } - invariant( - "string" === typeof returnFiber, - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) 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://fb.me/react-refs-must-have-owner for more information.", - returnFiber - ); + if ("string" !== typeof returnFiber) + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + if (!element._owner) + throw ReactError( + "Element ref was specified as a string (" + + returnFiber + + ") 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://fb.me/react-refs-must-have-owner for more information." + ); } return returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { - "textarea" !== returnFiber.type && - invariant( - !1, - "Objects are not valid as a React child (found: %s).%s", - "[object Object]" === Object.prototype.toString.call(newChild) - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - "" + if ("textarea" !== returnFiber.type) + throw ReactError( + "Objects are not valid as a React child (found: " + + ("[object Object]" === Object.prototype.toString.call(newChild) + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2712,18 +2994,21 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - if ( - (oldFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - )) - ) - (currentFirstChild = placeChild(oldFiber, currentFirstChild, newIdx)), + (oldFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + )), + null !== oldFiber && + ((currentFirstChild = placeChild( + oldFiber, + currentFirstChild, + newIdx + )), null === previousNewFiber ? (resultingFirstChild = oldFiber) : (previousNewFiber.sibling = oldFiber), - (previousNewFiber = oldFiber); + (previousNewFiber = oldFiber)); return resultingFirstChild; } for ( @@ -2731,20 +3016,19 @@ function ChildReconciler(shouldTrackSideEffects) { newIdx < newChildren.length; newIdx++ ) - if ( - (nextOldFiber = updateFromMap( - oldFiber, - returnFiber, - newIdx, - newChildren[newIdx], - expirationTime - )) - ) - shouldTrackSideEffects && - null !== nextOldFiber.alternate && - oldFiber.delete( - null === nextOldFiber.key ? newIdx : nextOldFiber.key - ), + (nextOldFiber = updateFromMap( + oldFiber, + returnFiber, + newIdx, + newChildren[newIdx], + expirationTime + )), + null !== nextOldFiber && + (shouldTrackSideEffects && + null !== nextOldFiber.alternate && + oldFiber.delete( + null === nextOldFiber.key ? newIdx : nextOldFiber.key + ), (currentFirstChild = placeChild( nextOldFiber, currentFirstChild, @@ -2753,7 +3037,7 @@ function ChildReconciler(shouldTrackSideEffects) { null === previousNewFiber ? (resultingFirstChild = nextOldFiber) : (previousNewFiber.sibling = nextOldFiber), - (previousNewFiber = nextOldFiber); + (previousNewFiber = nextOldFiber)); shouldTrackSideEffects && oldFiber.forEach(function(child) { return deleteChild(returnFiber, child); @@ -2767,15 +3051,13 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - "function" === typeof iteratorFn, - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." - ); + if ("function" !== typeof iteratorFn) + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); newChildrenIterable = iteratorFn.call(newChildrenIterable); - invariant( - null != newChildrenIterable, - "An iterable object provided no iterator." - ); + if (null == newChildrenIterable) + throw ReactError("An iterable object provided no iterator."); for ( var previousNewFiber = (iteratorFn = null), oldFiber = currentFirstChild, @@ -2795,7 +3077,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ); if (null === newFiber) { - oldFiber || (oldFiber = nextOldFiber); + null === oldFiber && (oldFiber = nextOldFiber); break; } shouldTrackSideEffects && @@ -2867,7 +3149,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) + if (isUnkeyedTopLevelFragment.key === isObject) { if ( 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE @@ -2892,14 +3174,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -2935,7 +3213,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== currentFirstChild; ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + if (currentFirstChild.key === isUnkeyedTopLevelFragment) { if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -2955,11 +3233,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren(returnFiber, currentFirstChild); - break; } - else deleteChild(returnFiber, currentFirstChild); + deleteRemainingChildren(returnFiber, currentFirstChild); + break; + } else deleteChild(returnFiber, currentFirstChild); currentFirstChild = currentFirstChild.sibling; } currentFirstChild = createFiberFromPortal( @@ -3013,12 +3290,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (returnFiber.tag) { case 1: case 0: - (expirationTime = returnFiber.type), - invariant( - !1, - "%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.", - expirationTime.displayName || expirationTime.name || "Component" - ); + throw ((returnFiber = returnFiber.type), + ReactError( + (returnFiber.displayName || returnFiber.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + )); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3030,10 +3306,10 @@ var reconcileChildFibers = ChildReconciler(!0), contextFiberStackCursor = { current: NO_CONTEXT }, rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." - ); + if (c === NO_CONTEXT) + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); return c; } function pushHostContainer(fiber, nextRootInstance) { @@ -3079,7 +3355,7 @@ var NoEffect$1 = 0, MountPassive = 64, UnmountPassive = 128, ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, - renderExpirationTime = 0, + renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, nextCurrentHook = null, @@ -3093,9 +3369,8 @@ var NoEffect$1 = 0, renderPhaseUpdates = null, numberOfReRenders = 0; function throwInvalidHookError() { - invariant( - !1, - "Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)" + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3112,7 +3387,7 @@ function renderWithHooks( refOrContext, nextRenderExpirationTime ) { - renderExpirationTime = nextRenderExpirationTime; + renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; nextCurrentHook = null !== current ? current.memoizedState : null; ReactCurrentDispatcher$1.current = @@ -3138,20 +3413,20 @@ function renderWithHooks( current.updateQueue = componentUpdateQueue; current.effectTag |= sideEffectTag; current = null !== currentHook && null !== currentHook.next; - renderExpirationTime = 0; + renderExpirationTime$1 = 0; nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; remainingExpirationTime = 0; componentUpdateQueue = null; sideEffectTag = 0; - invariant( - !current, - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." - ); + if (current) + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); return workInProgress; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - renderExpirationTime = 0; + renderExpirationTime$1 = 0; nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; remainingExpirationTime = 0; componentUpdateQueue = null; @@ -3180,10 +3455,8 @@ function updateWorkInProgressHook() { (currentHook = nextCurrentHook), (nextCurrentHook = null !== currentHook ? currentHook.next : null); else { - invariant( - null !== nextCurrentHook, - "Rendered more hooks than during the previous render." - ); + if (null === nextCurrentHook) + throw ReactError("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; var newHook = { memoizedState: currentHook.memoizedState, @@ -3206,10 +3479,11 @@ function basicStateReducer(state, action) { function updateReducer(reducer) { var hook = updateWorkInProgressHook(), queue = hook.queue; - invariant( - null !== queue, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + if (null === queue) + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + queue.lastRenderedReducer = reducer; if (0 < numberOfReRenders) { var _dispatch = queue.dispatch; if (null !== renderPhaseUpdates) { @@ -3224,8 +3498,7 @@ function updateReducer(reducer) { is(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; hook.baseUpdate === queue.last && (hook.baseState = newState); - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; return [newState, _dispatch]; } } @@ -3244,17 +3517,19 @@ function updateReducer(reducer) { didSkip = !1; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime + updateExpirationTime < renderExpirationTime$1 ? (didSkip || ((didSkip = !0), (newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)), updateExpirationTime > remainingExpirationTime && (remainingExpirationTime = updateExpirationTime)) - : (newState = + : (updateExpirationTime < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = updateExpirationTime), + (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action)); + : reducer(newState, _update.action))); baseUpdate = _update; _update = _update.next; } while (null !== _update && _update !== _dispatch); @@ -3264,8 +3539,7 @@ function updateReducer(reducer) { hook.memoizedState = newState; hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; } @@ -3328,10 +3602,10 @@ function imperativeHandleEffect(create, ref) { } function mountDebugValue() {} function dispatchAction(fiber, queue, action) { - invariant( - 25 > numberOfReRenders, - "Too many re-renders. React limits the number of renders to prevent an infinite loop." - ); + if (!(25 > numberOfReRenders)) + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); var alternate = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3340,7 +3614,7 @@ function dispatchAction(fiber, queue, action) { if ( ((didScheduleRenderPhaseUpdate = !0), (fiber = { - expirationTime: renderExpirationTime, + expirationTime: renderExpirationTime$1, action: action, eagerReducer: null, eagerState: null, @@ -3377,10 +3651,10 @@ function dispatchAction(fiber, queue, action) { if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && - ((alternate = queue.eagerReducer), null !== alternate) + ((alternate = queue.lastRenderedReducer), null !== alternate) ) try { - var currentState = queue.eagerState, + var currentState = queue.lastRenderedState, _eagerState = alternate(currentState, action); _update2.eagerReducer = alternate; _update2.eagerState = _eagerState; @@ -3388,7 +3662,7 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleUpdateOnFiber(fiber, currentTime); } } var ContextOnlyDispatcher = { @@ -3443,8 +3717,8 @@ var ContextOnlyDispatcher = { reducer = hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialArg + lastRenderedReducer: reducer, + lastRenderedState: initialArg }; reducer = reducer.dispatch = dispatchAction.bind( null, @@ -3465,8 +3739,8 @@ var ContextOnlyDispatcher = { initialState = hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }; initialState = initialState.dispatch = dispatchAction.bind( null, @@ -4082,7 +4356,10 @@ function updateSuspenseComponent( nextState = null; var nextDidTimeout = !1; } else - (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextState = { + fallbackExpirationTime: + null !== nextState ? nextState.fallbackExpirationTime : 0 + }), (nextDidTimeout = !0), (workInProgress.effectTag &= -65); if (null === current$$1) @@ -4177,10 +4454,8 @@ function bailoutOnAlreadyFinishedWork( null !== current$$1 && (workInProgress.contextDependencies = current$$1.contextDependencies); if (workInProgress.childExpirationTime < renderExpirationTime) return null; - invariant( - null === current$$1 || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + if (null !== current$$1 && workInProgress.child !== current$$1.child) + throw ReactError("Resuming work not yet implemented."); if (null !== workInProgress.child) { current$$1 = workInProgress.child; renderExpirationTime = createWorkInProgress( @@ -4205,845 +4480,6 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime) { - var updateExpirationTime = workInProgress.expirationTime; - if (null !== current$$1) - if ( - current$$1.memoizedProps !== workInProgress.pendingProps || - didPerformWorkStackCursor.current - ) - didReceiveUpdate = !0; - else { - if (updateExpirationTime < renderExpirationTime) { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ); - break; - case 10: - pushProvider(workInProgress, workInProgress.memoizedProps.value); - break; - case 13: - if (null !== workInProgress.memoizedState) { - updateExpirationTime = workInProgress.child.childExpirationTime; - if ( - 0 !== updateExpirationTime && - updateExpirationTime >= renderExpirationTime - ) - return updateSuspenseComponent( - current$$1, - workInProgress, - renderExpirationTime - ); - workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - return null !== workInProgress ? workInProgress.sibling : null; - } - } - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - } - else didReceiveUpdate = !1; - workInProgress.expirationTime = 0; - switch (workInProgress.tag) { - case 2: - updateExpirationTime = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - var context = getMaskedContext( - workInProgress, - contextStackCursor.current - ); - prepareToReadContext(workInProgress, renderExpirationTime); - context = renderWithHooks( - null, - workInProgress, - updateExpirationTime, - current$$1, - context, - renderExpirationTime - ); - workInProgress.effectTag |= 1; - if ( - "object" === typeof context && - null !== context && - "function" === typeof context.render && - void 0 === context.$$typeof - ) { - workInProgress.tag = 1; - resetHooks(); - if (isContextProvider(updateExpirationTime)) { - var hasContext = !0; - pushContextProvider(workInProgress); - } else hasContext = !1; - workInProgress.memoizedState = - null !== context.state && void 0 !== context.state - ? context.state - : null; - var getDerivedStateFromProps = - updateExpirationTime.getDerivedStateFromProps; - "function" === typeof getDerivedStateFromProps && - applyDerivedStateFromProps( - workInProgress, - updateExpirationTime, - getDerivedStateFromProps, - current$$1 - ); - context.updater = classComponentUpdater; - workInProgress.stateNode = context; - context._reactInternalFiber = workInProgress; - mountClassInstance( - workInProgress, - updateExpirationTime, - current$$1, - renderExpirationTime - ); - workInProgress = finishClassComponent( - null, - workInProgress, - updateExpirationTime, - !0, - hasContext, - renderExpirationTime - ); - } else - (workInProgress.tag = 0), - reconcileChildren( - null, - workInProgress, - context, - renderExpirationTime - ), - (workInProgress = workInProgress.child); - return workInProgress; - case 16: - context = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - hasContext = workInProgress.pendingProps; - current$$1 = readLazyComponentType(context); - workInProgress.type = current$$1; - context = workInProgress.tag = resolveLazyComponentTag(current$$1); - hasContext = resolveDefaultProps(current$$1, hasContext); - getDerivedStateFromProps = void 0; - switch (context) { - case 0: - getDerivedStateFromProps = updateFunctionComponent( - null, - workInProgress, - current$$1, - hasContext, - renderExpirationTime - ); - break; - case 1: - getDerivedStateFromProps = updateClassComponent( - null, - workInProgress, - current$$1, - hasContext, - renderExpirationTime - ); - break; - case 11: - getDerivedStateFromProps = updateForwardRef( - null, - workInProgress, - current$$1, - hasContext, - renderExpirationTime - ); - break; - case 14: - getDerivedStateFromProps = updateMemoComponent( - null, - workInProgress, - current$$1, - resolveDefaultProps(current$$1.type, hasContext), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", - current$$1, - "" - ); - } - return getDerivedStateFromProps; - case 0: - return ( - (updateExpirationTime = workInProgress.type), - (context = workInProgress.pendingProps), - (context = - workInProgress.elementType === updateExpirationTime - ? context - : resolveDefaultProps(updateExpirationTime, context)), - updateFunctionComponent( - current$$1, - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ) - ); - case 1: - return ( - (updateExpirationTime = workInProgress.type), - (context = workInProgress.pendingProps), - (context = - workInProgress.elementType === updateExpirationTime - ? context - : resolveDefaultProps(updateExpirationTime, context)), - updateClassComponent( - current$$1, - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ) - ); - case 3: - return ( - pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), - invariant( - null !== updateExpirationTime, - "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." - ), - (context = workInProgress.memoizedState), - (context = null !== context ? context.element : null), - processUpdateQueue( - workInProgress, - updateExpirationTime, - workInProgress.pendingProps, - null, - renderExpirationTime - ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === context - ? (workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )) - : (reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child)), - workInProgress - ); - case 5: - return ( - pushHostContext(workInProgress), - null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), - markRef(current$$1, workInProgress), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child), - workInProgress - ); - case 6: - return ( - null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - null - ); - case 13: - return updateSuspenseComponent( - current$$1, - workInProgress, - renderExpirationTime - ); - case 4: - return ( - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ), - (updateExpirationTime = workInProgress.pendingProps), - null === current$$1 - ? (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - )) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - workInProgress.child - ); - case 11: - return ( - (updateExpirationTime = workInProgress.type), - (context = workInProgress.pendingProps), - (context = - workInProgress.elementType === updateExpirationTime - ? context - : resolveDefaultProps(updateExpirationTime, context)), - updateForwardRef( - current$$1, - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ) - ); - case 7: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps, - renderExpirationTime - ), - workInProgress.child - ); - case 8: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime - ), - workInProgress.child - ); - case 12: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime - ), - workInProgress.child - ); - case 10: - a: { - updateExpirationTime = workInProgress.type._context; - context = workInProgress.pendingProps; - getDerivedStateFromProps = workInProgress.memoizedProps; - hasContext = context.value; - pushProvider(workInProgress, hasContext); - if (null !== getDerivedStateFromProps) { - var oldValue = getDerivedStateFromProps.value; - hasContext = is(oldValue, hasContext) - ? 0 - : ("function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( - oldValue, - hasContext - ) - : 1073741823) | 0; - if (0 === hasContext) { - if ( - getDerivedStateFromProps.children === context.children && - !didPerformWorkStackCursor.current - ) { - workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - } else - for ( - oldValue = workInProgress.child, - null !== oldValue && (oldValue.return = workInProgress); - null !== oldValue; - - ) { - var list = oldValue.contextDependencies; - if (null !== list) { - getDerivedStateFromProps = oldValue.child; - for (var dependency = list.first; null !== dependency; ) { - if ( - dependency.context === updateExpirationTime && - 0 !== (dependency.observedBits & hasContext) - ) { - 1 === oldValue.tag && - ((dependency = createUpdate(renderExpirationTime)), - (dependency.tag = ForceUpdate), - enqueueUpdate(oldValue, dependency)); - oldValue.expirationTime < renderExpirationTime && - (oldValue.expirationTime = renderExpirationTime); - dependency = oldValue.alternate; - null !== dependency && - dependency.expirationTime < renderExpirationTime && - (dependency.expirationTime = renderExpirationTime); - dependency = renderExpirationTime; - for (var node = oldValue.return; null !== node; ) { - var alternate = node.alternate; - if (node.childExpirationTime < dependency) - (node.childExpirationTime = dependency), - null !== alternate && - alternate.childExpirationTime < dependency && - (alternate.childExpirationTime = dependency); - else if ( - null !== alternate && - alternate.childExpirationTime < dependency - ) - alternate.childExpirationTime = dependency; - else break; - node = node.return; - } - list.expirationTime < renderExpirationTime && - (list.expirationTime = renderExpirationTime); - break; - } - dependency = dependency.next; - } - } else - getDerivedStateFromProps = - 10 === oldValue.tag - ? oldValue.type === workInProgress.type - ? null - : oldValue.child - : oldValue.child; - if (null !== getDerivedStateFromProps) - getDerivedStateFromProps.return = oldValue; - else - for ( - getDerivedStateFromProps = oldValue; - null !== getDerivedStateFromProps; - - ) { - if (getDerivedStateFromProps === workInProgress) { - getDerivedStateFromProps = null; - break; - } - oldValue = getDerivedStateFromProps.sibling; - if (null !== oldValue) { - oldValue.return = getDerivedStateFromProps.return; - getDerivedStateFromProps = oldValue; - break; - } - getDerivedStateFromProps = getDerivedStateFromProps.return; - } - oldValue = getDerivedStateFromProps; - } - } - reconcileChildren( - current$$1, - workInProgress, - context.children, - renderExpirationTime - ); - workInProgress = workInProgress.child; - } - return workInProgress; - case 9: - return ( - (context = workInProgress.type), - (hasContext = workInProgress.pendingProps), - (updateExpirationTime = hasContext.children), - prepareToReadContext(workInProgress, renderExpirationTime), - (context = readContext(context, hasContext.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(context)), - (workInProgress.effectTag |= 1), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - workInProgress.child - ); - case 14: - return ( - (context = workInProgress.type), - (hasContext = resolveDefaultProps( - context, - workInProgress.pendingProps - )), - (hasContext = resolveDefaultProps(context.type, hasContext)), - updateMemoComponent( - current$$1, - workInProgress, - context, - hasContext, - updateExpirationTime, - renderExpirationTime - ) - ); - case 15: - return updateSimpleMemoComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - updateExpirationTime, - renderExpirationTime - ); - case 17: - return ( - (updateExpirationTime = workInProgress.type), - (context = workInProgress.pendingProps), - (context = - workInProgress.elementType === updateExpirationTime - ? context - : resolveDefaultProps(updateExpirationTime, context)), - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), - (workInProgress.tag = 1), - isContextProvider(updateExpirationTime) - ? ((current$$1 = !0), pushContextProvider(workInProgress)) - : (current$$1 = !1), - prepareToReadContext(workInProgress, renderExpirationTime), - constructClassInstance( - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ), - mountClassInstance( - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ), - finishClassComponent( - null, - workInProgress, - updateExpirationTime, - !0, - current$$1, - renderExpirationTime - ) - ); - } - invariant( - !1, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); -} -var valueCursor = { current: null }, - currentlyRenderingFiber = null, - lastContextDependency = null, - lastContextWithAllBitsObserved = null; -function pushProvider(providerFiber, nextValue) { - var context = providerFiber.type._context; - push(valueCursor, context._currentValue, providerFiber); - context._currentValue = nextValue; -} -function popProvider(providerFiber) { - var currentValue = valueCursor.current; - pop(valueCursor, providerFiber); - providerFiber.type._context._currentValue = currentValue; -} -function prepareToReadContext(workInProgress, renderExpirationTime) { - currentlyRenderingFiber = workInProgress; - lastContextWithAllBitsObserved = lastContextDependency = null; - var currentDependencies = workInProgress.contextDependencies; - null !== currentDependencies && - currentDependencies.expirationTime >= renderExpirationTime && - (didReceiveUpdate = !0); - workInProgress.contextDependencies = null; -} -function readContext(context, observedBits) { - if ( - lastContextWithAllBitsObserved !== context && - !1 !== observedBits && - 0 !== observedBits - ) { - if ("number" !== typeof observedBits || 1073741823 === observedBits) - (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); - observedBits = { context: context, observedBits: observedBits, next: null }; - null === lastContextDependency - ? (invariant( - null !== currentlyRenderingFiber, - "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()." - ), - (lastContextDependency = observedBits), - (currentlyRenderingFiber.contextDependencies = { - first: observedBits, - expirationTime: 0 - })) - : (lastContextDependency = lastContextDependency.next = observedBits); - } - return context._currentValue; -} -var UpdateState = 0, - ReplaceState = 1, - ForceUpdate = 2, - CaptureUpdate = 3, - hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; -} -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; -} -function createUpdate(expirationTime) { - return { - expirationTime: expirationTime, - tag: UpdateState, - payload: null, - callback: null, - next: null, - nextEffect: null - }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); -} -function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); -} -function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case ReplaceState: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case CaptureUpdate: - workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; - case UpdateState: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case ForceUpdate: - hasForceUpdate = !0; - } - return prevState; -} -function processUpdateQueue( - workInProgress, - queue, - props, - instance, - renderExpirationTime -) { - hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; - } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; - } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; -} -function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var _callback3 = effect.callback; - if (null !== _callback3) { - effect.callback = null; - var context = instance; - invariant( - "function" === typeof _callback3, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - _callback3 - ); - _callback3.call(context); - } - effect = effect.nextEffect; - } -} -function createCapturedValue(value, source) { - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; -} var appendAllChildren = void 0, updateHostContainer = void 0, updateHostComponent$1 = void 0, @@ -5075,6 +4511,13 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { updateHostText$1 = function(current, workInProgress, oldText, newText) { oldText !== newText && (workInProgress.effectTag |= 4); }; +function createCapturedValue(value, source) { + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; +} function logCapturedError(capturedError) { var componentStack = capturedError.componentStack, error = capturedError.error; @@ -5269,17 +4712,14 @@ function commitPlacement(finishedWork) { } parent = parent.return; } - invariant( - !1, + throw ReactError( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); - parentFiber = void 0; } - var isContainer = (parent = void 0); switch (parentFiber.tag) { case 5: parent = parentFiber.stateNode; - isContainer = !1; + var isContainer = !1; break; case 3: parent = parentFiber.stateNode.containerInfo; @@ -5290,8 +4730,7 @@ function commitPlacement(finishedWork) { isContainer = !0; break; default: - invariant( - !1, + throw ReactError( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } @@ -5322,23 +4761,23 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (5 === node.tag || 6 === node.tag) + if (5 === node.tag || 6 === node.tag) { + var stateNode = node.stateNode; if (parentFiber) - if (isContainer) - invariant( - "number" !== typeof parent, - "Container does not support insertBefore operation" - ); - else { + if (isContainer) { + if ("number" === typeof parent) + throw ReactError( + "Container does not support insertBefore operation" + ); + } else { var parentInstance = parent, - child = node.stateNode, beforeChild = parentFiber, children = parentInstance._children, - index = children.indexOf(child); + index = children.indexOf(stateNode); 0 <= index ? (children.splice(index, 1), (beforeChild = children.indexOf(beforeChild)), - children.splice(beforeChild, 0, child), + children.splice(beforeChild, 0, stateNode), UIManager.manageChildren( parentInstance._nativeTag, [index], @@ -5348,32 +4787,33 @@ function commitPlacement(finishedWork) { [] )) : ((index = children.indexOf(beforeChild)), - children.splice(index, 0, child), + children.splice(index, 0, stateNode), UIManager.manageChildren( parentInstance._nativeTag, [], [], - ["number" === typeof child ? child : child._nativeTag], + [ + "number" === typeof stateNode + ? stateNode + : stateNode._nativeTag + ], [index], [] )); } else isContainer - ? ((parentInstance = node.stateNode), - UIManager.setChildren(parent, [ - "number" === typeof parentInstance - ? parentInstance - : parentInstance._nativeTag - ])) + ? UIManager.setChildren(parent, [ + "number" === typeof stateNode ? stateNode : stateNode._nativeTag + ]) : ((parentInstance = parent), - (child = node.stateNode), - (children = "number" === typeof child ? child : child._nativeTag), + (children = + "number" === typeof stateNode ? stateNode : stateNode._nativeTag), (index = parentInstance._children), - (beforeChild = index.indexOf(child)), + (beforeChild = index.indexOf(stateNode)), 0 <= beforeChild ? (index.splice(beforeChild, 1), - index.push(child), + index.push(stateNode), UIManager.manageChildren( parentInstance._nativeTag, [beforeChild], @@ -5382,7 +4822,7 @@ function commitPlacement(finishedWork) { [], [] )) - : (index.push(child), + : (index.push(stateNode), UIManager.manageChildren( parentInstance._nativeTag, [], @@ -5391,7 +4831,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (4 !== node.tag && null !== node.child) { + } else if (4 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -5417,10 +4857,10 @@ function unmountHostComponents(current$$1) { if (!currentParentIsValid) { currentParentIsValid = node.return; a: for (;;) { - invariant( - null !== currentParentIsValid, - "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === currentParentIsValid) + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); switch (currentParentIsValid.tag) { case 5: currentParent = currentParentIsValid.stateNode; @@ -5508,81 +4948,93 @@ function commitWork(current$$1, finishedWork) { if (null != instance) { var newProps = finishedWork.memoizedProps; current$$1 = null !== current$$1 ? current$$1.memoizedProps : newProps; - var type = finishedWork.type, - updatePayload = finishedWork.updateQueue; + var updatePayload = finishedWork.updateQueue; finishedWork.updateQueue = null; null !== updatePayload && - commitUpdate( - instance, - updatePayload, - type, + ((finishedWork = instance.viewConfig), + (instanceProps[instance._nativeTag] = newProps), + (newProps = diffProperties( + null, current$$1, newProps, - finishedWork - ); + finishedWork.validAttributes + )), + null != newProps && + UIManager.updateView( + instance._nativeTag, + finishedWork.uiViewClassName, + newProps + )); } break; case 6: - invariant( - null !== finishedWork.stateNode, - "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === finishedWork.stateNode) + throw ReactError( + "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + ); UIManager.updateView(finishedWork.stateNode, "RCTRawText", { text: finishedWork.memoizedProps }); break; + case 20: + break; case 3: break; case 12: break; case 13: - instance = finishedWork.memoizedState; - newProps = void 0; - current$$1 = finishedWork; - null === instance - ? (newProps = !1) - : ((newProps = !0), - (current$$1 = finishedWork.child), - 0 === instance.timedOutAt && - (instance.timedOutAt = requestCurrentTime())); - null !== current$$1 && hideOrUnhideAllChildren(current$$1, newProps); - instance = finishedWork.updateQueue; - if (null !== instance) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; - null === retryCache && - (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); - instance.forEach(function(thenable) { - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - retryCache.has(thenable) || - (retryCache.add(thenable), thenable.then(retry, retry)); - }); - } + commitSuspenseComponent(finishedWork); break; case 17: break; + case 19: + break; default: - invariant( - !1, + throw ReactError( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } } +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState, + newDidTimeout = void 0, + primaryChildParent = finishedWork; + null === newState + ? (newDidTimeout = !1) + : ((newDidTimeout = !0), + (primaryChildParent = finishedWork.child), + 0 === newState.fallbackExpirationTime && + (newState.fallbackExpirationTime = requestCurrentTime() - 500)); + null !== primaryChildParent && + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + newState = finishedWork.updateQueue; + if (null !== newState) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + null === retryCache && + (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); + newState.forEach(function(thenable) { + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + (retryCache.add(thenable), thenable.then(retry, retry)); + }); + } +} var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); - expirationTime.tag = CaptureUpdate; + expirationTime.tag = 3; expirationTime.payload = { element: null }; var error = errorInfo.value; expirationTime.callback = function() { - onUncaughtError(error); + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); logError(fiber, errorInfo); }; return expirationTime; } function createClassErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); - expirationTime.tag = CaptureUpdate; + expirationTime.tag = 3; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error$jscomp$0 = errorInfo.value; @@ -5617,17 +5069,15 @@ function unwindWork(workInProgress) { workInProgress) : null; case 3: - return ( - popHostContainer(workInProgress), - popTopLevelContextObject(workInProgress), - (effectTag = workInProgress.effectTag), - invariant( - 0 === (effectTag & 64), + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw ReactError( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ), - (workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress - ); + ); + workInProgress.effectTag = (effectTag & -2049) | 64; + return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: @@ -5644,384 +5094,510 @@ function unwindWork(workInProgress) { return popHostContainer(workInProgress), null; case 10: return popProvider(workInProgress), null; + case 19: + case 20: + return null; default: return null; } } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var ceil = Math.ceil, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - isWorking = !1, - nextUnitOfWork = null, - nextRoot = null, - nextRenderExpirationTime = 0, - nextLatestAbsoluteTimeoutMs = -1, - nextRenderDidError = !1, + LegacyUnbatchedPhase = 2, + RenderPhase = 4, + CommitPhase = 5, + RootIncomplete = 0, + RootErrored = 1, + RootSuspended = 2, + RootCompleted = 3, + workPhase = 0, + workInProgressRoot = null, + workInProgress = null, + renderExpirationTime = 0, + workInProgressRootExitStatus = RootIncomplete, + workInProgressRootMostRecentEventTime = 1073741823, nextEffect = null, - isCommitting$1 = !1, + hasUncaughtError = !1, + firstUncaughtError = null, + legacyErrorBoundariesThatAlreadyFailed = null, + rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, - passiveEffectCallbackHandle = null, - passiveEffectCallback = null, - legacyErrorBoundariesThatAlreadyFailed = null; -function resetStack() { - if (null !== nextUnitOfWork) - for ( - var interruptedWork = nextUnitOfWork.return; - null !== interruptedWork; + rootsWithPendingDiscreteUpdates = null, + nestedUpdateCount = 0, + rootWithNestedUpdates = null, + currentEventTime = 0; +function requestCurrentTime() { + return workPhase === RenderPhase || workPhase === CommitPhase + ? 1073741822 - ((now() / 10) | 0) + : 0 !== currentEventTime + ? currentEventTime + : (currentEventTime = 1073741822 - ((now() / 10) | 0)); +} +function computeExpirationForFiber(currentTime, fiber) { + if (0 === (fiber.mode & 1)) return 1073741823; + if (workPhase === RenderPhase) return renderExpirationTime; + switch (getCurrentPriorityLevel()) { + case 99: + currentTime = 1073741823; + break; + case 98: + currentTime = + 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); + break; + case 97: + case 96: + currentTime = + 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); + break; + case 95: + currentTime = 1; + break; + default: + throw ReactError("Expected a valid priority level"); + } + null !== workInProgressRoot && + currentTime === renderExpirationTime && + --currentTime; + return currentTime; +} +function scheduleUpdateOnFiber(fiber, expirationTime) { + if (50 < nestedUpdateCount) + throw ((nestedUpdateCount = 0), + (rootWithNestedUpdates = null), + ReactError( + "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." + )); + fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (null !== fiber) + if (((fiber.pingTime = 0), 1073741823 === expirationTime)) + if (workPhase === LegacyUnbatchedPhase) + for ( + expirationTime = renderRoot(fiber, 1073741823, !0); + null !== expirationTime; - ) { - var interruptedWork$jscomp$0 = interruptedWork; - switch (interruptedWork$jscomp$0.tag) { + ) + expirationTime = expirationTime(!0); + else + scheduleCallbackForRoot(fiber, 99, 1073741823), + 0 === workPhase && flushImmediateQueue(); + else { + var priorityLevel = getCurrentPriorityLevel(); + if (98 === priorityLevel) + if (null === rootsWithPendingDiscreteUpdates) + rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]]); + else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(fiber); + (void 0 === lastDiscreteTime || lastDiscreteTime > expirationTime) && + rootsWithPendingDiscreteUpdates.set(fiber, expirationTime); + } + scheduleCallbackForRoot(fiber, priorityLevel, expirationTime); + } +} +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); + var alternate = fiber.alternate; + null !== alternate && + alternate.expirationTime < expirationTime && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); + null !== alternate && + alternate.childExpirationTime < expirationTime && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 3 === node.tag) { + root = node.stateNode; + break; + } + node = node.return; + } + null !== root && + (expirationTime > root.firstPendingTime && + (root.firstPendingTime = expirationTime), + (fiber = root.lastPendingTime), + 0 === fiber || expirationTime < fiber) && + (root.lastPendingTime = expirationTime); + return root; +} +function scheduleCallbackForRoot(root, priorityLevel, expirationTime) { + if (root.callbackExpirationTime < expirationTime) { + var existingCallbackNode = root.callbackNode; + null !== existingCallbackNode && + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); + root.callbackExpirationTime = expirationTime; + existingCallbackNode = null; + 1073741823 !== expirationTime && + 1 !== expirationTime && + ((existingCallbackNode = 10 * (1073741822 - expirationTime) - now()), + 5e3 < existingCallbackNode && (existingCallbackNode = 5e3), + (existingCallbackNode = { timeout: existingCallbackNode })); + root.callbackNode = scheduleCallback( + priorityLevel, + runRootCallback.bind( + null, + root, + renderRoot.bind(null, root, expirationTime) + ), + existingCallbackNode + ); + } +} +function runRootCallback(root, callback, isSync) { + var prevCallbackNode = root.callbackNode, + continuation = null; + try { + return ( + (continuation = callback(isSync)), + null !== continuation + ? runRootCallback.bind(null, root, continuation) + : null + ); + } finally { + null === continuation && + prevCallbackNode === root.callbackNode && + ((root.callbackNode = null), (root.callbackExpirationTime = 0)); + } +} +function resolveLocksOnRoot(root, expirationTime) { + var firstBatch = root.firstBatch; + return null !== firstBatch && + firstBatch._defer && + firstBatch._expirationTime >= expirationTime + ? ((root.finishedWork = root.current.alternate), + (root.pendingCommitExpirationTime = expirationTime), + scheduleCallback(97, function() { + firstBatch._onComplete(); + return null; + }), + !0) + : !1; +} +function flushPendingDiscreteUpdates() { + if (null !== rootsWithPendingDiscreteUpdates) { + var roots = rootsWithPendingDiscreteUpdates; + rootsWithPendingDiscreteUpdates = null; + roots.forEach(function(expirationTime, root) { + scheduleCallback(99, renderRoot.bind(null, root, expirationTime)); + }); + flushImmediateQueue(); + } +} +function prepareFreshStack(root, expirationTime) { + root.pendingCommitExpirationTime = 0; + var timeoutHandle = root.timeoutHandle; + -1 !== timeoutHandle && + ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); + if (null !== workInProgress) + for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) { + var interruptedWork = timeoutHandle; + switch (interruptedWork.tag) { case 1: - var childContextTypes = - interruptedWork$jscomp$0.type.childContextTypes; + var childContextTypes = interruptedWork.type.childContextTypes; null !== childContextTypes && void 0 !== childContextTypes && - popContext(interruptedWork$jscomp$0); + popContext(interruptedWork); break; case 3: - popHostContainer(interruptedWork$jscomp$0); - popTopLevelContextObject(interruptedWork$jscomp$0); + popHostContainer(interruptedWork); + popTopLevelContextObject(interruptedWork); break; case 5: - popHostContext(interruptedWork$jscomp$0); + popHostContext(interruptedWork); break; case 4: - popHostContainer(interruptedWork$jscomp$0); + popHostContainer(interruptedWork); break; case 10: - popProvider(interruptedWork$jscomp$0); + popProvider(interruptedWork); } - interruptedWork = interruptedWork.return; + timeoutHandle = timeoutHandle.return; } - nextRoot = null; - nextRenderExpirationTime = 0; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = !1; - nextUnitOfWork = null; + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null, expirationTime); + renderExpirationTime = expirationTime; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootMostRecentEventTime = 1073741823; } -function commitAllHostEffects() { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { - var current$$1 = nextEffect.alternate; - null !== current$$1 && - ((current$$1 = current$$1.ref), - null !== current$$1 && - ("function" === typeof current$$1 - ? current$$1(null) - : (current$$1.current = null))); - } - switch (effectTag & 14) { - case 2: - commitPlacement(nextEffect); - nextEffect.effectTag &= -3; - break; - case 6: - commitPlacement(nextEffect); - nextEffect.effectTag &= -3; - commitWork(nextEffect.alternate, nextEffect); - break; - case 4: - commitWork(nextEffect.alternate, nextEffect); - break; - case 8: - (effectTag = nextEffect), - unmountHostComponents(effectTag), - (effectTag.return = null), - (effectTag.child = null), - (effectTag.memoizedState = null), - (effectTag.updateQueue = null), - (effectTag = effectTag.alternate), - null !== effectTag && - ((effectTag.return = null), - (effectTag.child = null), - (effectTag.memoizedState = null), - (effectTag.updateQueue = null)); - } - nextEffect = nextEffect.nextEffect; - } -} -function commitBeforeMutationLifecycles() { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) - a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - break a; - case 1: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState; - current$$1 = finishedWork.stateNode; - finishedWork = current$$1.getSnapshotBeforeUpdate( - finishedWork.elementType === finishedWork.type - ? prevProps - : resolveDefaultProps(finishedWork.type, prevProps), - prevState - ); - current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; - } - break a; - case 3: - case 5: - case 6: - case 4: - case 17: - break a; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } -} -function commitAllLifeCycles(finishedRoot, committedExpirationTime$jscomp$0) { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 36) { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect, - committedExpirationTime = committedExpirationTime$jscomp$0; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; - case 1: - var instance = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current$$1) instance.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current$$1.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current$$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - current$$1 = finishedWork.updateQueue; - null !== current$$1 && - commitUpdateQueue( - finishedWork, - current$$1, - instance, - committedExpirationTime - ); - break; - case 3: - instance = finishedWork.updateQueue; - if (null !== instance) { - current$$1 = null; - if (null !== finishedWork.child) - switch (finishedWork.child.tag) { - case 5: - current$$1 = finishedWork.child.stateNode; - break; - case 1: - current$$1 = finishedWork.child.stateNode; - } - commitUpdateQueue( - finishedWork, - instance, - current$$1, - committedExpirationTime - ); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 17: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." +function renderRoot(root$jscomp$0, expirationTime, isSync) { + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Should not already be working."); + if (root$jscomp$0.firstPendingTime < expirationTime) return null; + if (root$jscomp$0.pendingCommitExpirationTime === expirationTime) + return ( + (root$jscomp$0.pendingCommitExpirationTime = 0), + commitRoot.bind(null, root$jscomp$0, expirationTime) + ); + flushPassiveEffects(); + (root$jscomp$0 === workInProgressRoot && + expirationTime === renderExpirationTime) || + prepareFreshStack(root$jscomp$0, expirationTime); + if (null !== workInProgress) { + var prevWorkPhase = workPhase; + workPhase = RenderPhase; + var prevDispatcher = ReactCurrentDispatcher.current; + null === prevDispatcher && (prevDispatcher = ContextOnlyDispatcher); + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + if (isSync) { + if (1073741823 !== expirationTime) { + var currentTime = requestCurrentTime(); + if (currentTime < expirationTime) + return ( + (workPhase = prevWorkPhase), + resetContextDependences(), + (ReactCurrentDispatcher.current = prevDispatcher), + renderRoot.bind(null, root$jscomp$0, currentTime) ); } - } - effectTag & 128 && - ((finishedWork = nextEffect.ref), - null !== finishedWork && - ((committedExpirationTime = nextEffect.stateNode), - "function" === typeof finishedWork - ? finishedWork(committedExpirationTime) - : (finishedWork.current = committedExpirationTime))); - effectTag & 512 && (rootWithPendingPassiveEffects = finishedRoot); - nextEffect = nextEffect.nextEffect; - } -} -function commitPassiveEffects(root, firstEffect) { - passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; - var previousIsRendering = isRendering; - isRendering = !0; - do { - if (firstEffect.effectTag & 512) { - var didError = !1, - error = void 0; + } else currentEventTime = 0; + do try { - var finishedWork = firstEffect; - commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); - commitHookEffectList(NoEffect$1, MountPassive, finishedWork); - } catch (e) { - (didError = !0), (error = e); + if (isSync) + for (; null !== workInProgress; ) + workInProgress = performUnitOfWork(workInProgress); + else + for (; null !== workInProgress && !shouldYield(); ) + workInProgress = performUnitOfWork(workInProgress); + break; + } catch (thrownValue) { + resetContextDependences(); + resetHooks(); + currentTime = workInProgress; + if (null === currentTime || null === currentTime.return) + throw (prepareFreshStack(root$jscomp$0, expirationTime), + (workPhase = prevWorkPhase), + thrownValue); + a: { + var root = root$jscomp$0, + returnFiber = currentTime.return, + sourceFiber = currentTime, + value = thrownValue, + renderExpirationTime$jscomp$0 = renderExpirationTime; + sourceFiber.effectTag |= 1024; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; + if ( + null !== value && + "object" === typeof value && + "function" === typeof value.then + ) { + var thenable = value; + value = returnFiber; + do { + if ( + 13 === value.tag && + (void 0 === value.memoizedProps.fallback + ? 0 + : null === value.memoizedState) + ) { + returnFiber = value.updateQueue; + null === returnFiber + ? ((returnFiber = new Set()), + returnFiber.add(thenable), + (value.updateQueue = returnFiber)) + : returnFiber.add(thenable); + if (0 === (value.mode & 1)) { + value.effectTag |= 64; + sourceFiber.effectTag &= -1957; + 1 === sourceFiber.tag && + (null === sourceFiber.alternate + ? (sourceFiber.tag = 17) + : ((renderExpirationTime$jscomp$0 = createUpdate( + 1073741823 + )), + (renderExpirationTime$jscomp$0.tag = 2), + enqueueUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ))); + sourceFiber.expirationTime = 1073741823; + break a; + } + sourceFiber = root; + root = renderExpirationTime$jscomp$0; + var pingCache = sourceFiber.pingCache; + null === pingCache + ? ((pingCache = sourceFiber.pingCache = new PossiblyWeakMap()), + (returnFiber = new Set()), + pingCache.set(thenable, returnFiber)) + : ((returnFiber = pingCache.get(thenable)), + void 0 === returnFiber && + ((returnFiber = new Set()), + pingCache.set(thenable, returnFiber))); + returnFiber.has(root) || + (returnFiber.add(root), + (sourceFiber = pingSuspendedRoot.bind( + null, + sourceFiber, + thenable, + root + )), + thenable.then(sourceFiber, sourceFiber)); + value.effectTag |= 2048; + value.expirationTime = renderExpirationTime$jscomp$0; + break a; + } + value = value.return; + } while (null !== value); + value = Error( + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) + ); + } + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) + workInProgressRootExitStatus = RootErrored; + value = createCapturedValue(value, sourceFiber); + sourceFiber = returnFiber; + do { + switch (sourceFiber.tag) { + case 3: + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime$jscomp$0; + renderExpirationTime$jscomp$0 = createRootErrorUpdate( + sourceFiber, + value, + renderExpirationTime$jscomp$0 + ); + enqueueCapturedUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ); + break a; + case 1: + if ( + ((thenable = value), + (root = sourceFiber.type), + (returnFiber = sourceFiber.stateNode), + 0 === (sourceFiber.effectTag & 64) && + ("function" === typeof root.getDerivedStateFromError || + (null !== returnFiber && + "function" === typeof returnFiber.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has( + returnFiber + ))))) + ) { + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime$jscomp$0; + renderExpirationTime$jscomp$0 = createClassErrorUpdate( + sourceFiber, + thenable, + renderExpirationTime$jscomp$0 + ); + enqueueCapturedUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ); + break a; + } + } + sourceFiber = sourceFiber.return; + } while (null !== sourceFiber); + } + workInProgress = completeUnitOfWork(currentTime); } - didError && captureCommitPhaseError(firstEffect, error); - } - firstEffect = firstEffect.nextEffect; - } while (null !== firstEffect); - isRendering = previousIsRendering; - previousIsRendering = root.expirationTime; - 0 !== previousIsRendering && requestWork(root, previousIsRendering); - isBatchingUpdates || isRendering || performWork(1073741823, !1); -} -function flushPassiveEffects() { - if (null !== passiveEffectCallbackHandle) { - var callbackID = passiveEffectCallbackHandle; - scheduledCallback = null; - clearTimeout(callbackID); + while (1); + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher.current = prevDispatcher; + if (null !== workInProgress) + return renderRoot.bind(null, root$jscomp$0, expirationTime); + } + if (resolveLocksOnRoot(root$jscomp$0, expirationTime)) return null; + workInProgressRoot = null; + switch (workInProgressRootExitStatus) { + case RootIncomplete: + throw ReactError("Should have a work-in-progress."); + case RootErrored: + return ( + (prevWorkPhase = root$jscomp$0.lastPendingTime), + root$jscomp$0.lastPendingTime < expirationTime + ? renderRoot.bind(null, root$jscomp$0, prevWorkPhase) + : isSync + ? commitRoot.bind(null, root$jscomp$0, expirationTime) + : (prepareFreshStack(root$jscomp$0, expirationTime), + scheduleCallback( + 99, + renderRoot.bind(null, root$jscomp$0, expirationTime) + ), + null) + ); + case RootSuspended: + if (!isSync) { + isSync = root$jscomp$0.lastPendingTime; + if (root$jscomp$0.lastPendingTime < expirationTime) + return renderRoot.bind(null, root$jscomp$0, isSync); + if ( + 1073741823 !== workInProgressRootMostRecentEventTime && + ((prevWorkPhase = + 10 * (1073741822 - workInProgressRootMostRecentEventTime) - 5e3), + (isSync = now()), + (prevWorkPhase = isSync - prevWorkPhase), + (prevWorkPhase = + (120 > prevWorkPhase + ? 120 + : 480 > prevWorkPhase + ? 480 + : 1080 > prevWorkPhase + ? 1080 + : 1920 > prevWorkPhase + ? 1920 + : 3e3 > prevWorkPhase + ? 3e3 + : 4320 > prevWorkPhase + ? 4320 + : 1960 * ceil(prevWorkPhase / 1960)) - prevWorkPhase), + (isSync = 10 * (1073741822 - expirationTime) - isSync), + isSync < prevWorkPhase && (prevWorkPhase = isSync), + (isSync = prevWorkPhase), + 10 < isSync) + ) + return ( + (root$jscomp$0.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root$jscomp$0, expirationTime), + isSync + )), + null + ); + } + return commitRoot.bind(null, root$jscomp$0, expirationTime); + case RootCompleted: + return commitRoot.bind(null, root$jscomp$0, expirationTime); + default: + throw ReactError("Unknown root exit status."); } - null !== passiveEffectCallback && passiveEffectCallback(); } -function commitRoot(root, finishedWork) { - isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); - var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== committedExpirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.pendingCommitExpirationTime = 0; - var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, - childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; - markCommittedPriorityLevels( - root, - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit - ? childExpirationTimeBeforeCommit - : updateExpirationTimeBeforeCommit +function performUnitOfWork(unitOfWork) { + var next = beginWork$$1( + unitOfWork.alternate, + unitOfWork, + renderExpirationTime ); + unitOfWork.memoizedProps = unitOfWork.pendingProps; + null === next && (next = completeUnitOfWork(unitOfWork)); ReactCurrentOwner$2.current = null; - updateExpirationTimeBeforeCommit = void 0; - 1 < finishedWork.effectTag - ? null !== finishedWork.lastEffect - ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (updateExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (updateExpirationTimeBeforeCommit = finishedWork) - : (updateExpirationTimeBeforeCommit = finishedWork.firstEffect); - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - var error = void 0; - try { - commitBeforeMutationLifecycles(); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - error = void 0; - try { - commitAllHostEffects(); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - root.current = finishedWork; - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - error = void 0; - try { - commitAllLifeCycles(root, committedExpirationTime); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - if ( - null !== updateExpirationTimeBeforeCommit && - null !== rootWithPendingPassiveEffects - ) { - var callback = commitPassiveEffects.bind( - null, - root, - updateExpirationTimeBeforeCommit - ); - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return scheduleDeferredCallback$1(callback); - } - ); - passiveEffectCallback = callback; - } - isWorking = isCommitting$1 = !1; - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode); - committedExpirationTime = finishedWork.expirationTime; - finishedWork = finishedWork.childExpirationTime; - finishedWork = - finishedWork > committedExpirationTime - ? finishedWork - : committedExpirationTime; - 0 === finishedWork && (legacyErrorBoundariesThatAlreadyFailed = null); - onCommit(root, finishedWork); + return next; } -function completeUnitOfWork(workInProgress) { - for (;;) { - var current$$1 = workInProgress.alternate, - returnFiber = workInProgress.return, - siblingFiber = workInProgress.sibling; +function completeUnitOfWork(unitOfWork) { + workInProgress = unitOfWork; + do { + var current$$1 = workInProgress.alternate; + unitOfWork = workInProgress.return; if (0 === (workInProgress.effectTag & 1024)) { - nextUnitOfWork = workInProgress; a: { var current = current$$1; current$$1 = workInProgress; - var renderExpirationTime = nextRenderExpirationTime, + var renderExpirationTime$jscomp$0 = renderExpirationTime, newProps = current$$1.pendingProps; switch (current$$1.tag) { case 2: @@ -6047,7 +5623,7 @@ function completeUnitOfWork(workInProgress) { break; case 5: popHostContext(current$$1); - renderExpirationTime = requiredContext( + renderExpirationTime$jscomp$0 = requiredContext( rootInstanceStackCursor.current ); var type = current$$1.type; @@ -6057,101 +5633,113 @@ function completeUnitOfWork(workInProgress) { current$$1, type, newProps, - renderExpirationTime + renderExpirationTime$jscomp$0 ), current.ref !== current$$1.ref && (current$$1.effectTag |= 128); else if (newProps) { current = requiredContext(contextStackCursor$1.current); - var internalInstanceHandle = current$$1, - tag = allocateTag(), - viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !current.isInAParentText, - "Nesting of within is not currently supported." - ); + var type$jscomp$0 = type; + var instance = newProps; + var rootContainerInstance = renderExpirationTime$jscomp$0, + internalInstanceHandle = current$$1, + tag = allocateTag(); + type$jscomp$0 = ReactNativeViewConfigRegistry.get(type$jscomp$0); var updatePayload = diffProperties( null, emptyObject, - newProps, - viewConfig.validAttributes + instance, + type$jscomp$0.validAttributes ); UIManager.createView( tag, - viewConfig.uiViewClassName, - renderExpirationTime, + type$jscomp$0.uiViewClassName, + rootContainerInstance, updatePayload ); - viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); + rootContainerInstance = new ReactNativeFiberHostComponent( + tag, + type$jscomp$0 + ); instanceCache[tag] = internalInstanceHandle; - instanceProps[tag] = newProps; - appendAllChildren(viewConfig, current$$1, !1, !1); + instanceProps[tag] = instance; + instance = rootContainerInstance; + appendAllChildren(instance, current$$1, !1, !1); finalizeInitialChildren( - viewConfig, + instance, type, newProps, - renderExpirationTime, + renderExpirationTime$jscomp$0, current ) && (current$$1.effectTag |= 4); - current$$1.stateNode = viewConfig; + current$$1.stateNode = instance; null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, + } else if (null === current$$1.stateNode) + throw ReactError( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); break; case 6: - current && null != current$$1.stateNode - ? updateHostText$1( - current, - current$$1, - current.memoizedProps, - newProps - ) - : ("string" !== typeof newProps && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ), - (current = requiredContext(rootInstanceStackCursor.current)), - (type = requiredContext(contextStackCursor$1.current)), - (renderExpirationTime = current$$1), - invariant( - type.isInAParentText, + if (current && null != current$$1.stateNode) + updateHostText$1( + current, + current$$1, + current.memoizedProps, + newProps + ); + else { + if ("string" !== typeof newProps && null === current$$1.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + current = requiredContext(rootInstanceStackCursor.current); + type = requiredContext(contextStackCursor$1.current); + renderExpirationTime$jscomp$0 = current$$1; + if (!type.isInAParentText) + throw ReactError( "Text strings must be rendered within a component." - ), - (type = allocateTag()), - UIManager.createView(type, "RCTRawText", current, { - text: newProps - }), - (instanceCache[type] = current$$1), - (renderExpirationTime.stateNode = type)); + ); + type = allocateTag(); + UIManager.createView(type, "RCTRawText", current, { + text: newProps + }); + instanceCache[type] = current$$1; + renderExpirationTime$jscomp$0.stateNode = type; + } break; case 11: break; case 13: newProps = current$$1.memoizedState; if (0 !== (current$$1.effectTag & 64)) { - current$$1.expirationTime = renderExpirationTime; - nextUnitOfWork = current$$1; + current$$1.expirationTime = renderExpirationTime$jscomp$0; break a; } newProps = null !== newProps; - renderExpirationTime = - null !== current && null !== current.memoizedState; + renderExpirationTime$jscomp$0 = !1; null !== current && - !newProps && - renderExpirationTime && - ((type = current.child.sibling), - null !== type && - ((current = current$$1.firstEffect), - null !== current - ? ((current$$1.firstEffect = type), - (type.nextEffect = current)) - : ((current$$1.firstEffect = current$$1.lastEffect = type), - (type.nextEffect = null)), - (type.effectTag = 8))); - if (newProps || renderExpirationTime) current$$1.effectTag |= 4; + ((type = current.memoizedState), + (renderExpirationTime$jscomp$0 = null !== type), + newProps || + null === type || + ((type = type.fallbackExpirationTime), + type < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = type), + (type = current.child.sibling), + null !== type && + ((current = current$$1.firstEffect), + null !== current + ? ((current$$1.firstEffect = type), + (type.nextEffect = current)) + : ((current$$1.firstEffect = current$$1.lastEffect = type), + (type.nextEffect = null)), + (type.effectTag = 8)))); + newProps && + !renderExpirationTime$jscomp$0 && + 0 !== (current$$1.mode & 1) && + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); + if (newProps || renderExpirationTime$jscomp$0) + current$$1.effectTag |= 4; break; case 7: break; @@ -6175,355 +5763,396 @@ function completeUnitOfWork(workInProgress) { break; case 18: break; + case 19: + break; + case 20: + break; default: - invariant( - !1, + throw ReactError( "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); } - nextUnitOfWork = null; + current$$1 = null; } - current$$1 = workInProgress; - if ( - 1 === nextRenderExpirationTime || - 1 !== current$$1.childExpirationTime - ) { - newProps = 0; - for ( - renderExpirationTime = current$$1.child; - null !== renderExpirationTime; - - ) - (type = renderExpirationTime.expirationTime), - (current = renderExpirationTime.childExpirationTime), - type > newProps && (newProps = type), - current > newProps && (newProps = current), - (renderExpirationTime = renderExpirationTime.sibling); - current$$1.childExpirationTime = newProps; + newProps = workInProgress; + if (1 === renderExpirationTime || 1 !== newProps.childExpirationTime) { + renderExpirationTime$jscomp$0 = 0; + for (type = newProps.child; null !== type; ) + (current = type.expirationTime), + (instance = type.childExpirationTime), + current > renderExpirationTime$jscomp$0 && + (renderExpirationTime$jscomp$0 = current), + instance > renderExpirationTime$jscomp$0 && + (renderExpirationTime$jscomp$0 = instance), + (type = type.sibling); + newProps.childExpirationTime = renderExpirationTime$jscomp$0; } - if (null !== nextUnitOfWork) return nextUnitOfWork; - null !== returnFiber && - 0 === (returnFiber.effectTag & 1024) && - (null === returnFiber.firstEffect && - (returnFiber.firstEffect = workInProgress.firstEffect), + if (null !== current$$1) return current$$1; + null !== unitOfWork && + 0 === (unitOfWork.effectTag & 1024) && + (null === unitOfWork.firstEffect && + (unitOfWork.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && - (null !== returnFiber.lastEffect && - (returnFiber.lastEffect.nextEffect = workInProgress.firstEffect), - (returnFiber.lastEffect = workInProgress.lastEffect)), + (null !== unitOfWork.lastEffect && + (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), + (unitOfWork.lastEffect = workInProgress.lastEffect)), 1 < workInProgress.effectTag && - (null !== returnFiber.lastEffect - ? (returnFiber.lastEffect.nextEffect = workInProgress) - : (returnFiber.firstEffect = workInProgress), - (returnFiber.lastEffect = workInProgress))); + (null !== unitOfWork.lastEffect + ? (unitOfWork.lastEffect.nextEffect = workInProgress) + : (unitOfWork.firstEffect = workInProgress), + (unitOfWork.lastEffect = workInProgress))); } else { - workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); - if (null !== workInProgress) - return (workInProgress.effectTag &= 1023), workInProgress; - null !== returnFiber && - ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 1024)); + current$$1 = unwindWork(workInProgress, renderExpirationTime); + if (null !== current$$1) + return (current$$1.effectTag &= 1023), current$$1; + null !== unitOfWork && + ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), + (unitOfWork.effectTag |= 1024)); } - if (null !== siblingFiber) return siblingFiber; - if (null !== returnFiber) workInProgress = returnFiber; - else break; - } + current$$1 = workInProgress.sibling; + if (null !== current$$1) return current$$1; + workInProgress = unitOfWork; + } while (null !== workInProgress); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootCompleted); return null; } -function performUnitOfWork(workInProgress) { - var next = beginWork( - workInProgress.alternate, - workInProgress, - nextRenderExpirationTime - ); - workInProgress.memoizedProps = workInProgress.pendingProps; - null === next && (next = completeUnitOfWork(workInProgress)); - ReactCurrentOwner$2.current = null; - return next; +function commitRoot(root, expirationTime) { + runWithPriority(99, commitRootImpl.bind(null, root, expirationTime)); + null !== rootWithPendingPassiveEffects && + ((root = getCurrentPriorityLevel()), + scheduleCallback(root, function() { + flushPassiveEffects(); + return null; + })); + return null; } -function renderRoot(root$jscomp$0, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); +function commitRootImpl(root, expirationTime) { flushPassiveEffects(); - isWorking = !0; - var previousDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - var expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn; - if ( - expirationTime !== nextRenderExpirationTime || - root$jscomp$0 !== nextRoot || - null === nextUnitOfWork - ) - resetStack(), - (nextRoot = root$jscomp$0), - (nextRenderExpirationTime = expirationTime), - (nextUnitOfWork = createWorkInProgress( - nextRoot.current, - null, - nextRenderExpirationTime - )), - (root$jscomp$0.pendingCommitExpirationTime = 0); - var didFatal = !1; - do { - try { - if (isYieldy) - for (; null !== nextUnitOfWork && !(frameDeadline <= now$1()); ) - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - else - for (; null !== nextUnitOfWork; ) - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - } catch (thrownValue) { - if ( - ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), - resetHooks(), - null === nextUnitOfWork) - ) - (didFatal = !0), onUncaughtError(thrownValue); - else { - invariant( - null !== nextUnitOfWork, - "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." - ); - var sourceFiber = nextUnitOfWork, - returnFiber = sourceFiber.return; - if (null === returnFiber) (didFatal = !0), onUncaughtError(thrownValue); - else { - a: { - var root = root$jscomp$0, - returnFiber$jscomp$0 = returnFiber, - sourceFiber$jscomp$0 = sourceFiber, - value = thrownValue; - returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 1024; - sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; - if ( - null !== value && - "object" === typeof value && - "function" === typeof value.then - ) { - var thenable = value; - value = returnFiber$jscomp$0; - var earliestTimeoutMs = -1, - startTimeMs = -1; - do { - if (13 === value.tag) { - var current$$1 = value.alternate; - if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), - null !== current$$1) - ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); - break; - } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; - else if ( - -1 === earliestTimeoutMs || - current$$1 < earliestTimeoutMs - ) - earliestTimeoutMs = current$$1; - } - value = value.return; - } while (null !== value); - value = returnFiber$jscomp$0; - do { - if ((current$$1 = 13 === value.tag)) - current$$1 = - void 0 === value.memoizedProps.fallback - ? !1 - : null === value.memoizedState; - if (current$$1) { - returnFiber$jscomp$0 = value.updateQueue; - null === returnFiber$jscomp$0 - ? ((returnFiber$jscomp$0 = new Set()), - returnFiber$jscomp$0.add(thenable), - (value.updateQueue = returnFiber$jscomp$0)) - : returnFiber$jscomp$0.add(thenable); - if (0 === (value.mode & 1)) { - value.effectTag |= 64; - sourceFiber$jscomp$0.effectTag &= -1957; - 1 === sourceFiber$jscomp$0.tag && - (null === sourceFiber$jscomp$0.alternate - ? (sourceFiber$jscomp$0.tag = 17) - : ((returnFiber = createUpdate(1073741823)), - (returnFiber.tag = ForceUpdate), - enqueueUpdate(sourceFiber$jscomp$0, returnFiber))); - sourceFiber$jscomp$0.expirationTime = 1073741823; - break a; - } - sourceFiber$jscomp$0 = root; - returnFiber$jscomp$0 = returnFiber; - var pingCache = sourceFiber$jscomp$0.pingCache; - null === pingCache - ? ((pingCache = sourceFiber$jscomp$0.pingCache = new PossiblyWeakMap()), - (current$$1 = new Set()), - pingCache.set(thenable, current$$1)) - : ((current$$1 = pingCache.get(thenable)), - void 0 === current$$1 && - ((current$$1 = new Set()), - pingCache.set(thenable, current$$1))); - current$$1.has(returnFiber$jscomp$0) || - (current$$1.add(returnFiber$jscomp$0), - (sourceFiber$jscomp$0 = pingSuspendedRoot.bind( - null, - sourceFiber$jscomp$0, - thenable, - returnFiber$jscomp$0 - )), - thenable.then(sourceFiber$jscomp$0, sourceFiber$jscomp$0)); - -1 === earliestTimeoutMs - ? (root = 1073741823) - : (-1 === startTimeMs && - (startTimeMs = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - returnFiber - )) - - 5e3), - (root = startTimeMs + earliestTimeoutMs)); - 0 <= root && - nextLatestAbsoluteTimeoutMs < root && - (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 2048; - value.expirationTime = returnFiber; - break a; - } - value = value.return; - } while (null !== value); - value = Error( - (getComponentName(sourceFiber$jscomp$0.type) || - "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber$jscomp$0) - ); - } - nextRenderDidError = !0; - value = createCapturedValue(value, sourceFiber$jscomp$0); - root = returnFiber$jscomp$0; - do { - switch (root.tag) { - case 3: - root.effectTag |= 2048; - root.expirationTime = returnFiber; - returnFiber = createRootErrorUpdate(root, value, returnFiber); - enqueueCapturedUpdate(root, returnFiber); - break a; - case 1: - if ( - ((earliestTimeoutMs = value), - (startTimeMs = root.type), - (sourceFiber$jscomp$0 = root.stateNode), - 0 === (root.effectTag & 64) && - ("function" === - typeof startTimeMs.getDerivedStateFromError || - (null !== sourceFiber$jscomp$0 && - "function" === - typeof sourceFiber$jscomp$0.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - sourceFiber$jscomp$0 - ))))) - ) { - root.effectTag |= 2048; - root.expirationTime = returnFiber; - returnFiber = createClassErrorUpdate( - root, - earliestTimeoutMs, - returnFiber + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Should not already be working."); + var finishedWork = root.current.alternate; + if (null === finishedWork) + throw ReactError("Should have a work-in-progress root."); + root.callbackNode = null; + root.callbackExpirationTime = 0; + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, + childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + updateExpirationTimeBeforeCommit = + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit; + root.firstPendingTime = updateExpirationTimeBeforeCommit; + updateExpirationTimeBeforeCommit < root.lastPendingTime && + (root.lastPendingTime = updateExpirationTimeBeforeCommit); + root === workInProgressRoot && + ((workInProgress = workInProgressRoot = null), (renderExpirationTime = 0)); + 1 < finishedWork.effectTag + ? null !== finishedWork.lastEffect + ? ((finishedWork.lastEffect.nextEffect = finishedWork), + (childExpirationTimeBeforeCommit = finishedWork.firstEffect)) + : (childExpirationTimeBeforeCommit = finishedWork) + : (childExpirationTimeBeforeCommit = finishedWork.firstEffect); + if (null !== childExpirationTimeBeforeCommit) { + updateExpirationTimeBeforeCommit = workPhase; + workPhase = CommitPhase; + ReactCurrentOwner$2.current = null; + nextEffect = childExpirationTimeBeforeCommit; + do + try { + for (; null !== nextEffect; ) { + if (0 !== (nextEffect.effectTag & 256)) { + var current$$1 = nextEffect.alternate, + finishedWork$jscomp$0 = nextEffect; + switch (finishedWork$jscomp$0.tag) { + case 0: + case 11: + case 15: + commitHookEffectList( + UnmountSnapshot, + NoEffect$1, + finishedWork$jscomp$0 + ); + break; + case 1: + if ( + finishedWork$jscomp$0.effectTag & 256 && + null !== current$$1 + ) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState, + instance = finishedWork$jscomp$0.stateNode, + snapshot = instance.getSnapshotBeforeUpdate( + finishedWork$jscomp$0.elementType === + finishedWork$jscomp$0.type + ? prevProps + : resolveDefaultProps( + finishedWork$jscomp$0.type, + prevProps + ), + prevState ); - enqueueCapturedUpdate(root, returnFiber); - break a; - } - } - root = root.return; - } while (null !== root); + instance.__reactInternalSnapshotBeforeUpdate = snapshot; + } + break; + case 3: + case 5: + case 6: + case 4: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } } - nextUnitOfWork = completeUnitOfWork(sourceFiber); - continue; + nextEffect = nextEffect.nextEffect; } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; } - } - break; - } while (1); - isWorking = !1; - ReactCurrentDispatcher.current = previousDispatcher; - lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; - resetHooks(); - if (didFatal) (nextRoot = null), (root$jscomp$0.finishedWork = null); - else if (null !== nextUnitOfWork) root$jscomp$0.finishedWork = null; - else { - previousDispatcher = root$jscomp$0.current.alternate; - invariant( - null !== previousDispatcher, - "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." - ); - nextRoot = null; - if (nextRenderDidError) { - didFatal = root$jscomp$0.latestPendingTime; - sourceFiber = root$jscomp$0.latestSuspendedTime; - returnFiber = root$jscomp$0.latestPingedTime; - if ( - (0 !== didFatal && didFatal < expirationTime) || - (0 !== sourceFiber && sourceFiber < expirationTime) || - (0 !== returnFiber && returnFiber < expirationTime) - ) { - markSuspendedPriorityLevel(root$jscomp$0, expirationTime); - onSuspend( - root$jscomp$0, - previousDispatcher, - expirationTime, - root$jscomp$0.expirationTime, - -1 - ); - return; + while (null !== nextEffect); + nextEffect = childExpirationTimeBeforeCommit; + do + try { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 128) { + var current$$1$jscomp$0 = nextEffect.alternate; + if (null !== current$$1$jscomp$0) { + var currentRef = current$$1$jscomp$0.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (effectTag & 14) { + case 2: + commitPlacement(nextEffect); + nextEffect.effectTag &= -3; + break; + case 6: + commitPlacement(nextEffect); + nextEffect.effectTag &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + current$$1 = nextEffect; + unmountHostComponents(current$$1); + current$$1.return = null; + current$$1.child = null; + current$$1.memoizedState = null; + current$$1.updateQueue = null; + var alternate = current$$1.alternate; + null !== alternate && + ((alternate.return = null), + (alternate.child = null), + (alternate.memoizedState = null), + (alternate.updateQueue = null)); + } + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; } - if (!root$jscomp$0.didError && isYieldy) { - root$jscomp$0.didError = !0; - expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn = expirationTime; - isYieldy = root$jscomp$0.expirationTime = 1073741823; - onSuspend( - root$jscomp$0, - previousDispatcher, - expirationTime, - isYieldy, - -1 - ); - return; + while (null !== nextEffect); + root.current = finishedWork; + nextEffect = childExpirationTimeBeforeCommit; + do + try { + for (effectTag = expirationTime; null !== nextEffect; ) { + var effectTag$jscomp$0 = nextEffect.effectTag; + if (effectTag$jscomp$0 & 36) { + var current$$1$jscomp$1 = nextEffect.alternate; + current$$1$jscomp$0 = nextEffect; + currentRef = effectTag; + switch (current$$1$jscomp$0.tag) { + case 0: + case 11: + case 15: + commitHookEffectList( + UnmountLayout, + MountLayout, + current$$1$jscomp$0 + ); + break; + case 1: + var instance$jscomp$0 = current$$1$jscomp$0.stateNode; + if (current$$1$jscomp$0.effectTag & 4) + if (null === current$$1$jscomp$1) + instance$jscomp$0.componentDidMount(); + else { + var prevProps$jscomp$0 = + current$$1$jscomp$0.elementType === + current$$1$jscomp$0.type + ? current$$1$jscomp$1.memoizedProps + : resolveDefaultProps( + current$$1$jscomp$0.type, + current$$1$jscomp$1.memoizedProps + ); + instance$jscomp$0.componentDidUpdate( + prevProps$jscomp$0, + current$$1$jscomp$1.memoizedState, + instance$jscomp$0.__reactInternalSnapshotBeforeUpdate + ); + } + var updateQueue = current$$1$jscomp$0.updateQueue; + null !== updateQueue && + commitUpdateQueue( + current$$1$jscomp$0, + updateQueue, + instance$jscomp$0, + currentRef + ); + break; + case 3: + var _updateQueue = current$$1$jscomp$0.updateQueue; + if (null !== _updateQueue) { + alternate = null; + if (null !== current$$1$jscomp$0.child) + switch (current$$1$jscomp$0.child.tag) { + case 5: + alternate = current$$1$jscomp$0.child.stateNode; + break; + case 1: + alternate = current$$1$jscomp$0.child.stateNode; + } + commitUpdateQueue( + current$$1$jscomp$0, + _updateQueue, + alternate, + currentRef + ); + } + break; + case 5: + break; + case 6: + break; + case 4: + break; + case 12: + break; + case 13: + case 17: + break; + case 20: + break; + case 19: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + if (effectTag$jscomp$0 & 128) { + var ref = nextEffect.ref; + if (null !== ref) { + var instance$jscomp$1 = nextEffect.stateNode; + switch (nextEffect.tag) { + case 5: + var instanceToUse = instance$jscomp$1; + break; + default: + instanceToUse = instance$jscomp$1; + } + "function" === typeof ref + ? ref(instanceToUse) + : (ref.current = instanceToUse); + } + } + effectTag$jscomp$0 & 512 && (rootDoesHavePassiveEffects = !0); + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; } - } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs - ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), - (isYieldy = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root$jscomp$0, - expirationTime - ))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), - onSuspend( - root$jscomp$0, - previousDispatcher, - expirationTime, - root$jscomp$0.expirationTime, - 0 > isYieldy ? 0 : isYieldy - )) - : ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), - (root$jscomp$0.finishedWork = previousDispatcher)); - } + while (null !== nextEffect); + nextEffect = null; + workPhase = updateExpirationTimeBeforeCommit; + } else root.current = finishedWork; + rootDoesHavePassiveEffects && + ((rootDoesHavePassiveEffects = !1), (rootWithPendingPassiveEffects = root)); + expirationTime = root.firstPendingTime; + 0 !== expirationTime + ? ((effectTag$jscomp$0 = requestCurrentTime()), + (effectTag$jscomp$0 = inferPriorityFromExpirationTime( + effectTag$jscomp$0, + expirationTime + )), + scheduleCallbackForRoot(root, effectTag$jscomp$0, expirationTime)) + : (legacyErrorBoundariesThatAlreadyFailed = null); + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode); + 1073741823 === expirationTime + ? root === rootWithNestedUpdates + ? nestedUpdateCount++ + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) + : (nestedUpdateCount = 0); + if (hasUncaughtError) + throw ((hasUncaughtError = !1), + (root = firstUncaughtError), + (firstUncaughtError = null), + root); + if (workPhase === LegacyUnbatchedPhase) return null; + flushImmediateQueue(); + return null; } -function captureCommitPhaseError(sourceFiber, value) { - for (var fiber = sourceFiber.return; null !== fiber; ) { - switch (fiber.tag) { - case 1: +function flushPassiveEffects() { + if (null === rootWithPendingPassiveEffects) return !1; + var root = rootWithPendingPassiveEffects; + rootWithPendingPassiveEffects = null; + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Cannot flush passive effects while already rendering."); + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + for (root = root.current.firstEffect; null !== root; ) { + try { + var finishedWork = root; + commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); + commitHookEffectList(NoEffect$1, MountPassive, finishedWork); + } catch (error) { + if (null === root) throw ReactError("Should be working on an effect."); + captureCommitPhaseError(root, error); + } + root = root.nextEffect; + } + workPhase = prevWorkPhase; + flushImmediateQueue(); + return !0; +} +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + sourceFiber = createCapturedValue(error, sourceFiber); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); + enqueueUpdate(rootFiber, sourceFiber); + rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); + null !== rootFiber && scheduleCallbackForRoot(rootFiber, 99, 1073741823); +} +function captureCommitPhaseError(sourceFiber, error) { + if (3 === sourceFiber.tag) + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + else + for (var fiber = sourceFiber.return; null !== fiber; ) { + if (3 === fiber.tag) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + break; + } else if (1 === fiber.tag) { var instance = fiber.stateNode; if ( "function" === typeof fiber.type.getDerivedStateFromError || @@ -6531,436 +6160,599 @@ function captureCommitPhaseError(sourceFiber, value) { (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { - sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createCapturedValue(error, sourceFiber); sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); - return; + fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); + null !== fiber && scheduleCallbackForRoot(fiber, 99, 1073741823); + break; } - break; - case 3: - sourceFiber = createCapturedValue(value, sourceFiber); - sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); - return; + } + fiber = fiber.return; } - fiber = fiber.return; - } - 3 === sourceFiber.tag && - ((fiber = createCapturedValue(value, sourceFiber)), - (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), - enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); } -function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(), - expirationTime = void 0; - if (0 === (fiber.mode & 1)) expirationTime = 1073741823; - else if (isWorking && !isCommitting$1) - expirationTime = nextRenderExpirationTime; - else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = 1073741823; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = - 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); - break; - case scheduler.unstable_NormalPriority: - expirationTime = - 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = 1; - break; - default: - invariant( - !1, - "Unknown priority level. This error is likely caused by a bug in React. Please file an issue." - ); - } - null !== nextRoot && - expirationTime === nextRenderExpirationTime && - --expirationTime; - } - priorityLevel === scheduler.unstable_UserBlockingPriority && - (0 === lowestPriorityPendingInteractiveExpirationTime || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) && - (lowestPriorityPendingInteractiveExpirationTime = expirationTime); - return expirationTime; -} -function pingSuspendedRoot(root, thenable, pingTime) { +function pingSuspendedRoot(root, thenable, suspendedTime) { var pingCache = root.pingCache; null !== pingCache && pingCache.delete(thenable); - if (null !== nextRoot && nextRenderExpirationTime === pingTime) - nextRoot = null; - else if ( - ((thenable = root.earliestSuspendedTime), - (pingCache = root.latestSuspendedTime), - 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) - ) { - root.didError = !1; - thenable = root.latestPingedTime; - if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; - findNextExpirationTimeToWorkOn(pingTime, root); - pingTime = root.expirationTime; - 0 !== pingTime && requestWork(root, pingTime); - } + workInProgressRoot === root && renderExpirationTime === suspendedTime + ? prepareFreshStack(root, renderExpirationTime) + : root.lastPendingTime < suspendedTime || + ((thenable = root.pingTime), + (0 !== thenable && thenable < suspendedTime) || + ((root.pingTime = suspendedTime), + (thenable = requestCurrentTime()), + (thenable = inferPriorityFromExpirationTime(thenable, suspendedTime)), + scheduleCallbackForRoot(root, thenable, suspendedTime))); } function resolveRetryThenable(boundaryFiber, thenable) { var retryCache = boundaryFiber.stateNode; null !== retryCache && retryCache.delete(thenable); - thenable = requestCurrentTime(); - thenable = computeExpirationForFiber(thenable, boundaryFiber); - boundaryFiber = scheduleWorkToRoot(boundaryFiber, thenable); + retryCache = requestCurrentTime(); + thenable = computeExpirationForFiber(retryCache, boundaryFiber); + retryCache = inferPriorityFromExpirationTime(retryCache, thenable); + boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); null !== boundaryFiber && - (markPendingPriorityLevel(boundaryFiber, thenable), - (thenable = boundaryFiber.expirationTime), - 0 !== thenable && requestWork(boundaryFiber, thenable)); + scheduleCallbackForRoot(boundaryFiber, retryCache, thenable); } -function scheduleWorkToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); - var alternate = fiber.alternate; - null !== alternate && - alternate.expirationTime < expirationTime && - (alternate.expirationTime = expirationTime); - var node = fiber.return, - root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; - else - for (; null !== node; ) { - alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); - null !== alternate && - alternate.childExpirationTime < expirationTime && - (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { - root = node.stateNode; - break; - } - node = node.return; - } - return root; -} -function scheduleWork(fiber, expirationTime) { - fiber = scheduleWorkToRoot(fiber, expirationTime); - null !== fiber && - (!isWorking && - 0 !== nextRenderExpirationTime && - expirationTime > nextRenderExpirationTime && - resetStack(), - markPendingPriorityLevel(fiber, expirationTime), - (isWorking && !isCommitting$1 && nextRoot === fiber) || - requestWork(fiber, fiber.expirationTime), - nestedUpdateCount > NESTED_UPDATE_LIMIT && - ((nestedUpdateCount = 0), - invariant( - !1, - "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." - ))); -} -var firstScheduledRoot = null, - lastScheduledRoot = null, - callbackExpirationTime = 0, - callbackID = void 0, - isRendering = !1, - nextFlushedRoot = null, - nextFlushedExpirationTime = 0, - lowestPriorityPendingInteractiveExpirationTime = 0, - hasUnhandledError = !1, - unhandledError = null, - isBatchingUpdates = !1, - isUnbatchingUpdates = !1, - completedBatches = null, - originalStartTimeMs = now$1(), - currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), - currentSchedulerTime = currentRendererTime, - NESTED_UPDATE_LIMIT = 50, - nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null; -function recomputeCurrentRendererTime() { - currentRendererTime = - 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); -} -function scheduleCallbackWithExpirationTime(root, expirationTime) { - if (0 !== callbackExpirationTime) { - if (expirationTime < callbackExpirationTime) return; - null !== callbackID && - ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); - } - callbackExpirationTime = expirationTime; - root = now$1() - originalStartTimeMs; - callbackID = scheduleDeferredCallback$1(performAsyncWork, { - timeout: 10 * (1073741822 - expirationTime) - root - }); -} -function onSuspend( - root, - finishedWork, - suspendedExpirationTime, - rootExpirationTime, - msUntilTimeout -) { - root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || frameDeadline <= now$1() - ? 0 < msUntilTimeout && - (root.timeoutHandle = scheduleTimeout( - onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), - msUntilTimeout - )) - : ((root.pendingCommitExpirationTime = suspendedExpirationTime), - (root.finishedWork = finishedWork)); -} -function onTimeout(root, finishedWork, suspendedExpirationTime) { - root.pendingCommitExpirationTime = suspendedExpirationTime; - root.finishedWork = finishedWork; - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); - nextFlushedRoot = root; - nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); -} -function onCommit(root, expirationTime) { - root.expirationTime = expirationTime; - root.finishedWork = null; -} -function requestCurrentTime() { - if (isRendering) return currentSchedulerTime; - findHighestPriorityRoot(); - if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - return currentSchedulerTime; -} -function requestWork(root, expirationTime) { - null === root.nextScheduledRoot - ? ((root.expirationTime = expirationTime), - null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = root), - (root.nextScheduledRoot = root)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) - : expirationTime > root.expirationTime && - (root.expirationTime = expirationTime); - isRendering || - (isBatchingUpdates - ? isUnbatchingUpdates && - ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1073741823), - performWorkOnRoot(root, 1073741823, !1)) - : 1073741823 === expirationTime - ? performWork(1073741823, !1) - : scheduleCallbackWithExpirationTime(root, expirationTime)); -} -function findHighestPriorityRoot() { - var highestPriorityWork = 0, - highestPriorityRoot = null; - if (null !== lastScheduledRoot) - for ( - var previousScheduledRoot = lastScheduledRoot, root = firstScheduledRoot; - null !== root; - - ) { - var remainingExpirationTime = root.expirationTime; - if (0 === remainingExpirationTime) { - invariant( - null !== previousScheduledRoot && null !== lastScheduledRoot, - "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." +var beginWork$$1 = void 0; +beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { + var updateExpirationTime = workInProgress.expirationTime; + if (null !== current$$1) + if ( + current$$1.memoizedProps !== workInProgress.pendingProps || + didPerformWorkStackCursor.current + ) + didReceiveUpdate = !0; + else { + if (updateExpirationTime < renderExpirationTime) { + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ); + break; + case 10: + pushProvider(workInProgress, workInProgress.memoizedProps.value); + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + return null !== workInProgress ? workInProgress.sibling : null; + } + } + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime ); - if (root === root.nextScheduledRoot) { - firstScheduledRoot = lastScheduledRoot = root.nextScheduledRoot = null; - break; - } else if (root === firstScheduledRoot) - (firstScheduledRoot = remainingExpirationTime = - root.nextScheduledRoot), - (lastScheduledRoot.nextScheduledRoot = remainingExpirationTime), - (root.nextScheduledRoot = null); - else if (root === lastScheduledRoot) { - lastScheduledRoot = previousScheduledRoot; - lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; - root.nextScheduledRoot = null; - break; - } else - (previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot), - (root.nextScheduledRoot = null); - root = previousScheduledRoot.nextScheduledRoot; - } else { - remainingExpirationTime > highestPriorityWork && - ((highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root)); - if (root === lastScheduledRoot) break; - if (1073741823 === highestPriorityWork) break; - previousScheduledRoot = root; - root = root.nextScheduledRoot; } } - nextFlushedRoot = highestPriorityRoot; - nextFlushedExpirationTime = highestPriorityWork; -} -function performAsyncWork(didTimeout) { - if (didTimeout && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - didTimeout = firstScheduledRoot; - do { - var expirationTime = didTimeout.expirationTime; - 0 !== expirationTime && - currentRendererTime <= expirationTime && - (didTimeout.nextExpirationTimeToWorkOn = currentRendererTime); - didTimeout = didTimeout.nextScheduledRoot; - } while (didTimeout !== firstScheduledRoot); - } - performWork(0, !0); -} -function performWork(minExpirationTime, isYieldy) { - findHighestPriorityRoot(); - if (isYieldy) - for ( - recomputeCurrentRendererTime(), - currentSchedulerTime = currentRendererTime; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !( - frameDeadline <= now$1() && - currentRendererTime > nextFlushedExpirationTime + else didReceiveUpdate = !1; + workInProgress.expirationTime = 0; + switch (workInProgress.tag) { + case 2: + updateExpirationTime = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + var context = getMaskedContext( + workInProgress, + contextStackCursor.current ); - - ) - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ), - findHighestPriorityRoot(), - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - else - for ( - ; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; - - ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), - findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); - 0 !== nextFlushedExpirationTime && - scheduleCallbackWithExpirationTime( - nextFlushedRoot, - nextFlushedExpirationTime - ); - nestedUpdateCount = 0; - lastCommittedRootDuringThisBatch = null; - if (null !== completedBatches) - for ( - minExpirationTime = completedBatches, - completedBatches = null, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ - ) { - var batch = minExpirationTime[isYieldy]; - try { - batch._onComplete(); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); + prepareToReadContext(workInProgress, renderExpirationTime); + context = renderWithHooks( + null, + workInProgress, + updateExpirationTime, + current$$1, + context, + renderExpirationTime + ); + workInProgress.effectTag |= 1; + if ( + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof + ) { + workInProgress.tag = 1; + resetHooks(); + if (isContextProvider(updateExpirationTime)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + workInProgress.memoizedState = + null !== context.state && void 0 !== context.state + ? context.state + : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current$$1, + renderExpirationTime + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + hasContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 0), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), + (workInProgress = workInProgress.child); + return workInProgress; + case 16: + context = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + context = readLazyComponentType(context); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current$$1 = resolveDefaultProps(context, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + context, + current$$1, + renderExpirationTime + ); + break; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + context, + current$$1, + renderExpirationTime + ); + break; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + context, + current$$1, + renderExpirationTime + ); + break; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + context, + resolveDefaultProps(context.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break; + default: + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + context + + ". Lazy element type must resolve to a class or function." + ); } - } - if (hasUnhandledError) - throw ((minExpirationTime = unhandledError), - (unhandledError = null), - (hasUnhandledError = !1), - minExpirationTime); -} -function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - isRendering = !0; - if (isYieldy) { - var _finishedWork = root.finishedWork; - null !== _finishedWork - ? completeRoot(root, _finishedWork, expirationTime) - : ((root.finishedWork = null), - (_finishedWork = root.timeoutHandle), - -1 !== _finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), - renderRoot(root, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - (frameDeadline <= now$1() - ? (root.finishedWork = _finishedWork) - : completeRoot(root, _finishedWork, expirationTime))); - } else - (_finishedWork = root.finishedWork), - null !== _finishedWork - ? completeRoot(root, _finishedWork, expirationTime) - : ((root.finishedWork = null), - (_finishedWork = root.timeoutHandle), - -1 !== _finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), - renderRoot(root, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - completeRoot(root, _finishedWork, expirationTime)); - isRendering = !1; -} -function completeRoot(root, finishedWork, expirationTime) { - var firstBatch = root.firstBatch; - if ( - null !== firstBatch && - firstBatch._expirationTime >= expirationTime && - (null === completedBatches - ? (completedBatches = [firstBatch]) - : completedBatches.push(firstBatch), - firstBatch._defer) - ) { - root.finishedWork = finishedWork; - root.expirationTime = 0; - return; + return workInProgress; + case 0: + return ( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateFunctionComponent( + current$$1, + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ) + ); + case 1: + return ( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateClassComponent( + current$$1, + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ) + ); + case 3: + pushHostRootContext(workInProgress); + updateExpirationTime = workInProgress.updateQueue; + if (null === updateExpirationTime) + throw ReactError( + "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." + ); + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; + processUpdateQueue( + workInProgress, + updateExpirationTime, + workInProgress.pendingProps, + null, + renderExpirationTime + ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context + ? (workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + )) + : (reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child)); + return workInProgress; + case 5: + return ( + pushHostContext(workInProgress), + null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), + (updateExpirationTime = workInProgress.pendingProps.children), + markRef(current$$1, workInProgress), + reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + workInProgress.child + ); + case 6: + return ( + null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), + null + ); + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + case 4: + return ( + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ), + (updateExpirationTime = workInProgress.pendingProps), + null === current$$1 + ? (workInProgress.child = reconcileChildFibers( + workInProgress, + null, + updateExpirationTime, + renderExpirationTime + )) + : reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + workInProgress.child + ); + case 11: + return ( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateForwardRef( + current$$1, + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ) + ); + case 7: + return ( + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps, + renderExpirationTime + ), + workInProgress.child + ); + case 8: + return ( + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps.children, + renderExpirationTime + ), + workInProgress.child + ); + case 12: + return ( + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps.children, + renderExpirationTime + ), + workInProgress.child + ); + case 10: + a: { + updateExpirationTime = workInProgress.type._context; + context = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + hasContext = context.value; + pushProvider(workInProgress, hasContext); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + hasContext = is(oldValue, hasContext) + ? 0 + : ("function" === typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + hasContext + ) + : 1073741823) | 0; + if (0 === hasContext) { + if ( + getDerivedStateFromProps.children === context.children && + !didPerformWorkStackCursor.current + ) { + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + break a; + } + } else + for ( + oldValue = workInProgress.child, + null !== oldValue && (oldValue.return = workInProgress); + null !== oldValue; + + ) { + var list = oldValue.contextDependencies; + if (null !== list) { + getDerivedStateFromProps = oldValue.child; + for (var dependency = list.first; null !== dependency; ) { + if ( + dependency.context === updateExpirationTime && + 0 !== (dependency.observedBits & hasContext) + ) { + 1 === oldValue.tag && + ((dependency = createUpdate(renderExpirationTime)), + (dependency.tag = 2), + enqueueUpdate(oldValue, dependency)); + oldValue.expirationTime < renderExpirationTime && + (oldValue.expirationTime = renderExpirationTime); + dependency = oldValue.alternate; + null !== dependency && + dependency.expirationTime < renderExpirationTime && + (dependency.expirationTime = renderExpirationTime); + dependency = renderExpirationTime; + for (var node = oldValue.return; null !== node; ) { + var alternate = node.alternate; + if (node.childExpirationTime < dependency) + (node.childExpirationTime = dependency), + null !== alternate && + alternate.childExpirationTime < dependency && + (alternate.childExpirationTime = dependency); + else if ( + null !== alternate && + alternate.childExpirationTime < dependency + ) + alternate.childExpirationTime = dependency; + else break; + node = node.return; + } + list.expirationTime < renderExpirationTime && + (list.expirationTime = renderExpirationTime); + break; + } + dependency = dependency.next; + } + } else + getDerivedStateFromProps = + 10 === oldValue.tag + ? oldValue.type === workInProgress.type + ? null + : oldValue.child + : oldValue.child; + if (null !== getDerivedStateFromProps) + getDerivedStateFromProps.return = oldValue; + else + for ( + getDerivedStateFromProps = oldValue; + null !== getDerivedStateFromProps; + + ) { + if (getDerivedStateFromProps === workInProgress) { + getDerivedStateFromProps = null; + break; + } + oldValue = getDerivedStateFromProps.sibling; + if (null !== oldValue) { + oldValue.return = getDerivedStateFromProps.return; + getDerivedStateFromProps = oldValue; + break; + } + getDerivedStateFromProps = getDerivedStateFromProps.return; + } + oldValue = getDerivedStateFromProps; + } + } + reconcileChildren( + current$$1, + workInProgress, + context.children, + renderExpirationTime + ); + workInProgress = workInProgress.child; + } + return workInProgress; + case 9: + return ( + (context = workInProgress.type), + (hasContext = workInProgress.pendingProps), + (updateExpirationTime = hasContext.children), + prepareToReadContext(workInProgress, renderExpirationTime), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(context)), + (workInProgress.effectTag |= 1), + reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + workInProgress.child + ); + case 14: + return ( + (context = workInProgress.type), + (hasContext = resolveDefaultProps( + context, + workInProgress.pendingProps + )), + (hasContext = resolveDefaultProps(context.type, hasContext)), + updateMemoComponent( + current$$1, + workInProgress, + context, + hasContext, + updateExpirationTime, + renderExpirationTime + ) + ); + case 15: + return updateSimpleMemoComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + updateExpirationTime, + renderExpirationTime + ); + case 17: + return ( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + (workInProgress.tag = 1), + isContextProvider(updateExpirationTime) + ? ((current$$1 = !0), pushContextProvider(workInProgress)) + : (current$$1 = !1), + prepareToReadContext(workInProgress, renderExpirationTime), + constructClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime + ) + ); } - root.finishedWork = null; - root === lastCommittedRootDuringThisBatch - ? nestedUpdateCount++ - : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); - } + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); -} -function onUncaughtError(error) { - invariant( - null !== nextFlushedRoot, - "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." - ); - nextFlushedRoot.expirationTime = 0; - hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); -} +}; function findHostInstance(component) { var fiber = component._reactInternalFiber; - void 0 === fiber && - ("function" === typeof component.render - ? invariant(!1, "Unable to find node on an unmounted component.") - : invariant( - !1, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - )); + if (void 0 === fiber) { + if ("function" === typeof component.render) + throw ReactError("Unable to find node on an unmounted component."); + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } component = findCurrentHostFiber(fiber); return null === component ? null : component.stateNode; } @@ -6972,10 +6764,13 @@ function updateContainer(element, container, parentComponent, callback) { a: if (parentComponent) { parentComponent = parentComponent._reactInternalFiber; b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); + if ( + 2 !== isFiberMountedImpl(parentComponent) || + 1 !== parentComponent.tag + ) + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); var parentContext = parentComponent; do { switch (parentContext.tag) { @@ -6992,11 +6787,9 @@ function updateContainer(element, container, parentComponent, callback) { } parentContext = parentContext.return; } while (null !== parentContext); - invariant( - !1, + throw ReactError( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); - parentContext = void 0; } if (1 === parentComponent.tag) { var Component = parentComponent.type; @@ -7021,7 +6814,7 @@ function updateContainer(element, container, parentComponent, callback) { null !== container && (callback.callback = container); flushPassiveEffects(); enqueueUpdate(currentTime, callback); - scheduleWork(currentTime, current$$1); + scheduleUpdateOnFiber(currentTime, current$$1); return current$$1; } function createPortal(children, containerInfo, implementation) { @@ -7056,7 +6849,9 @@ function _inherits(subClass, superClass) { } var getInspectorDataForViewTag = void 0; getInspectorDataForViewTag = function() { - invariant(!1, "getInspectorDataForViewTag() is not available in production"); + throw ReactError( + "getInspectorDataForViewTag() is not available in production" + ); }; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7072,21 +6867,18 @@ function findNodeHandle(componentOrHandle) { : componentOrHandle._nativeTag; } _batchedUpdatesImpl = function(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; + if (0 !== workPhase) return fn(a); + workPhase = 1; try { return fn(a); } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1073741823, !1); + (workPhase = 0), flushImmediateQueue(); } }; _flushInteractiveUpdatesImpl = function() { - isRendering || - 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), - (lowestPriorityPendingInteractiveExpirationTime = 0)); + workPhase !== RenderPhase && + workPhase !== CommitPhase && + flushPendingDiscreteUpdates(); }; var roots = new Map(), ReactNativeRenderer = { @@ -7113,35 +6905,67 @@ var roots = new Map(), TextInputState.focusTextInput(findNodeHandle(this)); }; ReactNativeComponent.prototype.measure = function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureLayout = function( relativeToNativeNode, onSuccess, onFail ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { + if (null != maybeInstance && !maybeInstance.canonical) { var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; maybeInstance = @@ -7182,30 +7006,10 @@ var roots = new Map(), render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = createFiber(3, null, null, 0); - var root$jscomp$0 = { - current: root, - containerInfo: containerTag, - pendingChildren: null, - pingCache: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: !1, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null - }; - root = root.stateNode = root$jscomp$0; + root = new FiberRootNode(containerTag, !1); + var uninitializedFiber = createFiber(3, null, null, 0); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -7244,31 +7048,63 @@ var roots = new Map(), NativeMethodsMixin: (function(findNodeHandle, findHostInstance) { return { measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }, setNativeProps: function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { + if (null != maybeInstance && !maybeInstance.canonical) { var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; maybeInstance = @@ -7306,7 +7142,10 @@ var roots = new Map(), var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: null, overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { fiber = findCurrentHostFiber(fiber); @@ -7323,7 +7162,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.8.3", + version: "16.8.6", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js index 3490e98d5..5a356fca8 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js @@ -19,30 +19,93 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), + Scheduler = require("scheduler"), tracing = require("scheduler/tracing"), - scheduler = require("scheduler"), ExceptionsManager = require("ExceptionsManager"); -function invariant(condition, format, a, b, c, d, e, f) { - if (!condition) { - condition = void 0; - if (void 0 === format) - condition = Error( - "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." - ); - else { - var args = [a, b, c, d, e, f], - argIndex = 0; - condition = Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - condition.name = "Invariant Violation"; - } - condition.framesToPop = 1; - throw condition; - } +function ReactError(message) { + message = Error(message); + message.name = "Invariant Violation"; + return message; } +var eventPluginOrder = null, + namesToPlugins = {}; +function recomputePluginOrdering() { + if (eventPluginOrder) + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName], + pluginIndex = eventPluginOrder.indexOf(pluginName); + if (!(-1 < pluginIndex)) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." + ); + if (!plugins[pluginIndex]) { + if (!pluginModule.extractEvents) + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); + plugins[pluginIndex] = pluginModule; + pluginIndex = pluginModule.eventTypes; + for (var eventName in pluginIndex) { + var JSCompiler_inline_result = void 0; + var dispatchConfig = pluginIndex[eventName], + pluginModule$jscomp$0 = pluginModule, + eventName$jscomp$0 = eventName; + if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName$jscomp$0 + + "`." + ); + eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + if (phasedRegistrationNames) { + for (JSCompiler_inline_result in phasedRegistrationNames) + phasedRegistrationNames.hasOwnProperty( + JSCompiler_inline_result + ) && + publishRegistrationName( + phasedRegistrationNames[JSCompiler_inline_result], + pluginModule$jscomp$0, + eventName$jscomp$0 + ); + JSCompiler_inline_result = !0; + } else + dispatchConfig.registrationName + ? (publishRegistrationName( + dispatchConfig.registrationName, + pluginModule$jscomp$0, + eventName$jscomp$0 + ), + (JSCompiler_inline_result = !0)) + : (JSCompiler_inline_result = !1); + if (!JSCompiler_inline_result) + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); + } + } + } +} +function publishRegistrationName(registrationName, pluginModule) { + if (registrationNameModules[registrationName]) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); + registrationNameModules[registrationName] = pluginModule; +} +var plugins = [], + eventNameDispatchConfigs = {}, + registrationNameModules = {}; function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -84,88 +147,13 @@ function invokeGuardedCallbackAndCatchFirstError( hasError = !1; caughtError = null; } else - invariant( - !1, + throw ReactError( "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ), - (error = void 0); + ); hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); } } -var eventPluginOrder = null, - namesToPlugins = {}; -function recomputePluginOrdering() { - if (eventPluginOrder) - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName], - pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - -1 < pluginIndex, - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.", - pluginName - ); - if (!plugins[pluginIndex]) { - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.", - pluginName - ); - plugins[pluginIndex] = pluginModule; - pluginIndex = pluginModule.eventTypes; - for (var eventName in pluginIndex) { - var JSCompiler_inline_result = void 0; - var dispatchConfig = pluginIndex[eventName], - pluginModule$jscomp$0 = pluginModule, - eventName$jscomp$0 = eventName; - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0), - "EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.", - eventName$jscomp$0 - ); - eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - if (phasedRegistrationNames) { - for (JSCompiler_inline_result in phasedRegistrationNames) - phasedRegistrationNames.hasOwnProperty( - JSCompiler_inline_result - ) && - publishRegistrationName( - phasedRegistrationNames[JSCompiler_inline_result], - pluginModule$jscomp$0, - eventName$jscomp$0 - ); - JSCompiler_inline_result = !0; - } else - dispatchConfig.registrationName - ? (publishRegistrationName( - dispatchConfig.registrationName, - pluginModule$jscomp$0, - eventName$jscomp$0 - ), - (JSCompiler_inline_result = !0)) - : (JSCompiler_inline_result = !1); - invariant( - JSCompiler_inline_result, - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); - } - } - } -} -function publishRegistrationName(registrationName, pluginModule) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.", - registrationName - ); - registrationNameModules[registrationName] = pluginModule; -} -var plugins = [], - eventNameDispatchConfigs = {}, - registrationNameModules = {}, - getFiberCurrentPropsFromNode = null, +var getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; function executeDispatch(event, listener, inst) { @@ -177,10 +165,8 @@ function executeDispatch(event, listener, inst) { function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + if (Array.isArray(dispatchListener)) + throw ReactError("executeDirectDispatch(...): Invalid `event`."); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -191,10 +177,10 @@ function executeDirectDispatch(event) { return dispatchListener; } function accumulateInto(current, next) { - invariant( - null != next, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); if (null == current) return next; if (Array.isArray(current)) { if (Array.isArray(next)) return current.push.apply(current, next), current; @@ -228,10 +214,10 @@ function executeDispatchesAndReleaseTopLevel(e) { } var injection = { injectEventPluginOrder: function(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." - ); + if (eventPluginOrder) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); recomputePluginOrdering(); }, @@ -241,15 +227,19 @@ var injection = { for (pluginName in injectedNamesToPlugins) if (injectedNamesToPlugins.hasOwnProperty(pluginName)) { var pluginModule = injectedNamesToPlugins[pluginName]; - (namesToPlugins.hasOwnProperty(pluginName) && - namesToPlugins[pluginName] === pluginModule) || - (invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.", - pluginName - ), - (namesToPlugins[pluginName] = pluginModule), - (isOrderingDirty = !0)); + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + if (namesToPlugins[pluginName]) + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = !0; + } } isOrderingDirty && recomputePluginOrdering(); } @@ -285,12 +275,14 @@ function getListener(inst, registrationName) { inst = !1; } if (inst) return null; - invariant( - !listener || "function" === typeof listener, - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + if (listener && "function" !== typeof listener) + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); return listener; } function getParent(inst) { @@ -451,10 +443,10 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { return new this(dispatchConfig, targetInst, nativeEvent, nativeInst); } function releasePooledEvent(event) { - invariant( - event instanceof this, - "Trying to release an event instance into a pool of a different type." - ); + if (!(event instanceof this)) + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); event.destructor(); 10 > this.eventPool.length && this.eventPool.push(event); } @@ -489,7 +481,7 @@ function timestampForTouch(touch) { } function getTouchIdentifier(_ref) { _ref = _ref.identifier; - invariant(null != _ref, "Touch object is missing identifier."); + if (null == _ref) throw ReactError("Touch object is missing identifier."); return _ref; } function recordTouchStart(touch) { @@ -602,10 +594,10 @@ var ResponderTouchHistoryStore = { touchHistory: touchHistory }; function accumulate(current, next) { - invariant( - null != next, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulate(...): Accumulated items must not be null or undefined." + ); return null == current ? next : Array.isArray(current) @@ -970,11 +962,10 @@ var eventTypes$1 = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + if (!bubbleDispatchConfig && !directDispatchConfig) + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); topLevelType = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -1005,14 +996,10 @@ function getInstanceFromTag(tag) { var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { - if ((target = getInstanceFromNode(target))) { - invariant( - !1, + if (getInstanceFromNode(target)) + throw ReactError( "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." ); - var props = getFiberCurrentPropsFromNode(target.stateNode); - null(target.stateNode, target.type, props); - } } function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); @@ -1060,19 +1047,18 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - if ( - events && - (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ), - hasRethrowError) - ) - throw ((events = rethrowError), - (hasRethrowError = !1), - (rethrowError = null), - events); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasRethrowError) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); + } }); } RCTEventEmitter.register({ @@ -1119,7 +1105,7 @@ getInstanceFromNode = getInstanceFromTag; getNodeFromInstance = function(inst) { var tag = inst.stateNode._nativeTag; void 0 === tag && (tag = inst.stateNode.canonical._nativeTag); - invariant(tag, "All native instances should have a tag."); + if (!tag) throw ReactError("All native instances should have a tag."); return tag; }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ @@ -1147,8 +1133,11 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, - MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116; +hasSymbol && Symbol.for("react.event_component"); +hasSymbol && Symbol.for("react.event_target"); +hasSymbol && Symbol.for("react.event_target.touch_hit"); +var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1206,80 +1195,83 @@ function isFiberMountedImpl(fiber) { return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { - invariant( - 2 === isFiberMountedImpl(fiber), - "Unable to find node on an unmounted component." - ); + if (2 !== isFiberMountedImpl(fiber)) + throw ReactError("Unable to find node on an unmounted component."); } function findCurrentFiberUsingSlowPath(fiber) { var alternate = fiber.alternate; - if (!alternate) - return ( - (alternate = isFiberMountedImpl(fiber)), - invariant( - 3 !== alternate, - "Unable to find node on an unmounted component." - ), - 1 === alternate ? null : fiber - ); + if (!alternate) { + alternate = isFiberMountedImpl(fiber); + if (3 === alternate) + throw ReactError("Unable to find node on an unmounted component."); + return 1 === alternate ? null : fiber; + } for (var a = fiber, b = alternate; ; ) { - var parentA = a.return, - parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) break; - if (parentA.child === parentB.child) { - for (var child = parentA.child; child; ) { - if (child === a) return assertIsMounted(parentA), fiber; - if (child === b) return assertIsMounted(parentA), alternate; - child = child.sibling; + var parentA = a.return; + if (null === parentA) break; + var parentB = parentA.alternate; + if (null === parentB) { + b = parentA.return; + if (null !== b) { + a = b; + continue; } - invariant(!1, "Unable to find node on an unmounted component."); + break; + } + if (parentA.child === parentB.child) { + for (parentB = parentA.child; parentB; ) { + if (parentB === a) return assertIsMounted(parentA), fiber; + if (parentB === b) return assertIsMounted(parentA), alternate; + parentB = parentB.sibling; + } + throw ReactError("Unable to find node on an unmounted component."); } if (a.return !== b.return) (a = parentA), (b = parentB); else { - child = !1; - for (var _child = parentA.child; _child; ) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentA; b = parentB; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentA; a = parentB; break; } _child = _child.sibling; } - if (!child) { + if (!didFindChild) { for (_child = parentB.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentB; b = parentA; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentB; a = parentA; break; } _child = _child.sibling; } - invariant( - child, - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." - ); + if (!didFindChild) + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." - ); + if (a.alternate !== b) + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + if (3 !== a.tag) + throw ReactError("Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { @@ -1528,86 +1520,72 @@ function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { }; } var ReactNativeFiberHostComponent = (function() { - function ReactNativeFiberHostComponent(tag, viewConfig) { - if (!(this instanceof ReactNativeFiberHostComponent)) - throw new TypeError("Cannot call a class as a function"); - this._nativeTag = tag; - this._children = []; - this.viewConfig = viewConfig; - } - ReactNativeFiberHostComponent.prototype.blur = function() { - TextInputState.blurTextInput(this._nativeTag); - }; - ReactNativeFiberHostComponent.prototype.focus = function() { - TextInputState.focusTextInput(this._nativeTag); - }; - ReactNativeFiberHostComponent.prototype.measure = function(callback) { - UIManager.measure( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; - ReactNativeFiberHostComponent.prototype.measureInWindow = function( - callback - ) { - UIManager.measureInWindow( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; - ReactNativeFiberHostComponent.prototype.measureLayout = function( - relativeToNativeNode, - onSuccess, - onFail - ) { + function ReactNativeFiberHostComponent(tag, viewConfig) { + if (!(this instanceof ReactNativeFiberHostComponent)) + throw new TypeError("Cannot call a class as a function"); + this._nativeTag = tag; + this._children = []; + this.viewConfig = viewConfig; + } + ReactNativeFiberHostComponent.prototype.blur = function() { + TextInputState.blurTextInput(this._nativeTag); + }; + ReactNativeFiberHostComponent.prototype.focus = function() { + TextInputState.focusTextInput(this._nativeTag); + }; + ReactNativeFiberHostComponent.prototype.measure = function(callback) { + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + ReactNativeFiberHostComponent.prototype.measureInWindow = function(callback) { + UIManager.measureInWindow( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + ReactNativeFiberHostComponent.prototype.measureLayout = function( + relativeToNativeNode, + onSuccess, + onFail + ) { + var relativeNode = void 0; + "number" === typeof relativeToNativeNode + ? (relativeNode = relativeToNativeNode) + : relativeToNativeNode._nativeTag + ? (relativeNode = relativeToNativeNode._nativeTag) + : relativeToNativeNode.canonical && + relativeToNativeNode.canonical._nativeTag && + (relativeNode = relativeToNativeNode.canonical._nativeTag); + null != relativeNode && UIManager.measureLayout( this._nativeTag, - relativeToNativeNode, + relativeNode, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); - }; - ReactNativeFiberHostComponent.prototype.setNativeProps = function( - nativeProps - ) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes + }; + ReactNativeFiberHostComponent.prototype.setNativeProps = function( + nativeProps + ) { + nativeProps = diffProperties( + null, + emptyObject, + nativeProps, + this.viewConfig.validAttributes + ); + null != nativeProps && + UIManager.updateView( + this._nativeTag, + this.viewConfig.uiViewClassName, + nativeProps ); - null != nativeProps && - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps - ); - }; - return ReactNativeFiberHostComponent; - })(), - now$1 = - "object" === typeof performance && "function" === typeof performance.now - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }, - scheduledCallback = null, - frameDeadline = 0; -function setTimeoutCallback() { - frameDeadline = now$1() + 5; - var callback = scheduledCallback; - scheduledCallback = null; - null !== callback && callback(); -} -function scheduleDeferredCallback$1(callback) { - scheduledCallback = callback; - return setTimeout(setTimeoutCallback, 1); -} + }; + return ReactNativeFiberHostComponent; +})(); function shim$1() { - invariant( - !1, + throw ReactError( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } @@ -1638,24 +1616,8 @@ function finalizeInitialChildren(parentInstance) { return !1; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout; -function commitUpdate(instance, updatePayloadTODO, type, oldProps, newProps) { - updatePayloadTODO = instance.viewConfig; - instanceProps[instance._nativeTag] = newProps; - oldProps = diffProperties( - null, - oldProps, - newProps, - updatePayloadTODO.validAttributes - ); - null != oldProps && - UIManager.updateView( - instance._nativeTag, - updatePayloadTODO.uiViewClassName, - oldProps - ); -} -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; + cancelTimeout = clearTimeout, + BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { @@ -1739,10 +1701,10 @@ function popTopLevelContextObject(fiber) { pop(contextStackCursor, fiber); } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." - ); + if (contextStackCursor.current !== emptyContextObject) + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } @@ -1752,12 +1714,13 @@ function processChildContext(fiber, type, parentContext) { if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) - invariant( - contextKey in fiber, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + if (!(contextKey in fiber)) + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { @@ -1776,10 +1739,10 @@ function pushContextProvider(workInProgress) { } function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." - ); + if (!instance) + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); didChange ? ((type = processChildContext(workInProgress, type, previousContext)), (instance.__reactInternalMemoizedMergedChildContext = type), @@ -1814,6 +1777,129 @@ function injectInternals(internals) { } catch (err) {} return !0; } +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, + Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, + Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, + Scheduler_shouldYield = Scheduler.unstable_shouldYield, + Scheduler_now = Scheduler.unstable_now, + Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel, + Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, + Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, + Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, + Scheduler_LowPriority = Scheduler.unstable_LowPriority, + Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; +if ( + null == tracing.__interactionsRef || + null == tracing.__interactionsRef.current +) + throw ReactError( + "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 http://fb.me/react-profiling" + ); +var fakeCallbackNode = {}, + immediateQueue = null, + immediateQueueCallbackNode = null, + isFlushingImmediate = !1, + initialTimeMs = Scheduler_now(), + now = + 1e4 > initialTimeMs + ? Scheduler_now + : function() { + return Scheduler_now() - initialTimeMs; + }; +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return 99; + case Scheduler_UserBlockingPriority: + return 98; + case Scheduler_NormalPriority: + return 97; + case Scheduler_LowPriority: + return 96; + case Scheduler_IdlePriority: + return 95; + default: + throw ReactError("Unknown priority level."); + } +} +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case 99: + return Scheduler_ImmediatePriority; + case 98: + return Scheduler_UserBlockingPriority; + case 97: + return Scheduler_NormalPriority; + case 96: + return Scheduler_LowPriority; + case 95: + return Scheduler_IdlePriority; + default: + throw ReactError("Unknown priority level."); + } +} +function runWithPriority(reactPriorityLevel, fn) { + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(reactPriorityLevel, fn); +} +function scheduleCallback(reactPriorityLevel, callback, options) { + if (99 === reactPriorityLevel) + return ( + null === immediateQueue + ? ((immediateQueue = [callback]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueueImpl + ))) + : immediateQueue.push(callback), + fakeCallbackNode + ); + reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); +} +function flushImmediateQueue() { + null !== immediateQueueCallbackNode && + Scheduler_cancelCallback(immediateQueueCallbackNode); + flushImmediateQueueImpl(); +} +function flushImmediateQueueImpl() { + if (!isFlushingImmediate && null !== immediateQueue) { + isFlushingImmediate = !0; + var i = 0; + try { + for (; i < immediateQueue.length; i++) { + var callback = immediateQueue[i]; + do callback = callback(!0); + while (null !== callback); + } + immediateQueue = null; + } catch (error) { + throw (null !== immediateQueue && + (immediateQueue = immediateQueue.slice(i + 1)), + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueue + ), + error); + } finally { + isFlushingImmediate = !1; + } + } +} +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (1073741823 === expirationTime) return 99; + if (1 === expirationTime) return 95; + currentTime = + 10 * (1073741822 - expirationTime) - 10 * (1073741822 - currentTime); + return 0 >= currentTime + ? 99 + : 250 >= currentTime + ? 98 + : 5250 >= currentTime + ? 97 + : 95; +} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -1944,11 +2030,10 @@ function createFiberFromTypeAndProps( owner = null; break a; } - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (null == type ? type : typeof type) + + "." ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -1990,105 +2075,20 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } -function markPendingPriorityLevel(root, expirationTime) { - root.didError = !1; - var earliestPendingTime = root.earliestPendingTime; - 0 === earliestPendingTime - ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime < expirationTime - ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime > expirationTime && - (root.latestPendingTime = expirationTime); - findNextExpirationTimeToWorkOn(expirationTime, root); -} -function markCommittedPriorityLevels(root, earliestRemainingTime) { - root.didError = !1; - if (0 === earliestRemainingTime) - (root.earliestPendingTime = 0), - (root.latestPendingTime = 0), - (root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0); - else { - earliestRemainingTime < root.latestPingedTime && - (root.latestPingedTime = 0); - var latestPendingTime = root.latestPendingTime; - 0 !== latestPendingTime && - (latestPendingTime > earliestRemainingTime - ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime > earliestRemainingTime && - (root.earliestPendingTime = root.latestPendingTime)); - latestPendingTime = root.earliestSuspendedTime; - 0 === latestPendingTime - ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime < root.latestSuspendedTime - ? ((root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0), - markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime > latestPendingTime && - markPendingPriorityLevel(root, earliestRemainingTime); - } - findNextExpirationTimeToWorkOn(0, root); -} -function hasLowerPriorityWork(root, erroredExpirationTime) { - var latestPendingTime = root.latestPendingTime, - latestSuspendedTime = root.latestSuspendedTime; - root = root.latestPingedTime; - return ( - (0 !== latestPendingTime && latestPendingTime < erroredExpirationTime) || - (0 !== latestSuspendedTime && - latestSuspendedTime < erroredExpirationTime) || - (0 !== root && root < erroredExpirationTime) - ); -} -function markSuspendedPriorityLevel(root, suspendedTime) { - root.didError = !1; - root.latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); - var earliestPendingTime = root.earliestPendingTime, - latestPendingTime = root.latestPendingTime; - earliestPendingTime === suspendedTime - ? (root.earliestPendingTime = - latestPendingTime === suspendedTime - ? (root.latestPendingTime = 0) - : latestPendingTime) - : latestPendingTime === suspendedTime && - (root.latestPendingTime = earliestPendingTime); - earliestPendingTime = root.earliestSuspendedTime; - latestPendingTime = root.latestSuspendedTime; - 0 === earliestPendingTime - ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : earliestPendingTime < suspendedTime - ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime > suspendedTime && - (root.latestSuspendedTime = suspendedTime); - findNextExpirationTimeToWorkOn(suspendedTime, root); -} -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestPendingTime = root.earliestPendingTime; - root = root.earliestSuspendedTime; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); - return renderExpirationTime; -} -function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { - var earliestSuspendedTime = root.earliestSuspendedTime, - latestSuspendedTime = root.latestSuspendedTime, - earliestPendingTime = root.earliestPendingTime, - latestPingedTime = root.latestPingedTime; - earliestPendingTime = - 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; - 0 === earliestPendingTime && - (0 === completedExpirationTime || - latestSuspendedTime < completedExpirationTime) && - (earliestPendingTime = latestSuspendedTime); - completedExpirationTime = earliestPendingTime; - 0 !== completedExpirationTime && - earliestSuspendedTime > completedExpirationTime && - (completedExpirationTime = earliestSuspendedTime); - root.nextExpirationTimeToWorkOn = earliestPendingTime; - root.expirationTime = completedExpirationTime; +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pingCache = this.pendingChildren = null; + this.pendingCommitExpirationTime = 0; + this.finishedWork = null; + this.timeoutHandle = -1; + this.pendingContext = this.context = null; + this.hydrate = hydrate; + this.callbackNode = this.firstBatch = null; + this.pingTime = this.lastPendingTime = this.firstPendingTime = this.callbackExpirationTime = 0; + this.interactionThreadID = tracing.unstable_getThreadID(); + this.memoizedInteractions = new Set(); + this.pendingInteractionMap = new Map(); } function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); @@ -2159,6 +2159,285 @@ function readLazyComponentType(lazyComponent) { throw result; } } +var valueCursor = { current: null }, + currentlyRenderingFiber = null, + lastContextDependency = null, + lastContextWithAllBitsObserved = null; +function resetContextDependences() { + lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; +} +function pushProvider(providerFiber, nextValue) { + var context = providerFiber.type._context; + push(valueCursor, context._currentValue, providerFiber); + context._currentValue = nextValue; +} +function popProvider(providerFiber) { + var currentValue = valueCursor.current; + pop(valueCursor, providerFiber); + providerFiber.type._context._currentValue = currentValue; +} +function prepareToReadContext(workInProgress, renderExpirationTime) { + currentlyRenderingFiber = workInProgress; + lastContextWithAllBitsObserved = lastContextDependency = null; + var currentDependencies = workInProgress.contextDependencies; + null !== currentDependencies && + currentDependencies.expirationTime >= renderExpirationTime && + (didReceiveUpdate = !0); + workInProgress.contextDependencies = null; +} +function readContext(context, observedBits) { + if ( + lastContextWithAllBitsObserved !== context && + !1 !== observedBits && + 0 !== observedBits + ) { + if ("number" !== typeof observedBits || 1073741823 === observedBits) + (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); + observedBits = { context: context, observedBits: observedBits, next: null }; + if (null === lastContextDependency) { + if (null === currentlyRenderingFiber) + throw ReactError( + "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()." + ); + lastContextDependency = observedBits; + currentlyRenderingFiber.contextDependencies = { + first: observedBits, + expirationTime: 0 + }; + } else lastContextDependency = lastContextDependency.next = observedBits; + } + return context._currentValue; +} +var hasForceUpdate = !1; +function createUpdateQueue(baseState) { + return { + baseState: baseState, + firstUpdate: null, + lastUpdate: null, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; +} +function cloneUpdateQueue(currentQueue) { + return { + baseState: currentQueue.baseState, + firstUpdate: currentQueue.firstUpdate, + lastUpdate: currentQueue.lastUpdate, + firstCapturedUpdate: null, + lastCapturedUpdate: null, + firstEffect: null, + lastEffect: null, + firstCapturedEffect: null, + lastCapturedEffect: null + }; +} +function createUpdate(expirationTime) { + return { + expirationTime: expirationTime, + tag: 0, + payload: null, + callback: null, + next: null, + nextEffect: null + }; +} +function appendUpdateToQueue(queue, update) { + null === queue.lastUpdate + ? (queue.firstUpdate = queue.lastUpdate = update) + : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); +} +function enqueueUpdate(fiber, update) { + var alternate = fiber.alternate; + if (null === alternate) { + var queue1 = fiber.updateQueue; + var queue2 = null; + null === queue1 && + (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); + } else + (queue1 = fiber.updateQueue), + (queue2 = alternate.updateQueue), + null === queue1 + ? null === queue2 + ? ((queue1 = fiber.updateQueue = createUpdateQueue( + fiber.memoizedState + )), + (queue2 = alternate.updateQueue = createUpdateQueue( + alternate.memoizedState + ))) + : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) + : null === queue2 && + (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); + null === queue2 || queue1 === queue2 + ? appendUpdateToQueue(queue1, update) + : null === queue1.lastUpdate || null === queue2.lastUpdate + ? (appendUpdateToQueue(queue1, update), + appendUpdateToQueue(queue2, update)) + : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); +} +function enqueueCapturedUpdate(workInProgress, update) { + var workInProgressQueue = workInProgress.updateQueue; + workInProgressQueue = + null === workInProgressQueue + ? (workInProgress.updateQueue = createUpdateQueue( + workInProgress.memoizedState + )) + : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); + null === workInProgressQueue.lastCapturedUpdate + ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) + : ((workInProgressQueue.lastCapturedUpdate.next = update), + (workInProgressQueue.lastCapturedUpdate = update)); +} +function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { + var current = workInProgress.alternate; + null !== current && + queue === current.updateQueue && + (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); + return queue; +} +function getStateFromUpdate( + workInProgress, + queue, + update, + prevState, + nextProps, + instance +) { + switch (update.tag) { + case 1: + return ( + (workInProgress = update.payload), + "function" === typeof workInProgress + ? workInProgress.call(instance, prevState, nextProps) + : workInProgress + ); + case 3: + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; + case 0: + workInProgress = update.payload; + nextProps = + "function" === typeof workInProgress + ? workInProgress.call(instance, prevState, nextProps) + : workInProgress; + if (null === nextProps || void 0 === nextProps) break; + return Object.assign({}, prevState, nextProps); + case 2: + hasForceUpdate = !0; + } + return prevState; +} +function processUpdateQueue( + workInProgress, + queue, + props, + instance, + renderExpirationTime +) { + hasForceUpdate = !1; + queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); + for ( + var newBaseState = queue.baseState, + newFirstUpdate = null, + newExpirationTime = 0, + update = queue.firstUpdate, + resultState = newBaseState; + null !== update; + + ) { + var updateExpirationTime = update.expirationTime; + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && + ((newFirstUpdate = update), (newBaseState = resultState)), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : (updateExpirationTime < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = updateExpirationTime), + (resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), + null !== update.callback && + ((workInProgress.effectTag |= 32), + (update.nextEffect = null), + null === queue.lastEffect + ? (queue.firstEffect = queue.lastEffect = update) + : ((queue.lastEffect.nextEffect = update), + (queue.lastEffect = update)))); + update = update.next; + } + updateExpirationTime = null; + for (update = queue.firstCapturedUpdate; null !== update; ) { + var _updateExpirationTime = update.expirationTime; + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && + ((updateExpirationTime = update), + null === newFirstUpdate && (newBaseState = resultState)), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), + null !== update.callback && + ((workInProgress.effectTag |= 32), + (update.nextEffect = null), + null === queue.lastCapturedEffect + ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) + : ((queue.lastCapturedEffect.nextEffect = update), + (queue.lastCapturedEffect = update)))); + update = update.next; + } + null === newFirstUpdate && (queue.lastUpdate = null); + null === updateExpirationTime + ? (queue.lastCapturedUpdate = null) + : (workInProgress.effectTag |= 32); + null === newFirstUpdate && + null === updateExpirationTime && + (newBaseState = resultState); + queue.baseState = newBaseState; + queue.firstUpdate = newFirstUpdate; + queue.firstCapturedUpdate = updateExpirationTime; + workInProgress.expirationTime = newExpirationTime; + workInProgress.memoizedState = resultState; +} +function commitUpdateQueue(finishedWork, finishedQueue, instance) { + null !== finishedQueue.firstCapturedUpdate && + (null !== finishedQueue.lastUpdate && + ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), + (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), + (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} +function commitUpdateEffects(effect, instance) { + for (; null !== effect; ) { + var _callback3 = effect.callback; + if (null !== _callback3) { + effect.callback = null; + var context = instance; + if ("function" !== typeof _callback3) + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + _callback3 + ); + _callback3.call(context); + } + effect = effect.nextEffect; + } +} var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, @@ -2193,30 +2472,30 @@ var classComponentUpdater = { void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternalFiber; var currentTime = requestCurrentTime(); currentTime = computeExpirationForFiber(currentTime, inst); var update = createUpdate(currentTime); - update.tag = ReplaceState; + update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternalFiber; var currentTime = requestCurrentTime(); currentTime = computeExpirationForFiber(currentTime, inst); var update = createUpdate(currentTime); - update.tag = ForceUpdate; + update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); flushPassiveEffects(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleUpdateOnFiber(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2341,17 +2620,19 @@ function coerceRef(returnFiber, current$$1, element) { if (element._owner) { element = element._owner; var inst = void 0; - element && - (invariant( - 1 === element.tag, - "Function components cannot have refs. Did you mean to use React.forwardRef()?" - ), - (inst = element.stateNode)); - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.", - returnFiber - ); + if (element) { + if (1 !== element.tag) + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + inst = element.stateNode; + } + if (!inst) + throw ReactError( + "Missing owner for string ref " + + returnFiber + + ". This error is likely caused by a bug in React. Please file an issue." + ); var stringRef = "" + returnFiber; if ( null !== current$$1 && @@ -2368,27 +2649,27 @@ function coerceRef(returnFiber, current$$1, element) { current$$1._stringRef = stringRef; return current$$1; } - invariant( - "string" === typeof returnFiber, - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) 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://fb.me/react-refs-must-have-owner for more information.", - returnFiber - ); + if ("string" !== typeof returnFiber) + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + if (!element._owner) + throw ReactError( + "Element ref was specified as a string (" + + returnFiber + + ") 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://fb.me/react-refs-must-have-owner for more information." + ); } return returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { - "textarea" !== returnFiber.type && - invariant( - !1, - "Objects are not valid as a React child (found: %s).%s", - "[object Object]" === Object.prototype.toString.call(newChild) - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - "" + if ("textarea" !== returnFiber.type) + throw ReactError( + "Objects are not valid as a React child (found: " + + ("[object Object]" === Object.prototype.toString.call(newChild) + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2732,18 +3013,21 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - if ( - (oldFiber = createChild( - returnFiber, - newChildren[newIdx], - expirationTime - )) - ) - (currentFirstChild = placeChild(oldFiber, currentFirstChild, newIdx)), + (oldFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + )), + null !== oldFiber && + ((currentFirstChild = placeChild( + oldFiber, + currentFirstChild, + newIdx + )), null === previousNewFiber ? (resultingFirstChild = oldFiber) : (previousNewFiber.sibling = oldFiber), - (previousNewFiber = oldFiber); + (previousNewFiber = oldFiber)); return resultingFirstChild; } for ( @@ -2751,20 +3035,19 @@ function ChildReconciler(shouldTrackSideEffects) { newIdx < newChildren.length; newIdx++ ) - if ( - (nextOldFiber = updateFromMap( - oldFiber, - returnFiber, - newIdx, - newChildren[newIdx], - expirationTime - )) - ) - shouldTrackSideEffects && - null !== nextOldFiber.alternate && - oldFiber.delete( - null === nextOldFiber.key ? newIdx : nextOldFiber.key - ), + (nextOldFiber = updateFromMap( + oldFiber, + returnFiber, + newIdx, + newChildren[newIdx], + expirationTime + )), + null !== nextOldFiber && + (shouldTrackSideEffects && + null !== nextOldFiber.alternate && + oldFiber.delete( + null === nextOldFiber.key ? newIdx : nextOldFiber.key + ), (currentFirstChild = placeChild( nextOldFiber, currentFirstChild, @@ -2773,7 +3056,7 @@ function ChildReconciler(shouldTrackSideEffects) { null === previousNewFiber ? (resultingFirstChild = nextOldFiber) : (previousNewFiber.sibling = nextOldFiber), - (previousNewFiber = nextOldFiber); + (previousNewFiber = nextOldFiber)); shouldTrackSideEffects && oldFiber.forEach(function(child) { return deleteChild(returnFiber, child); @@ -2787,15 +3070,13 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - "function" === typeof iteratorFn, - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." - ); + if ("function" !== typeof iteratorFn) + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); newChildrenIterable = iteratorFn.call(newChildrenIterable); - invariant( - null != newChildrenIterable, - "An iterable object provided no iterator." - ); + if (null == newChildrenIterable) + throw ReactError("An iterable object provided no iterator."); for ( var previousNewFiber = (iteratorFn = null), oldFiber = currentFirstChild, @@ -2815,7 +3096,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ); if (null === newFiber) { - oldFiber || (oldFiber = nextOldFiber); + null === oldFiber && (oldFiber = nextOldFiber); break; } shouldTrackSideEffects && @@ -2887,7 +3168,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) + if (isUnkeyedTopLevelFragment.key === isObject) { if ( 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE @@ -2912,14 +3193,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -2955,7 +3232,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== currentFirstChild; ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + if (currentFirstChild.key === isUnkeyedTopLevelFragment) { if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -2975,11 +3252,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren(returnFiber, currentFirstChild); - break; } - else deleteChild(returnFiber, currentFirstChild); + deleteRemainingChildren(returnFiber, currentFirstChild); + break; + } else deleteChild(returnFiber, currentFirstChild); currentFirstChild = currentFirstChild.sibling; } currentFirstChild = createFiberFromPortal( @@ -3033,12 +3309,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (returnFiber.tag) { case 1: case 0: - (expirationTime = returnFiber.type), - invariant( - !1, - "%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.", - expirationTime.displayName || expirationTime.name || "Component" - ); + throw ((returnFiber = returnFiber.type), + ReactError( + (returnFiber.displayName || returnFiber.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + )); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3050,10 +3325,10 @@ var reconcileChildFibers = ChildReconciler(!0), contextFiberStackCursor = { current: NO_CONTEXT }, rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." - ); + if (c === NO_CONTEXT) + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); return c; } function pushHostContainer(fiber, nextRootInstance) { @@ -3099,7 +3374,7 @@ var NoEffect$1 = 0, MountPassive = 64, UnmountPassive = 128, ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, - renderExpirationTime = 0, + renderExpirationTime$1 = 0, currentlyRenderingFiber$1 = null, currentHook = null, nextCurrentHook = null, @@ -3113,9 +3388,8 @@ var NoEffect$1 = 0, renderPhaseUpdates = null, numberOfReRenders = 0; function throwInvalidHookError() { - invariant( - !1, - "Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)" + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3132,7 +3406,7 @@ function renderWithHooks( refOrContext, nextRenderExpirationTime ) { - renderExpirationTime = nextRenderExpirationTime; + renderExpirationTime$1 = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; nextCurrentHook = null !== current ? current.memoizedState : null; ReactCurrentDispatcher$1.current = @@ -3158,20 +3432,20 @@ function renderWithHooks( current.updateQueue = componentUpdateQueue; current.effectTag |= sideEffectTag; current = null !== currentHook && null !== currentHook.next; - renderExpirationTime = 0; + renderExpirationTime$1 = 0; nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; remainingExpirationTime = 0; componentUpdateQueue = null; sideEffectTag = 0; - invariant( - !current, - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." - ); + if (current) + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); return workInProgress; } function resetHooks() { ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - renderExpirationTime = 0; + renderExpirationTime$1 = 0; nextWorkInProgressHook = workInProgressHook = firstWorkInProgressHook = nextCurrentHook = currentHook = currentlyRenderingFiber$1 = null; remainingExpirationTime = 0; componentUpdateQueue = null; @@ -3200,10 +3474,8 @@ function updateWorkInProgressHook() { (currentHook = nextCurrentHook), (nextCurrentHook = null !== currentHook ? currentHook.next : null); else { - invariant( - null !== nextCurrentHook, - "Rendered more hooks than during the previous render." - ); + if (null === nextCurrentHook) + throw ReactError("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; var newHook = { memoizedState: currentHook.memoizedState, @@ -3226,10 +3498,11 @@ function basicStateReducer(state, action) { function updateReducer(reducer) { var hook = updateWorkInProgressHook(), queue = hook.queue; - invariant( - null !== queue, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + if (null === queue) + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + queue.lastRenderedReducer = reducer; if (0 < numberOfReRenders) { var _dispatch = queue.dispatch; if (null !== renderPhaseUpdates) { @@ -3244,8 +3517,7 @@ function updateReducer(reducer) { is(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; hook.baseUpdate === queue.last && (hook.baseState = newState); - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; return [newState, _dispatch]; } } @@ -3264,17 +3536,19 @@ function updateReducer(reducer) { didSkip = !1; do { var updateExpirationTime = _update.expirationTime; - updateExpirationTime < renderExpirationTime + updateExpirationTime < renderExpirationTime$1 ? (didSkip || ((didSkip = !0), (newBaseUpdate = baseUpdate), (firstRenderPhaseUpdate = newState)), updateExpirationTime > remainingExpirationTime && (remainingExpirationTime = updateExpirationTime)) - : (newState = + : (updateExpirationTime < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = updateExpirationTime), + (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action)); + : reducer(newState, _update.action))); baseUpdate = _update; _update = _update.next; } while (null !== _update && _update !== _dispatch); @@ -3284,8 +3558,7 @@ function updateReducer(reducer) { hook.memoizedState = newState; hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; } @@ -3348,10 +3621,10 @@ function imperativeHandleEffect(create, ref) { } function mountDebugValue() {} function dispatchAction(fiber, queue, action) { - invariant( - 25 > numberOfReRenders, - "Too many re-renders. React limits the number of renders to prevent an infinite loop." - ); + if (!(25 > numberOfReRenders)) + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); var alternate = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3360,7 +3633,7 @@ function dispatchAction(fiber, queue, action) { if ( ((didScheduleRenderPhaseUpdate = !0), (fiber = { - expirationTime: renderExpirationTime, + expirationTime: renderExpirationTime$1, action: action, eagerReducer: null, eagerState: null, @@ -3397,10 +3670,10 @@ function dispatchAction(fiber, queue, action) { if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && - ((alternate = queue.eagerReducer), null !== alternate) + ((alternate = queue.lastRenderedReducer), null !== alternate) ) try { - var currentState = queue.eagerState, + var currentState = queue.lastRenderedState, _eagerState = alternate(currentState, action); _update2.eagerReducer = alternate; _update2.eagerState = _eagerState; @@ -3408,7 +3681,7 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleUpdateOnFiber(fiber, currentTime); } } var ContextOnlyDispatcher = { @@ -3463,8 +3736,8 @@ var ContextOnlyDispatcher = { reducer = hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialArg + lastRenderedReducer: reducer, + lastRenderedState: initialArg }; reducer = reducer.dispatch = dispatchAction.bind( null, @@ -3485,8 +3758,8 @@ var ContextOnlyDispatcher = { initialState = hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }; initialState = initialState.dispatch = dispatchAction.bind( null, @@ -3551,6 +3824,7 @@ var ContextOnlyDispatcher = { }, useDebugValue: mountDebugValue }, + now$1 = Scheduler.unstable_now, commitTime = 0, profilerStartTime = -1; function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { @@ -4116,7 +4390,10 @@ function updateSuspenseComponent( nextState = null; var nextDidTimeout = !1; } else - (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextState = { + fallbackExpirationTime: + null !== nextState ? nextState.fallbackExpirationTime : 0 + }), (nextDidTimeout = !0), (workInProgress.effectTag &= -65); if (null === current$$1) @@ -4246,10 +4523,8 @@ function bailoutOnAlreadyFinishedWork( (workInProgress.contextDependencies = current$$1.contextDependencies); profilerStartTime = -1; if (workInProgress.childExpirationTime < renderExpirationTime) return null; - invariant( - null === current$$1 || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + if (null !== current$$1 && workInProgress.child !== current$$1.child) + throw ReactError("Resuming work not yet implemented."); if (null !== workInProgress.child) { current$$1 = workInProgress.child; renderExpirationTime = createWorkInProgress( @@ -4274,849 +4549,6 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime) { - var updateExpirationTime = workInProgress.expirationTime; - if (null !== current$$1) - if ( - current$$1.memoizedProps !== workInProgress.pendingProps || - didPerformWorkStackCursor.current - ) - didReceiveUpdate = !0; - else { - if (updateExpirationTime < renderExpirationTime) { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ); - break; - case 10: - pushProvider(workInProgress, workInProgress.memoizedProps.value); - break; - case 12: - workInProgress.effectTag |= 4; - break; - case 13: - if (null !== workInProgress.memoizedState) { - updateExpirationTime = workInProgress.child.childExpirationTime; - if ( - 0 !== updateExpirationTime && - updateExpirationTime >= renderExpirationTime - ) - return updateSuspenseComponent( - current$$1, - workInProgress, - renderExpirationTime - ); - workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - return null !== workInProgress ? workInProgress.sibling : null; - } - } - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - } - else didReceiveUpdate = !1; - workInProgress.expirationTime = 0; - switch (workInProgress.tag) { - case 2: - updateExpirationTime = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - current$$1 = workInProgress.pendingProps; - var context = getMaskedContext( - workInProgress, - contextStackCursor.current - ); - prepareToReadContext(workInProgress, renderExpirationTime); - context = renderWithHooks( - null, - workInProgress, - updateExpirationTime, - current$$1, - context, - renderExpirationTime - ); - workInProgress.effectTag |= 1; - if ( - "object" === typeof context && - null !== context && - "function" === typeof context.render && - void 0 === context.$$typeof - ) { - workInProgress.tag = 1; - resetHooks(); - if (isContextProvider(updateExpirationTime)) { - var hasContext = !0; - pushContextProvider(workInProgress); - } else hasContext = !1; - workInProgress.memoizedState = - null !== context.state && void 0 !== context.state - ? context.state - : null; - var getDerivedStateFromProps = - updateExpirationTime.getDerivedStateFromProps; - "function" === typeof getDerivedStateFromProps && - applyDerivedStateFromProps( - workInProgress, - updateExpirationTime, - getDerivedStateFromProps, - current$$1 - ); - context.updater = classComponentUpdater; - workInProgress.stateNode = context; - context._reactInternalFiber = workInProgress; - mountClassInstance( - workInProgress, - updateExpirationTime, - current$$1, - renderExpirationTime - ); - workInProgress = finishClassComponent( - null, - workInProgress, - updateExpirationTime, - !0, - hasContext, - renderExpirationTime - ); - } else - (workInProgress.tag = 0), - reconcileChildren( - null, - workInProgress, - context, - renderExpirationTime - ), - (workInProgress = workInProgress.child); - return workInProgress; - case 16: - context = workInProgress.elementType; - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)); - hasContext = workInProgress.pendingProps; - current$$1 = readLazyComponentType(context); - workInProgress.type = current$$1; - context = workInProgress.tag = resolveLazyComponentTag(current$$1); - hasContext = resolveDefaultProps(current$$1, hasContext); - getDerivedStateFromProps = void 0; - switch (context) { - case 0: - getDerivedStateFromProps = updateFunctionComponent( - null, - workInProgress, - current$$1, - hasContext, - renderExpirationTime - ); - break; - case 1: - getDerivedStateFromProps = updateClassComponent( - null, - workInProgress, - current$$1, - hasContext, - renderExpirationTime - ); - break; - case 11: - getDerivedStateFromProps = updateForwardRef( - null, - workInProgress, - current$$1, - hasContext, - renderExpirationTime - ); - break; - case 14: - getDerivedStateFromProps = updateMemoComponent( - null, - workInProgress, - current$$1, - resolveDefaultProps(current$$1.type, hasContext), - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", - current$$1, - "" - ); - } - return getDerivedStateFromProps; - case 0: - return ( - (updateExpirationTime = workInProgress.type), - (context = workInProgress.pendingProps), - (context = - workInProgress.elementType === updateExpirationTime - ? context - : resolveDefaultProps(updateExpirationTime, context)), - updateFunctionComponent( - current$$1, - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ) - ); - case 1: - return ( - (updateExpirationTime = workInProgress.type), - (context = workInProgress.pendingProps), - (context = - workInProgress.elementType === updateExpirationTime - ? context - : resolveDefaultProps(updateExpirationTime, context)), - updateClassComponent( - current$$1, - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ) - ); - case 3: - return ( - pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), - invariant( - null !== updateExpirationTime, - "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." - ), - (context = workInProgress.memoizedState), - (context = null !== context ? context.element : null), - processUpdateQueue( - workInProgress, - updateExpirationTime, - workInProgress.pendingProps, - null, - renderExpirationTime - ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === context - ? (workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )) - : (reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child)), - workInProgress - ); - case 5: - return ( - pushHostContext(workInProgress), - null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), - markRef(current$$1, workInProgress), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child), - workInProgress - ); - case 6: - return ( - null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - null - ); - case 13: - return updateSuspenseComponent( - current$$1, - workInProgress, - renderExpirationTime - ); - case 4: - return ( - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ), - (updateExpirationTime = workInProgress.pendingProps), - null === current$$1 - ? (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - )) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - workInProgress.child - ); - case 11: - return ( - (updateExpirationTime = workInProgress.type), - (context = workInProgress.pendingProps), - (context = - workInProgress.elementType === updateExpirationTime - ? context - : resolveDefaultProps(updateExpirationTime, context)), - updateForwardRef( - current$$1, - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ) - ); - case 7: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps, - renderExpirationTime - ), - workInProgress.child - ); - case 8: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime - ), - workInProgress.child - ); - case 12: - return ( - (workInProgress.effectTag |= 4), - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime - ), - workInProgress.child - ); - case 10: - a: { - updateExpirationTime = workInProgress.type._context; - context = workInProgress.pendingProps; - getDerivedStateFromProps = workInProgress.memoizedProps; - hasContext = context.value; - pushProvider(workInProgress, hasContext); - if (null !== getDerivedStateFromProps) { - var oldValue = getDerivedStateFromProps.value; - hasContext = is(oldValue, hasContext) - ? 0 - : ("function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits( - oldValue, - hasContext - ) - : 1073741823) | 0; - if (0 === hasContext) { - if ( - getDerivedStateFromProps.children === context.children && - !didPerformWorkStackCursor.current - ) { - workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - } else - for ( - oldValue = workInProgress.child, - null !== oldValue && (oldValue.return = workInProgress); - null !== oldValue; - - ) { - var list = oldValue.contextDependencies; - if (null !== list) { - getDerivedStateFromProps = oldValue.child; - for (var dependency = list.first; null !== dependency; ) { - if ( - dependency.context === updateExpirationTime && - 0 !== (dependency.observedBits & hasContext) - ) { - 1 === oldValue.tag && - ((dependency = createUpdate(renderExpirationTime)), - (dependency.tag = ForceUpdate), - enqueueUpdate(oldValue, dependency)); - oldValue.expirationTime < renderExpirationTime && - (oldValue.expirationTime = renderExpirationTime); - dependency = oldValue.alternate; - null !== dependency && - dependency.expirationTime < renderExpirationTime && - (dependency.expirationTime = renderExpirationTime); - dependency = renderExpirationTime; - for (var node = oldValue.return; null !== node; ) { - var alternate = node.alternate; - if (node.childExpirationTime < dependency) - (node.childExpirationTime = dependency), - null !== alternate && - alternate.childExpirationTime < dependency && - (alternate.childExpirationTime = dependency); - else if ( - null !== alternate && - alternate.childExpirationTime < dependency - ) - alternate.childExpirationTime = dependency; - else break; - node = node.return; - } - list.expirationTime < renderExpirationTime && - (list.expirationTime = renderExpirationTime); - break; - } - dependency = dependency.next; - } - } else - getDerivedStateFromProps = - 10 === oldValue.tag - ? oldValue.type === workInProgress.type - ? null - : oldValue.child - : oldValue.child; - if (null !== getDerivedStateFromProps) - getDerivedStateFromProps.return = oldValue; - else - for ( - getDerivedStateFromProps = oldValue; - null !== getDerivedStateFromProps; - - ) { - if (getDerivedStateFromProps === workInProgress) { - getDerivedStateFromProps = null; - break; - } - oldValue = getDerivedStateFromProps.sibling; - if (null !== oldValue) { - oldValue.return = getDerivedStateFromProps.return; - getDerivedStateFromProps = oldValue; - break; - } - getDerivedStateFromProps = getDerivedStateFromProps.return; - } - oldValue = getDerivedStateFromProps; - } - } - reconcileChildren( - current$$1, - workInProgress, - context.children, - renderExpirationTime - ); - workInProgress = workInProgress.child; - } - return workInProgress; - case 9: - return ( - (context = workInProgress.type), - (hasContext = workInProgress.pendingProps), - (updateExpirationTime = hasContext.children), - prepareToReadContext(workInProgress, renderExpirationTime), - (context = readContext(context, hasContext.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(context)), - (workInProgress.effectTag |= 1), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - workInProgress.child - ); - case 14: - return ( - (context = workInProgress.type), - (hasContext = resolveDefaultProps( - context, - workInProgress.pendingProps - )), - (hasContext = resolveDefaultProps(context.type, hasContext)), - updateMemoComponent( - current$$1, - workInProgress, - context, - hasContext, - updateExpirationTime, - renderExpirationTime - ) - ); - case 15: - return updateSimpleMemoComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - updateExpirationTime, - renderExpirationTime - ); - case 17: - return ( - (updateExpirationTime = workInProgress.type), - (context = workInProgress.pendingProps), - (context = - workInProgress.elementType === updateExpirationTime - ? context - : resolveDefaultProps(updateExpirationTime, context)), - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), - (workInProgress.tag = 1), - isContextProvider(updateExpirationTime) - ? ((current$$1 = !0), pushContextProvider(workInProgress)) - : (current$$1 = !1), - prepareToReadContext(workInProgress, renderExpirationTime), - constructClassInstance( - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ), - mountClassInstance( - workInProgress, - updateExpirationTime, - context, - renderExpirationTime - ), - finishClassComponent( - null, - workInProgress, - updateExpirationTime, - !0, - current$$1, - renderExpirationTime - ) - ); - } - invariant( - !1, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); -} -var valueCursor = { current: null }, - currentlyRenderingFiber = null, - lastContextDependency = null, - lastContextWithAllBitsObserved = null; -function pushProvider(providerFiber, nextValue) { - var context = providerFiber.type._context; - push(valueCursor, context._currentValue, providerFiber); - context._currentValue = nextValue; -} -function popProvider(providerFiber) { - var currentValue = valueCursor.current; - pop(valueCursor, providerFiber); - providerFiber.type._context._currentValue = currentValue; -} -function prepareToReadContext(workInProgress, renderExpirationTime) { - currentlyRenderingFiber = workInProgress; - lastContextWithAllBitsObserved = lastContextDependency = null; - var currentDependencies = workInProgress.contextDependencies; - null !== currentDependencies && - currentDependencies.expirationTime >= renderExpirationTime && - (didReceiveUpdate = !0); - workInProgress.contextDependencies = null; -} -function readContext(context, observedBits) { - if ( - lastContextWithAllBitsObserved !== context && - !1 !== observedBits && - 0 !== observedBits - ) { - if ("number" !== typeof observedBits || 1073741823 === observedBits) - (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); - observedBits = { context: context, observedBits: observedBits, next: null }; - null === lastContextDependency - ? (invariant( - null !== currentlyRenderingFiber, - "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()." - ), - (lastContextDependency = observedBits), - (currentlyRenderingFiber.contextDependencies = { - first: observedBits, - expirationTime: 0 - })) - : (lastContextDependency = lastContextDependency.next = observedBits); - } - return context._currentValue; -} -var UpdateState = 0, - ReplaceState = 1, - ForceUpdate = 2, - CaptureUpdate = 3, - hasForceUpdate = !1; -function createUpdateQueue(baseState) { - return { - baseState: baseState, - firstUpdate: null, - lastUpdate: null, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; -} -function cloneUpdateQueue(currentQueue) { - return { - baseState: currentQueue.baseState, - firstUpdate: currentQueue.firstUpdate, - lastUpdate: currentQueue.lastUpdate, - firstCapturedUpdate: null, - lastCapturedUpdate: null, - firstEffect: null, - lastEffect: null, - firstCapturedEffect: null, - lastCapturedEffect: null - }; -} -function createUpdate(expirationTime) { - return { - expirationTime: expirationTime, - tag: UpdateState, - payload: null, - callback: null, - next: null, - nextEffect: null - }; -} -function appendUpdateToQueue(queue, update) { - null === queue.lastUpdate - ? (queue.firstUpdate = queue.lastUpdate = update) - : ((queue.lastUpdate.next = update), (queue.lastUpdate = update)); -} -function enqueueUpdate(fiber, update) { - var alternate = fiber.alternate; - if (null === alternate) { - var queue1 = fiber.updateQueue; - var queue2 = null; - null === queue1 && - (queue1 = fiber.updateQueue = createUpdateQueue(fiber.memoizedState)); - } else - (queue1 = fiber.updateQueue), - (queue2 = alternate.updateQueue), - null === queue1 - ? null === queue2 - ? ((queue1 = fiber.updateQueue = createUpdateQueue( - fiber.memoizedState - )), - (queue2 = alternate.updateQueue = createUpdateQueue( - alternate.memoizedState - ))) - : (queue1 = fiber.updateQueue = cloneUpdateQueue(queue2)) - : null === queue2 && - (queue2 = alternate.updateQueue = cloneUpdateQueue(queue1)); - null === queue2 || queue1 === queue2 - ? appendUpdateToQueue(queue1, update) - : null === queue1.lastUpdate || null === queue2.lastUpdate - ? (appendUpdateToQueue(queue1, update), - appendUpdateToQueue(queue2, update)) - : (appendUpdateToQueue(queue1, update), (queue2.lastUpdate = update)); -} -function enqueueCapturedUpdate(workInProgress, update) { - var workInProgressQueue = workInProgress.updateQueue; - workInProgressQueue = - null === workInProgressQueue - ? (workInProgress.updateQueue = createUpdateQueue( - workInProgress.memoizedState - )) - : ensureWorkInProgressQueueIsAClone(workInProgress, workInProgressQueue); - null === workInProgressQueue.lastCapturedUpdate - ? (workInProgressQueue.firstCapturedUpdate = workInProgressQueue.lastCapturedUpdate = update) - : ((workInProgressQueue.lastCapturedUpdate.next = update), - (workInProgressQueue.lastCapturedUpdate = update)); -} -function ensureWorkInProgressQueueIsAClone(workInProgress, queue) { - var current = workInProgress.alternate; - null !== current && - queue === current.updateQueue && - (queue = workInProgress.updateQueue = cloneUpdateQueue(queue)); - return queue; -} -function getStateFromUpdate( - workInProgress, - queue, - update, - prevState, - nextProps, - instance -) { - switch (update.tag) { - case ReplaceState: - return ( - (workInProgress = update.payload), - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress - ); - case CaptureUpdate: - workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; - case UpdateState: - workInProgress = update.payload; - nextProps = - "function" === typeof workInProgress - ? workInProgress.call(instance, prevState, nextProps) - : workInProgress; - if (null === nextProps || void 0 === nextProps) break; - return Object.assign({}, prevState, nextProps); - case ForceUpdate: - hasForceUpdate = !0; - } - return prevState; -} -function processUpdateQueue( - workInProgress, - queue, - props, - instance, - renderExpirationTime -) { - hasForceUpdate = !1; - queue = ensureWorkInProgressQueueIsAClone(workInProgress, queue); - for ( - var newBaseState = queue.baseState, - newFirstUpdate = null, - newExpirationTime = 0, - update = queue.firstUpdate, - resultState = newBaseState; - null !== update; - - ) { - var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && - ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastEffect - ? (queue.firstEffect = queue.lastEffect = update) - : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update)))); - update = update.next; - } - updateExpirationTime = null; - for (update = queue.firstCapturedUpdate; null !== update; ) { - var _updateExpirationTime = update.expirationTime; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && - ((updateExpirationTime = update), - null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), - null !== update.callback && - ((workInProgress.effectTag |= 32), - (update.nextEffect = null), - null === queue.lastCapturedEffect - ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) - : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update)))); - update = update.next; - } - null === newFirstUpdate && (queue.lastUpdate = null); - null === updateExpirationTime - ? (queue.lastCapturedUpdate = null) - : (workInProgress.effectTag |= 32); - null === newFirstUpdate && - null === updateExpirationTime && - (newBaseState = resultState); - queue.baseState = newBaseState; - queue.firstUpdate = newFirstUpdate; - queue.firstCapturedUpdate = updateExpirationTime; - workInProgress.expirationTime = newExpirationTime; - workInProgress.memoizedState = resultState; -} -function commitUpdateQueue(finishedWork, finishedQueue, instance) { - null !== finishedQueue.firstCapturedUpdate && - (null !== finishedQueue.lastUpdate && - ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), - (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), - (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - commitUpdateEffects(finishedQueue.firstEffect, instance); - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; -} -function commitUpdateEffects(effect, instance) { - for (; null !== effect; ) { - var _callback3 = effect.callback; - if (null !== _callback3) { - effect.callback = null; - var context = instance; - invariant( - "function" === typeof _callback3, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - _callback3 - ); - _callback3.call(context); - } - effect = effect.nextEffect; - } -} -function createCapturedValue(value, source) { - return { - value: value, - source: source, - stack: getStackByFiberInDevAndProd(source) - }; -} var appendAllChildren = void 0, updateHostContainer = void 0, updateHostComponent$1 = void 0, @@ -5148,6 +4580,178 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { updateHostText$1 = function(current, workInProgress, oldText, newText) { oldText !== newText && (workInProgress.effectTag |= 4); }; +function completeWork(current, workInProgress, renderExpirationTime) { + var newProps = workInProgress.pendingProps; + switch (workInProgress.tag) { + case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 1: + isContextProvider(workInProgress.type) && popContext(workInProgress); + break; + case 3: + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + newProps = workInProgress.stateNode; + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)); + if (null === current || null === current.child) + workInProgress.effectTag &= -3; + updateHostContainer(workInProgress); + break; + case 5: + popHostContext(workInProgress); + renderExpirationTime = requiredContext(rootInstanceStackCursor.current); + var type = workInProgress.type; + if (null !== current && null != workInProgress.stateNode) + updateHostComponent$1( + current, + workInProgress, + type, + newProps, + renderExpirationTime + ), + current.ref !== workInProgress.ref && + (workInProgress.effectTag |= 128); + else if (newProps) { + current = requiredContext(contextStackCursor$1.current); + var tag = allocateTag(), + viewConfig = ReactNativeViewConfigRegistry.get(type), + updatePayload = diffProperties( + null, + emptyObject, + newProps, + viewConfig.validAttributes + ); + UIManager.createView( + tag, + viewConfig.uiViewClassName, + renderExpirationTime, + updatePayload + ); + viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); + instanceCache[tag] = workInProgress; + instanceProps[tag] = newProps; + appendAllChildren(viewConfig, workInProgress, !1, !1); + finalizeInitialChildren( + viewConfig, + type, + newProps, + renderExpirationTime, + current + ) && (workInProgress.effectTag |= 4); + workInProgress.stateNode = viewConfig; + null !== workInProgress.ref && (workInProgress.effectTag |= 128); + } else if (null === workInProgress.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + if (current && null != workInProgress.stateNode) + updateHostText$1( + current, + workInProgress, + current.memoizedProps, + newProps + ); + else { + if ("string" !== typeof newProps && null === workInProgress.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + current = requiredContext(rootInstanceStackCursor.current); + if (!requiredContext(contextStackCursor$1.current).isInAParentText) + throw ReactError( + "Text strings must be rendered within a component." + ); + renderExpirationTime = allocateTag(); + UIManager.createView(renderExpirationTime, "RCTRawText", current, { + text: newProps + }); + instanceCache[renderExpirationTime] = workInProgress; + workInProgress.stateNode = renderExpirationTime; + } + break; + case 11: + break; + case 13: + newProps = workInProgress.memoizedState; + if (0 !== (workInProgress.effectTag & 64)) + return ( + (workInProgress.expirationTime = renderExpirationTime), workInProgress + ); + newProps = null !== newProps; + renderExpirationTime = !1; + null !== current && + ((type = current.memoizedState), + (renderExpirationTime = null !== type), + newProps || + null === type || + ((type = type.fallbackExpirationTime), + type < workInProgressRootMostRecentEventTime && + (workInProgressRootMostRecentEventTime = type), + (current = current.child.sibling), + null !== current && + ((type = workInProgress.firstEffect), + null !== type + ? ((workInProgress.firstEffect = current), + (current.nextEffect = type)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = current), + (current.nextEffect = null)), + (current.effectTag = 8)))); + newProps && + !renderExpirationTime && + 0 !== (workInProgress.mode & 1) && + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); + if (newProps || renderExpirationTime) workInProgress.effectTag |= 4; + break; + case 7: + break; + case 8: + break; + case 12: + break; + case 4: + popHostContainer(workInProgress); + updateHostContainer(workInProgress); + break; + case 10: + popProvider(workInProgress); + break; + case 9: + break; + case 14: + break; + case 17: + isContextProvider(workInProgress.type) && popContext(workInProgress); + break; + case 18: + break; + case 19: + break; + case 20: + break; + default: + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + return null; +} +function createCapturedValue(value, source) { + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; +} function logCapturedError(capturedError) { var componentStack = capturedError.componentStack, error = capturedError.error; @@ -5342,17 +4946,14 @@ function commitPlacement(finishedWork) { } parent = parent.return; } - invariant( - !1, + throw ReactError( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); - parentFiber = void 0; } - var isContainer = (parent = void 0); switch (parentFiber.tag) { case 5: parent = parentFiber.stateNode; - isContainer = !1; + var isContainer = !1; break; case 3: parent = parentFiber.stateNode.containerInfo; @@ -5363,8 +4964,7 @@ function commitPlacement(finishedWork) { isContainer = !0; break; default: - invariant( - !1, + throw ReactError( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } @@ -5395,23 +4995,23 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (5 === node.tag || 6 === node.tag) + if (5 === node.tag || 6 === node.tag) { + var stateNode = node.stateNode; if (parentFiber) - if (isContainer) - invariant( - "number" !== typeof parent, - "Container does not support insertBefore operation" - ); - else { + if (isContainer) { + if ("number" === typeof parent) + throw ReactError( + "Container does not support insertBefore operation" + ); + } else { var parentInstance = parent, - child = node.stateNode, beforeChild = parentFiber, children = parentInstance._children, - index = children.indexOf(child); + index = children.indexOf(stateNode); 0 <= index ? (children.splice(index, 1), (beforeChild = children.indexOf(beforeChild)), - children.splice(beforeChild, 0, child), + children.splice(beforeChild, 0, stateNode), UIManager.manageChildren( parentInstance._nativeTag, [index], @@ -5421,32 +5021,33 @@ function commitPlacement(finishedWork) { [] )) : ((index = children.indexOf(beforeChild)), - children.splice(index, 0, child), + children.splice(index, 0, stateNode), UIManager.manageChildren( parentInstance._nativeTag, [], [], - ["number" === typeof child ? child : child._nativeTag], + [ + "number" === typeof stateNode + ? stateNode + : stateNode._nativeTag + ], [index], [] )); } else isContainer - ? ((parentInstance = node.stateNode), - UIManager.setChildren(parent, [ - "number" === typeof parentInstance - ? parentInstance - : parentInstance._nativeTag - ])) + ? UIManager.setChildren(parent, [ + "number" === typeof stateNode ? stateNode : stateNode._nativeTag + ]) : ((parentInstance = parent), - (child = node.stateNode), - (children = "number" === typeof child ? child : child._nativeTag), + (children = + "number" === typeof stateNode ? stateNode : stateNode._nativeTag), (index = parentInstance._children), - (beforeChild = index.indexOf(child)), + (beforeChild = index.indexOf(stateNode)), 0 <= beforeChild ? (index.splice(beforeChild, 1), - index.push(child), + index.push(stateNode), UIManager.manageChildren( parentInstance._nativeTag, [beforeChild], @@ -5455,7 +5056,7 @@ function commitPlacement(finishedWork) { [], [] )) - : (index.push(child), + : (index.push(stateNode), UIManager.manageChildren( parentInstance._nativeTag, [], @@ -5464,7 +5065,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (4 !== node.tag && null !== node.child) { + } else if (4 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -5490,10 +5091,10 @@ function unmountHostComponents(current$$1) { if (!currentParentIsValid) { currentParentIsValid = node.return; a: for (;;) { - invariant( - null !== currentParentIsValid, - "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === currentParentIsValid) + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); switch (currentParentIsValid.tag) { case 5: currentParent = currentParentIsValid.stateNode; @@ -5581,82 +5182,95 @@ function commitWork(current$$1, finishedWork) { if (null != instance) { var newProps = finishedWork.memoizedProps; current$$1 = null !== current$$1 ? current$$1.memoizedProps : newProps; - var type = finishedWork.type, - updatePayload = finishedWork.updateQueue; + var updatePayload = finishedWork.updateQueue; finishedWork.updateQueue = null; null !== updatePayload && - commitUpdate( - instance, - updatePayload, - type, + ((finishedWork = instance.viewConfig), + (instanceProps[instance._nativeTag] = newProps), + (newProps = diffProperties( + null, current$$1, newProps, - finishedWork - ); + finishedWork.validAttributes + )), + null != newProps && + UIManager.updateView( + instance._nativeTag, + finishedWork.uiViewClassName, + newProps + )); } break; case 6: - invariant( - null !== finishedWork.stateNode, - "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === finishedWork.stateNode) + throw ReactError( + "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + ); UIManager.updateView(finishedWork.stateNode, "RCTRawText", { text: finishedWork.memoizedProps }); break; + case 20: + break; case 3: break; case 12: break; case 13: - instance = finishedWork.memoizedState; - newProps = void 0; - current$$1 = finishedWork; - null === instance - ? (newProps = !1) - : ((newProps = !0), - (current$$1 = finishedWork.child), - 0 === instance.timedOutAt && - (instance.timedOutAt = requestCurrentTime())); - null !== current$$1 && hideOrUnhideAllChildren(current$$1, newProps); - instance = finishedWork.updateQueue; - if (null !== instance) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; - null === retryCache && - (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); - instance.forEach(function(thenable) { - var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - retry = tracing.unstable_wrap(retry); - retryCache.has(thenable) || - (retryCache.add(thenable), thenable.then(retry, retry)); - }); - } + commitSuspenseComponent(finishedWork); break; case 17: break; + case 19: + break; default: - invariant( - !1, + throw ReactError( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } } +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState, + newDidTimeout = void 0, + primaryChildParent = finishedWork; + null === newState + ? (newDidTimeout = !1) + : ((newDidTimeout = !0), + (primaryChildParent = finishedWork.child), + 0 === newState.fallbackExpirationTime && + (newState.fallbackExpirationTime = requestCurrentTime() - 500)); + null !== primaryChildParent && + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + newState = finishedWork.updateQueue; + if (null !== newState) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + null === retryCache && + (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); + newState.forEach(function(thenable) { + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + ((retry = tracing.unstable_wrap(retry)), + retryCache.add(thenable), + thenable.then(retry, retry)); + }); + } +} var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); - expirationTime.tag = CaptureUpdate; + expirationTime.tag = 3; expirationTime.payload = { element: null }; var error = errorInfo.value; expirationTime.callback = function() { - onUncaughtError(error); + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); logError(fiber, errorInfo); }; return expirationTime; } function createClassErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); - expirationTime.tag = CaptureUpdate; + expirationTime.tag = 3; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { var error$jscomp$0 = errorInfo.value; @@ -5681,156 +5295,6 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { }); return expirationTime; } -function throwException( - root, - returnFiber, - sourceFiber, - value, - renderExpirationTime -) { - sourceFiber.effectTag |= 1024; - sourceFiber.firstEffect = sourceFiber.lastEffect = null; - if ( - null !== value && - "object" === typeof value && - "function" === typeof value.then - ) { - var thenable = value; - value = returnFiber; - var earliestTimeoutMs = -1, - startTimeMs = -1; - do { - if (13 === value.tag) { - var current$$1 = value.alternate; - if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), null !== current$$1) - ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); - break; - } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; - else if (-1 === earliestTimeoutMs || current$$1 < earliestTimeoutMs) - earliestTimeoutMs = current$$1; - } - value = value.return; - } while (null !== value); - value = returnFiber; - do { - if ((current$$1 = 13 === value.tag)) - current$$1 = - void 0 === value.memoizedProps.fallback - ? !1 - : null === value.memoizedState; - if (current$$1) { - returnFiber = value.updateQueue; - null === returnFiber - ? ((returnFiber = new Set()), - returnFiber.add(thenable), - (value.updateQueue = returnFiber)) - : returnFiber.add(thenable); - if (0 === (value.mode & 1)) { - value.effectTag |= 64; - sourceFiber.effectTag &= -1957; - 1 === sourceFiber.tag && - (null === sourceFiber.alternate - ? (sourceFiber.tag = 17) - : ((renderExpirationTime = createUpdate(1073741823)), - (renderExpirationTime.tag = ForceUpdate), - enqueueUpdate(sourceFiber, renderExpirationTime))); - sourceFiber.expirationTime = 1073741823; - return; - } - sourceFiber = root; - returnFiber = renderExpirationTime; - var pingCache = sourceFiber.pingCache; - null === pingCache - ? ((pingCache = sourceFiber.pingCache = new PossiblyWeakMap()), - (current$$1 = new Set()), - pingCache.set(thenable, current$$1)) - : ((current$$1 = pingCache.get(thenable)), - void 0 === current$$1 && - ((current$$1 = new Set()), pingCache.set(thenable, current$$1))); - current$$1.has(returnFiber) || - (current$$1.add(returnFiber), - (sourceFiber = pingSuspendedRoot.bind( - null, - sourceFiber, - thenable, - returnFiber - )), - (sourceFiber = tracing.unstable_wrap(sourceFiber)), - thenable.then(sourceFiber, sourceFiber)); - -1 === earliestTimeoutMs - ? (root = 1073741823) - : (-1 === startTimeMs && - (startTimeMs = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - )) - - 5e3), - (root = startTimeMs + earliestTimeoutMs)); - 0 <= root && - nextLatestAbsoluteTimeoutMs < root && - (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 2048; - value.expirationTime = renderExpirationTime; - return; - } - value = value.return; - } while (null !== value); - value = Error( - (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + - getStackByFiberInDevAndProd(sourceFiber) - ); - } - nextRenderDidError = !0; - value = createCapturedValue(value, sourceFiber); - root = returnFiber; - do { - switch (root.tag) { - case 3: - root.effectTag |= 2048; - root.expirationTime = renderExpirationTime; - renderExpirationTime = createRootErrorUpdate( - root, - value, - renderExpirationTime - ); - enqueueCapturedUpdate(root, renderExpirationTime); - return; - case 1: - if ( - ((earliestTimeoutMs = value), - (startTimeMs = root.type), - (sourceFiber = root.stateNode), - 0 === (root.effectTag & 64) && - ("function" === typeof startTimeMs.getDerivedStateFromError || - (null !== sourceFiber && - "function" === typeof sourceFiber.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(sourceFiber))))) - ) { - root.effectTag |= 2048; - root.expirationTime = renderExpirationTime; - renderExpirationTime = createClassErrorUpdate( - root, - earliestTimeoutMs, - renderExpirationTime - ); - enqueueCapturedUpdate(root, renderExpirationTime); - return; - } - } - root = root.return; - } while (null !== root); -} function unwindWork(workInProgress) { switch (workInProgress.tag) { case 1: @@ -5841,17 +5305,15 @@ function unwindWork(workInProgress) { workInProgress) : null; case 3: - return ( - popHostContainer(workInProgress), - popTopLevelContextObject(workInProgress), - (effectTag = workInProgress.effectTag), - invariant( - 0 === (effectTag & 64), + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw ReactError( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ), - (workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress - ); + ); + workInProgress.effectTag = (effectTag & -2049) | 64; + return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: @@ -5868,947 +5330,108 @@ function unwindWork(workInProgress) { return popHostContainer(workInProgress), null; case 10: return popProvider(workInProgress), null; + case 19: + case 20: + return null; default: return null; } } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, - ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; -invariant( - null != tracing.__interactionsRef && - null != tracing.__interactionsRef.current, - "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 http://fb.me/react-profiling" -); -var isWorking = !1, - nextUnitOfWork = null, - nextRoot = null, - nextRenderExpirationTime = 0, - nextLatestAbsoluteTimeoutMs = -1, - nextRenderDidError = !1, +var ceil = Math.ceil, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, + LegacyUnbatchedPhase = 2, + RenderPhase = 4, + CommitPhase = 5, + RootIncomplete = 0, + RootErrored = 1, + RootSuspended = 2, + RootCompleted = 3, + workPhase = 0, + workInProgressRoot = null, + workInProgress = null, + renderExpirationTime = 0, + workInProgressRootExitStatus = RootIncomplete, + workInProgressRootMostRecentEventTime = 1073741823, nextEffect = null, - isCommitting$1 = !1, + hasUncaughtError = !1, + firstUncaughtError = null, + legacyErrorBoundariesThatAlreadyFailed = null, + rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, - passiveEffectCallbackHandle = null, - passiveEffectCallback = null, - legacyErrorBoundariesThatAlreadyFailed = null; -function resetStack() { - if (null !== nextUnitOfWork) - for ( - var interruptedWork = nextUnitOfWork.return; - null !== interruptedWork; - - ) { - var interruptedWork$jscomp$0 = interruptedWork; - switch (interruptedWork$jscomp$0.tag) { - case 1: - var childContextTypes = - interruptedWork$jscomp$0.type.childContextTypes; - null !== childContextTypes && - void 0 !== childContextTypes && - popContext(interruptedWork$jscomp$0); - break; - case 3: - popHostContainer(interruptedWork$jscomp$0); - popTopLevelContextObject(interruptedWork$jscomp$0); - break; - case 5: - popHostContext(interruptedWork$jscomp$0); - break; - case 4: - popHostContainer(interruptedWork$jscomp$0); - break; - case 10: - popProvider(interruptedWork$jscomp$0); - } - interruptedWork = interruptedWork.return; - } - nextRoot = null; - nextRenderExpirationTime = 0; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = !1; - nextUnitOfWork = null; -} -function commitAllHostEffects() { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { - var current$$1 = nextEffect.alternate; - null !== current$$1 && - ((current$$1 = current$$1.ref), - null !== current$$1 && - ("function" === typeof current$$1 - ? current$$1(null) - : (current$$1.current = null))); - } - switch (effectTag & 14) { - case 2: - commitPlacement(nextEffect); - nextEffect.effectTag &= -3; - break; - case 6: - commitPlacement(nextEffect); - nextEffect.effectTag &= -3; - commitWork(nextEffect.alternate, nextEffect); - break; - case 4: - commitWork(nextEffect.alternate, nextEffect); - break; - case 8: - (effectTag = nextEffect), - unmountHostComponents(effectTag), - (effectTag.return = null), - (effectTag.child = null), - (effectTag.memoizedState = null), - (effectTag.updateQueue = null), - (effectTag = effectTag.alternate), - null !== effectTag && - ((effectTag.return = null), - (effectTag.child = null), - (effectTag.memoizedState = null), - (effectTag.updateQueue = null)); - } - nextEffect = nextEffect.nextEffect; - } -} -function commitBeforeMutationLifecycles() { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) - a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - break a; - case 1: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState; - current$$1 = finishedWork.stateNode; - finishedWork = current$$1.getSnapshotBeforeUpdate( - finishedWork.elementType === finishedWork.type - ? prevProps - : resolveDefaultProps(finishedWork.type, prevProps), - prevState - ); - current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; - } - break a; - case 3: - case 5: - case 6: - case 4: - case 17: - break a; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } -} -function commitAllLifeCycles( - finishedRoot$jscomp$0, - committedExpirationTime$jscomp$0 -) { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 36) { - var finishedRoot = finishedRoot$jscomp$0, - current$$1 = nextEffect.alternate, - finishedWork = nextEffect, - committedExpirationTime = committedExpirationTime$jscomp$0; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; - case 1: - finishedRoot = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current$$1) finishedRoot.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current$$1.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current$$1.memoizedProps - ); - finishedRoot.componentDidUpdate( - prevProps, - current$$1.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ); - } - current$$1 = finishedWork.updateQueue; - null !== current$$1 && - commitUpdateQueue( - finishedWork, - current$$1, - finishedRoot, - committedExpirationTime - ); - break; - case 3: - current$$1 = finishedWork.updateQueue; - if (null !== current$$1) { - finishedRoot = null; - if (null !== finishedWork.child) - switch (finishedWork.child.tag) { - case 5: - finishedRoot = finishedWork.child.stateNode; - break; - case 1: - finishedRoot = finishedWork.child.stateNode; - } - commitUpdateQueue( - finishedWork, - current$$1, - finishedRoot, - committedExpirationTime - ); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 12: - committedExpirationTime = finishedWork.memoizedProps.onRender; - committedExpirationTime( - finishedWork.memoizedProps.id, - null === current$$1 ? "mount" : "update", - finishedWork.actualDuration, - finishedWork.treeBaseDuration, - finishedWork.actualStartTime, - commitTime, - finishedRoot.memoizedInteractions - ); - break; - case 13: - break; - case 17: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - effectTag & 128 && - ((finishedWork = nextEffect.ref), - null !== finishedWork && - ((committedExpirationTime = nextEffect.stateNode), - "function" === typeof finishedWork - ? finishedWork(committedExpirationTime) - : (finishedWork.current = committedExpirationTime))); - effectTag & 512 && (rootWithPendingPassiveEffects = finishedRoot$jscomp$0); - nextEffect = nextEffect.nextEffect; - } -} -function commitPassiveEffects(root, firstEffect) { - passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; - var previousIsRendering = isRendering; - isRendering = !0; - do { - if (firstEffect.effectTag & 512) { - var didError = !1, - error = void 0; - try { - var finishedWork = firstEffect; - commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); - commitHookEffectList(NoEffect$1, MountPassive, finishedWork); - } catch (e) { - (didError = !0), (error = e); - } - didError && captureCommitPhaseError(firstEffect, error); - } - firstEffect = firstEffect.nextEffect; - } while (null !== firstEffect); - isRendering = previousIsRendering; - previousIsRendering = root.expirationTime; - 0 !== previousIsRendering && requestWork(root, previousIsRendering); - isBatchingUpdates || isRendering || performWork(1073741823, !1); -} -function flushPassiveEffects() { - if (null !== passiveEffectCallbackHandle) { - var callbackID = passiveEffectCallbackHandle; - scheduledCallback = null; - clearTimeout(callbackID); - } - null !== passiveEffectCallback && passiveEffectCallback(); -} -function commitRoot(root, finishedWork) { - isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); - var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== committedExpirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.pendingCommitExpirationTime = 0; - var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, - childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; - markCommittedPriorityLevels( - root, - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit - ? childExpirationTimeBeforeCommit - : updateExpirationTimeBeforeCommit - ); - updateExpirationTimeBeforeCommit = null; - updateExpirationTimeBeforeCommit = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - ReactCurrentOwner$2.current = null; - childExpirationTimeBeforeCommit = void 0; - 1 < finishedWork.effectTag - ? null !== finishedWork.lastEffect - ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (childExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (childExpirationTimeBeforeCommit = finishedWork) - : (childExpirationTimeBeforeCommit = finishedWork.firstEffect); - for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - var didError = !1, - error$jscomp$0 = void 0; - try { - commitBeforeMutationLifecycles(); - } catch (e) { - (didError = !0), (error$jscomp$0 = e); - } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - commitTime = now$1(); - for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - didError = !1; - error$jscomp$0 = void 0; - try { - commitAllHostEffects(); - } catch (e) { - (didError = !0), (error$jscomp$0 = e); - } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - root.current = finishedWork; - for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - didError = !1; - error$jscomp$0 = void 0; - try { - commitAllLifeCycles(root, committedExpirationTime); - } catch (e) { - (didError = !0), (error$jscomp$0 = e); - } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - if ( - null !== childExpirationTimeBeforeCommit && - null !== rootWithPendingPassiveEffects - ) { - var callback = commitPassiveEffects.bind( - null, - root, - childExpirationTimeBeforeCommit - ); - callback = tracing.unstable_wrap(callback); - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return scheduleDeferredCallback$1(callback); - } - ); - passiveEffectCallback = callback; - } - isWorking = isCommitting$1 = !1; - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode); - childExpirationTimeBeforeCommit = finishedWork.expirationTime; - finishedWork = finishedWork.childExpirationTime; - var earliestRemainingTimeAfterCommit = - finishedWork > childExpirationTimeBeforeCommit - ? finishedWork - : childExpirationTimeBeforeCommit; - 0 === earliestRemainingTimeAfterCommit && - (legacyErrorBoundariesThatAlreadyFailed = null); - onCommit(root, earliestRemainingTimeAfterCommit); - tracing.__interactionsRef.current = updateExpirationTimeBeforeCommit; - var subscriber = void 0; - try { - if ( - ((subscriber = tracing.__subscriberRef.current), - null !== subscriber && 0 < root.memoizedInteractions.size) - ) - subscriber.onWorkStopped( - root.memoizedInteractions, - 1e3 * committedExpirationTime + root.interactionThreadID - ); - } catch (error) { - hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); - } finally { - var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - scheduledExpirationTime > earliestRemainingTimeAfterCommit && - (pendingInteractionMap.delete(scheduledExpirationTime), - scheduledInteractions.forEach(function(interaction) { - interaction.__count--; - if (null !== subscriber && 0 === interaction.__count) - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - })); - }); - } -} -function completeUnitOfWork(workInProgress) { - for (;;) { - var current$$1 = workInProgress.alternate, - returnFiber = workInProgress.return, - siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 1024)) { - nextUnitOfWork = workInProgress; - if (workInProgress.mode & 4) { - var fiber = workInProgress; - profilerStartTime = now$1(); - 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); - } - a: { - var current = current$$1; - current$$1 = workInProgress; - var renderExpirationTime = nextRenderExpirationTime; - fiber = current$$1.pendingProps; - switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: - case 0: - break; - case 1: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 3: - popHostContainer(current$$1); - popTopLevelContextObject(current$$1); - fiber = current$$1.stateNode; - fiber.pendingContext && - ((fiber.context = fiber.pendingContext), - (fiber.pendingContext = null)); - if (null === current || null === current.child) - current$$1.effectTag &= -3; - updateHostContainer(current$$1); - break; - case 5: - popHostContext(current$$1); - renderExpirationTime = requiredContext( - rootInstanceStackCursor.current - ); - var type = current$$1.type; - if (null !== current && null != current$$1.stateNode) - updateHostComponent$1( - current, - current$$1, - type, - fiber, - renderExpirationTime - ), - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - else if (fiber) { - current = requiredContext(contextStackCursor$1.current); - var internalInstanceHandle = current$$1, - tag = allocateTag(), - viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !current.isInAParentText, - "Nesting of within is not currently supported." - ); - var updatePayload = diffProperties( - null, - emptyObject, - fiber, - viewConfig.validAttributes - ); - UIManager.createView( - tag, - viewConfig.uiViewClassName, - renderExpirationTime, - updatePayload - ); - viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); - instanceCache[tag] = internalInstanceHandle; - instanceProps[tag] = fiber; - appendAllChildren(viewConfig, current$$1, !1, !1); - finalizeInitialChildren( - viewConfig, - type, - fiber, - renderExpirationTime, - current - ) && (current$$1.effectTag |= 4); - current$$1.stateNode = viewConfig; - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - current && null != current$$1.stateNode - ? updateHostText$1( - current, - current$$1, - current.memoizedProps, - fiber - ) - : ("string" !== typeof fiber && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ), - (current = requiredContext(rootInstanceStackCursor.current)), - (type = requiredContext(contextStackCursor$1.current)), - (renderExpirationTime = current$$1), - invariant( - type.isInAParentText, - "Text strings must be rendered within a component." - ), - (type = allocateTag()), - UIManager.createView(type, "RCTRawText", current, { - text: fiber - }), - (instanceCache[type] = current$$1), - (renderExpirationTime.stateNode = type)); - break; - case 11: - break; - case 13: - fiber = current$$1.memoizedState; - if (0 !== (current$$1.effectTag & 64)) { - current$$1.expirationTime = renderExpirationTime; - nextUnitOfWork = current$$1; - break a; - } - fiber = null !== fiber; - renderExpirationTime = - null !== current && null !== current.memoizedState; - null !== current && - !fiber && - renderExpirationTime && - ((type = current.child.sibling), - null !== type && - ((current = current$$1.firstEffect), - null !== current - ? ((current$$1.firstEffect = type), - (type.nextEffect = current)) - : ((current$$1.firstEffect = current$$1.lastEffect = type), - (type.nextEffect = null)), - (type.effectTag = 8))); - if (fiber || renderExpirationTime) current$$1.effectTag |= 4; - break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); - break; - case 9: - break; - case 14: - break; - case 17: - isContextProvider(current$$1.type) && popContext(current$$1); - break; - case 18: - break; - default: - invariant( - !1, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); - } - nextUnitOfWork = null; - } - workInProgress.mode & 4 && - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - current$$1 = workInProgress; - if ( - 1 === nextRenderExpirationTime || - 1 !== current$$1.childExpirationTime - ) { - fiber = 0; - if (current$$1.mode & 4) { - renderExpirationTime = current$$1.actualDuration; - type = current$$1.selfBaseDuration; - current = - null === current$$1.alternate || - current$$1.child !== current$$1.alternate.child; - for ( - internalInstanceHandle = current$$1.child; - null !== internalInstanceHandle; - - ) - (tag = internalInstanceHandle.expirationTime), - (viewConfig = internalInstanceHandle.childExpirationTime), - tag > fiber && (fiber = tag), - viewConfig > fiber && (fiber = viewConfig), - current && - (renderExpirationTime += internalInstanceHandle.actualDuration), - (type += internalInstanceHandle.treeBaseDuration), - (internalInstanceHandle = internalInstanceHandle.sibling); - current$$1.actualDuration = renderExpirationTime; - current$$1.treeBaseDuration = type; - } else - for ( - renderExpirationTime = current$$1.child; - null !== renderExpirationTime; - - ) - (type = renderExpirationTime.expirationTime), - (current = renderExpirationTime.childExpirationTime), - type > fiber && (fiber = type), - current > fiber && (fiber = current), - (renderExpirationTime = renderExpirationTime.sibling); - current$$1.childExpirationTime = fiber; - } - if (null !== nextUnitOfWork) return nextUnitOfWork; - null !== returnFiber && - 0 === (returnFiber.effectTag & 1024) && - (null === returnFiber.firstEffect && - (returnFiber.firstEffect = workInProgress.firstEffect), - null !== workInProgress.lastEffect && - (null !== returnFiber.lastEffect && - (returnFiber.lastEffect.nextEffect = workInProgress.firstEffect), - (returnFiber.lastEffect = workInProgress.lastEffect)), - 1 < workInProgress.effectTag && - (null !== returnFiber.lastEffect - ? (returnFiber.lastEffect.nextEffect = workInProgress) - : (returnFiber.firstEffect = workInProgress), - (returnFiber.lastEffect = workInProgress))); - } else { - if (workInProgress.mode & 4) { - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - current$$1 = workInProgress.actualDuration; - for (fiber = workInProgress.child; null !== fiber; ) - (current$$1 += fiber.actualDuration), (fiber = fiber.sibling); - workInProgress.actualDuration = current$$1; - } - workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); - if (null !== workInProgress) - return (workInProgress.effectTag &= 1023), workInProgress; - null !== returnFiber && - ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 1024)); - } - if (null !== siblingFiber) return siblingFiber; - if (null !== returnFiber) workInProgress = returnFiber; - else break; - } - return null; -} -function performUnitOfWork(workInProgress) { - var current$$1 = workInProgress.alternate; - workInProgress.mode & 4 && - ((profilerStartTime = now$1()), - 0 > workInProgress.actualStartTime && - (workInProgress.actualStartTime = now$1())); - current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); - workInProgress.memoizedProps = workInProgress.pendingProps; - workInProgress.mode & 4 && - stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); - null === current$$1 && (current$$1 = completeUnitOfWork(workInProgress)); - ReactCurrentOwner$2.current = null; - return current$$1; -} -function renderRoot(root, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - flushPassiveEffects(); - isWorking = !0; - var previousDispatcher = ReactCurrentDispatcher.current; - ReactCurrentDispatcher.current = ContextOnlyDispatcher; - var expirationTime = root.nextExpirationTimeToWorkOn; - if ( - expirationTime !== nextRenderExpirationTime || - root !== nextRoot || - null === nextUnitOfWork - ) { - resetStack(); - nextRoot = root; - nextRenderExpirationTime = expirationTime; - nextUnitOfWork = createWorkInProgress( - nextRoot.current, - null, - nextRenderExpirationTime - ); - root.pendingCommitExpirationTime = 0; - var interactions = new Set(); - root.pendingInteractionMap.forEach(function( - scheduledInteractions, - scheduledExpirationTime - ) { - scheduledExpirationTime >= expirationTime && - scheduledInteractions.forEach(function(interaction) { - return interactions.add(interaction); - }); - }); - root.memoizedInteractions = interactions; - if (0 < interactions.size) { - var subscriber = tracing.__subscriberRef.current; - if (null !== subscriber) { - var threadID = 1e3 * expirationTime + root.interactionThreadID; - try { - subscriber.onWorkStarted(interactions, threadID); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - } - } - } - subscriber = null; - subscriber = tracing.__interactionsRef.current; - tracing.__interactionsRef.current = root.memoizedInteractions; - threadID = !1; - do { - try { - if (isYieldy) - for (; null !== nextUnitOfWork && !(frameDeadline <= now$1()); ) - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - else - for (; null !== nextUnitOfWork; ) - nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - } catch (thrownValue) { - if ( - ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), - resetHooks(), - null === nextUnitOfWork) - ) - (threadID = !0), onUncaughtError(thrownValue); - else { - nextUnitOfWork.mode & 4 && - stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, !0); - invariant( - null !== nextUnitOfWork, - "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." - ); - var sourceFiber = nextUnitOfWork, - returnFiber = sourceFiber.return; - if (null === returnFiber) (threadID = !0), onUncaughtError(thrownValue); - else { - throwException( - root, - returnFiber, - sourceFiber, - thrownValue, - nextRenderExpirationTime - ); - nextUnitOfWork = completeUnitOfWork(sourceFiber); - continue; - } - } - } - break; - } while (1); - tracing.__interactionsRef.current = subscriber; - isWorking = !1; - ReactCurrentDispatcher.current = previousDispatcher; - lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null; - resetHooks(); - if (threadID) (nextRoot = null), (root.finishedWork = null); - else if (null !== nextUnitOfWork) root.finishedWork = null; - else { - previousDispatcher = root.current.alternate; - invariant( - null !== previousDispatcher, - "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." - ); - nextRoot = null; - if (nextRenderDidError) { - if (hasLowerPriorityWork(root, expirationTime)) { - markSuspendedPriorityLevel(root, expirationTime); - onSuspend( - root, - previousDispatcher, - expirationTime, - root.expirationTime, - -1 - ); - return; - } - if (!root.didError && isYieldy) { - root.didError = !0; - isYieldy = root.nextExpirationTimeToWorkOn = expirationTime; - subscriber = root.expirationTime = 1073741823; - onSuspend(root, previousDispatcher, isYieldy, subscriber, -1); - return; - } - } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs - ? (markSuspendedPriorityLevel(root, expirationTime), - (isYieldy = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel(root, expirationTime))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), - onSuspend( - root, - previousDispatcher, - expirationTime, - root.expirationTime, - 0 > isYieldy ? 0 : isYieldy - )) - : onComplete(root, previousDispatcher, expirationTime); - } -} -function captureCommitPhaseError(sourceFiber, value) { - for (var fiber = sourceFiber.return; null !== fiber; ) { - switch (fiber.tag) { - case 1: - var instance = fiber.stateNode; - if ( - "function" === typeof fiber.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - sourceFiber = createCapturedValue(value, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); - return; - } - break; - case 3: - sourceFiber = createCapturedValue(value, sourceFiber); - sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); - enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); - return; - } - fiber = fiber.return; - } - 3 === sourceFiber.tag && - ((fiber = createCapturedValue(value, sourceFiber)), - (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), - enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); + pendingPassiveEffectsExpirationTime = 0, + rootsWithPendingDiscreteUpdates = null, + nestedUpdateCount = 0, + rootWithNestedUpdates = null, + currentEventTime = 0; +function requestCurrentTime() { + return workPhase === RenderPhase || workPhase === CommitPhase + ? 1073741822 - ((now() / 10) | 0) + : 0 !== currentEventTime + ? currentEventTime + : (currentEventTime = 1073741822 - ((now() / 10) | 0)); } function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(), - expirationTime = void 0; - if (0 === (fiber.mode & 1)) expirationTime = 1073741823; - else if (isWorking && !isCommitting$1) - expirationTime = nextRenderExpirationTime; - else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = 1073741823; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = - 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); - break; - case scheduler.unstable_NormalPriority: - expirationTime = - 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = 1; - break; - default: - invariant( - !1, - "Unknown priority level. This error is likely caused by a bug in React. Please file an issue." - ); + if (0 === (fiber.mode & 1)) return 1073741823; + if (workPhase === RenderPhase) return renderExpirationTime; + switch (getCurrentPriorityLevel()) { + case 99: + currentTime = 1073741823; + break; + case 98: + currentTime = + 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); + break; + case 97: + case 96: + currentTime = + 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); + break; + case 95: + currentTime = 1; + break; + default: + throw ReactError("Expected a valid priority level"); + } + null !== workInProgressRoot && + currentTime === renderExpirationTime && + --currentTime; + return currentTime; +} +function scheduleUpdateOnFiber(fiber, expirationTime) { + if (50 < nestedUpdateCount) + throw ((nestedUpdateCount = 0), + (rootWithNestedUpdates = null), + ReactError( + "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." + )); + fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (null !== fiber) + if (((fiber.pingTime = 0), 1073741823 === expirationTime)) + if (workPhase === LegacyUnbatchedPhase) + for ( + expirationTime = renderRoot(fiber, 1073741823, !0); + null !== expirationTime; + + ) + expirationTime = expirationTime(!0); + else + scheduleCallbackForRoot(fiber, 99, 1073741823), + 0 === workPhase && flushImmediateQueue(); + else { + var priorityLevel = getCurrentPriorityLevel(); + if (98 === priorityLevel) + if (null === rootsWithPendingDiscreteUpdates) + rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]]); + else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(fiber); + (void 0 === lastDiscreteTime || lastDiscreteTime > expirationTime) && + rootsWithPendingDiscreteUpdates.set(fiber, expirationTime); + } + scheduleCallbackForRoot(fiber, priorityLevel, expirationTime); } - null !== nextRoot && - expirationTime === nextRenderExpirationTime && - --expirationTime; - } - priorityLevel === scheduler.unstable_UserBlockingPriority && - (0 === lowestPriorityPendingInteractiveExpirationTime || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) && - (lowestPriorityPendingInteractiveExpirationTime = expirationTime); - return expirationTime; } -function pingSuspendedRoot(root, thenable, pingTime) { - var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - if (null !== nextRoot && nextRenderExpirationTime === pingTime) - nextRoot = null; - else if ( - ((thenable = root.earliestSuspendedTime), - (pingCache = root.latestSuspendedTime), - 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) - ) { - root.didError = !1; - thenable = root.latestPingedTime; - if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; - findNextExpirationTimeToWorkOn(pingTime, root); - pingTime = root.expirationTime; - 0 !== pingTime && requestWork(root, pingTime); - } -} -function resolveRetryThenable(boundaryFiber, thenable) { - var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(thenable); - thenable = requestCurrentTime(); - thenable = computeExpirationForFiber(thenable, boundaryFiber); - boundaryFiber = scheduleWorkToRoot(boundaryFiber, thenable); - null !== boundaryFiber && - (markPendingPriorityLevel(boundaryFiber, thenable), - (thenable = boundaryFiber.expirationTime), - 0 !== thenable && requestWork(boundaryFiber, thenable)); -} -function scheduleWorkToRoot(fiber, expirationTime) { +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { fiber.expirationTime < expirationTime && (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; @@ -6832,348 +5455,1542 @@ function scheduleWorkToRoot(fiber, expirationTime) { } node = node.return; } + null !== root && + (expirationTime > root.firstPendingTime && + (root.firstPendingTime = expirationTime), + (fiber = root.lastPendingTime), + 0 === fiber || expirationTime < fiber) && + (root.lastPendingTime = expirationTime); + return root; +} +function scheduleCallbackForRoot(root, priorityLevel, expirationTime) { + if (root.callbackExpirationTime < expirationTime) { + var existingCallbackNode = root.callbackNode; + null !== existingCallbackNode && + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); + root.callbackExpirationTime = expirationTime; + existingCallbackNode = null; + 1073741823 !== expirationTime && + 1 !== expirationTime && + ((existingCallbackNode = 10 * (1073741822 - expirationTime) - now()), + 5e3 < existingCallbackNode && (existingCallbackNode = 5e3), + (existingCallbackNode = { timeout: existingCallbackNode })); + root.callbackNode = scheduleCallback( + priorityLevel, + runRootCallback.bind( + null, + root, + renderRoot.bind(null, root, expirationTime) + ), + existingCallbackNode + ); + } + schedulePendingInteraction(root, expirationTime); +} +function runRootCallback(root, callback, isSync) { + var prevCallbackNode = root.callbackNode, + continuation = null; + try { + return ( + (continuation = callback(isSync)), + null !== continuation + ? runRootCallback.bind(null, root, continuation) + : null + ); + } finally { + null === continuation && + prevCallbackNode === root.callbackNode && + ((root.callbackNode = null), (root.callbackExpirationTime = 0)); + } +} +function resolveLocksOnRoot(root, expirationTime) { + var firstBatch = root.firstBatch; + return null !== firstBatch && + firstBatch._defer && + firstBatch._expirationTime >= expirationTime + ? ((root.finishedWork = root.current.alternate), + (root.pendingCommitExpirationTime = expirationTime), + scheduleCallback(97, function() { + firstBatch._onComplete(); + return null; + }), + !0) + : !1; +} +function flushPendingDiscreteUpdates() { + if (null !== rootsWithPendingDiscreteUpdates) { + var roots = rootsWithPendingDiscreteUpdates; + rootsWithPendingDiscreteUpdates = null; + roots.forEach(function(expirationTime, root) { + scheduleCallback(99, renderRoot.bind(null, root, expirationTime)); + }); + flushImmediateQueue(); + } +} +function prepareFreshStack(root, expirationTime) { + root.pendingCommitExpirationTime = 0; + var timeoutHandle = root.timeoutHandle; + -1 !== timeoutHandle && + ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); + if (null !== workInProgress) + for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) { + var interruptedWork = timeoutHandle; + switch (interruptedWork.tag) { + case 1: + var childContextTypes = interruptedWork.type.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork); + break; + case 3: + popHostContainer(interruptedWork); + popTopLevelContextObject(interruptedWork); + break; + case 5: + popHostContext(interruptedWork); + break; + case 4: + popHostContainer(interruptedWork); + break; + case 10: + popProvider(interruptedWork); + } + timeoutHandle = timeoutHandle.return; + } + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null, expirationTime); + renderExpirationTime = expirationTime; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootMostRecentEventTime = 1073741823; +} +function renderRoot(root$jscomp$0, expirationTime, isSync) { + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Should not already be working."); + if (root$jscomp$0.firstPendingTime < expirationTime) return null; + if (root$jscomp$0.pendingCommitExpirationTime === expirationTime) + return ( + (root$jscomp$0.pendingCommitExpirationTime = 0), + commitRoot.bind(null, root$jscomp$0, expirationTime) + ); + flushPassiveEffects(); if ( - null !== root && - ((fiber = tracing.__interactionsRef.current), 0 < fiber.size) - ) { - alternate = root.pendingInteractionMap; - var pendingInteractions = alternate.get(expirationTime); + root$jscomp$0 !== workInProgressRoot || + expirationTime !== renderExpirationTime + ) + prepareFreshStack(root$jscomp$0, expirationTime), + startWorkOnPendingInteraction(root$jscomp$0, expirationTime); + if (null !== workInProgress) { + var prevWorkPhase = workPhase; + workPhase = RenderPhase; + var prevDispatcher = ReactCurrentDispatcher.current; + null === prevDispatcher && (prevDispatcher = ContextOnlyDispatcher); + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + var prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root$jscomp$0.memoizedInteractions; + if (isSync) { + if (1073741823 !== expirationTime) { + var currentTime = requestCurrentTime(); + if (currentTime < expirationTime) + return ( + (workPhase = prevWorkPhase), + resetContextDependences(), + (ReactCurrentDispatcher.current = prevDispatcher), + (tracing.__interactionsRef.current = prevInteractions), + renderRoot.bind(null, root$jscomp$0, currentTime) + ); + } + } else currentEventTime = 0; + do + try { + if (isSync) + for (; null !== workInProgress; ) + workInProgress = performUnitOfWork(workInProgress); + else + for (; null !== workInProgress && !Scheduler_shouldYield(); ) + workInProgress = performUnitOfWork(workInProgress); + break; + } catch (thrownValue) { + resetContextDependences(); + resetHooks(); + currentTime = workInProgress; + if (null === currentTime || null === currentTime.return) + throw (prepareFreshStack(root$jscomp$0, expirationTime), + (workPhase = prevWorkPhase), + thrownValue); + currentTime.mode & 4 && + stopProfilerTimerIfRunningAndRecordDelta(currentTime, !0); + a: { + var root = root$jscomp$0, + returnFiber = currentTime.return, + sourceFiber = currentTime, + value = thrownValue, + renderExpirationTime$jscomp$0 = renderExpirationTime; + sourceFiber.effectTag |= 1024; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; + if ( + null !== value && + "object" === typeof value && + "function" === typeof value.then + ) { + var thenable = value; + value = returnFiber; + do { + if ( + 13 === value.tag && + (void 0 === value.memoizedProps.fallback + ? 0 + : null === value.memoizedState) + ) { + returnFiber = value.updateQueue; + null === returnFiber + ? ((returnFiber = new Set()), + returnFiber.add(thenable), + (value.updateQueue = returnFiber)) + : returnFiber.add(thenable); + if (0 === (value.mode & 1)) { + value.effectTag |= 64; + sourceFiber.effectTag &= -1957; + 1 === sourceFiber.tag && + (null === sourceFiber.alternate + ? (sourceFiber.tag = 17) + : ((renderExpirationTime$jscomp$0 = createUpdate( + 1073741823 + )), + (renderExpirationTime$jscomp$0.tag = 2), + enqueueUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ))); + sourceFiber.expirationTime = 1073741823; + break a; + } + sourceFiber = root; + root = renderExpirationTime$jscomp$0; + var pingCache = sourceFiber.pingCache; + null === pingCache + ? ((pingCache = sourceFiber.pingCache = new PossiblyWeakMap()), + (returnFiber = new Set()), + pingCache.set(thenable, returnFiber)) + : ((returnFiber = pingCache.get(thenable)), + void 0 === returnFiber && + ((returnFiber = new Set()), + pingCache.set(thenable, returnFiber))); + returnFiber.has(root) || + (returnFiber.add(root), + (sourceFiber = pingSuspendedRoot.bind( + null, + sourceFiber, + thenable, + root + )), + (sourceFiber = tracing.unstable_wrap(sourceFiber)), + thenable.then(sourceFiber, sourceFiber)); + value.effectTag |= 2048; + value.expirationTime = renderExpirationTime$jscomp$0; + break a; + } + value = value.return; + } while (null !== value); + value = Error( + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) + ); + } + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) + workInProgressRootExitStatus = RootErrored; + value = createCapturedValue(value, sourceFiber); + sourceFiber = returnFiber; + do { + switch (sourceFiber.tag) { + case 3: + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime$jscomp$0; + renderExpirationTime$jscomp$0 = createRootErrorUpdate( + sourceFiber, + value, + renderExpirationTime$jscomp$0 + ); + enqueueCapturedUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ); + break a; + case 1: + if ( + ((thenable = value), + (root = sourceFiber.type), + (returnFiber = sourceFiber.stateNode), + 0 === (sourceFiber.effectTag & 64) && + ("function" === typeof root.getDerivedStateFromError || + (null !== returnFiber && + "function" === typeof returnFiber.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has( + returnFiber + ))))) + ) { + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime$jscomp$0; + renderExpirationTime$jscomp$0 = createClassErrorUpdate( + sourceFiber, + thenable, + renderExpirationTime$jscomp$0 + ); + enqueueCapturedUpdate( + sourceFiber, + renderExpirationTime$jscomp$0 + ); + break a; + } + } + sourceFiber = sourceFiber.return; + } while (null !== sourceFiber); + } + workInProgress = completeUnitOfWork(currentTime); + } + while (1); + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher.current = prevDispatcher; + tracing.__interactionsRef.current = prevInteractions; + if (null !== workInProgress) + return renderRoot.bind(null, root$jscomp$0, expirationTime); + } + if (resolveLocksOnRoot(root$jscomp$0, expirationTime)) return null; + workInProgressRoot = null; + switch (workInProgressRootExitStatus) { + case RootIncomplete: + throw ReactError("Should have a work-in-progress."); + case RootErrored: + return ( + (prevWorkPhase = root$jscomp$0.lastPendingTime), + root$jscomp$0.lastPendingTime < expirationTime + ? renderRoot.bind(null, root$jscomp$0, prevWorkPhase) + : isSync + ? commitRoot.bind(null, root$jscomp$0, expirationTime) + : (prepareFreshStack(root$jscomp$0, expirationTime), + scheduleCallback( + 99, + renderRoot.bind(null, root$jscomp$0, expirationTime) + ), + null) + ); + case RootSuspended: + if (!isSync) { + isSync = root$jscomp$0.lastPendingTime; + if (root$jscomp$0.lastPendingTime < expirationTime) + return renderRoot.bind(null, root$jscomp$0, isSync); + if ( + 1073741823 !== workInProgressRootMostRecentEventTime && + ((prevWorkPhase = + 10 * (1073741822 - workInProgressRootMostRecentEventTime) - 5e3), + (isSync = now()), + (prevWorkPhase = isSync - prevWorkPhase), + (prevWorkPhase = + (120 > prevWorkPhase + ? 120 + : 480 > prevWorkPhase + ? 480 + : 1080 > prevWorkPhase + ? 1080 + : 1920 > prevWorkPhase + ? 1920 + : 3e3 > prevWorkPhase + ? 3e3 + : 4320 > prevWorkPhase + ? 4320 + : 1960 * ceil(prevWorkPhase / 1960)) - prevWorkPhase), + (isSync = 10 * (1073741822 - expirationTime) - isSync), + isSync < prevWorkPhase && (prevWorkPhase = isSync), + (isSync = prevWorkPhase), + 10 < isSync) + ) + return ( + (root$jscomp$0.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root$jscomp$0, expirationTime), + isSync + )), + null + ); + } + return commitRoot.bind(null, root$jscomp$0, expirationTime); + case RootCompleted: + return commitRoot.bind(null, root$jscomp$0, expirationTime); + default: + throw ReactError("Unknown root exit status."); + } +} +function performUnitOfWork(unitOfWork) { + var current$$1 = unitOfWork.alternate; + 0 !== (unitOfWork.mode & 4) + ? ((profilerStartTime = now$1()), + 0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()), + (current$$1 = beginWork$$1(current$$1, unitOfWork, renderExpirationTime)), + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0)) + : (current$$1 = beginWork$$1(current$$1, unitOfWork, renderExpirationTime)); + unitOfWork.memoizedProps = unitOfWork.pendingProps; + null === current$$1 && (current$$1 = completeUnitOfWork(unitOfWork)); + ReactCurrentOwner$2.current = null; + return current$$1; +} +function completeUnitOfWork(unitOfWork) { + workInProgress = unitOfWork; + do { + var current$$1 = workInProgress.alternate; + unitOfWork = workInProgress.return; + if (0 === (workInProgress.effectTag & 1024)) { + if (0 === (workInProgress.mode & 4)) + current$$1 = completeWork( + current$$1, + workInProgress, + renderExpirationTime + ); + else { + var fiber = workInProgress; + profilerStartTime = now$1(); + 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); + current$$1 = completeWork( + current$$1, + workInProgress, + renderExpirationTime + ); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + } + fiber = workInProgress; + if (1 === renderExpirationTime || 1 !== fiber.childExpirationTime) { + var newChildExpirationTime = 0; + if (0 !== (fiber.mode & 4)) { + for ( + var actualDuration = fiber.actualDuration, + treeBaseDuration = fiber.selfBaseDuration, + shouldBubbleActualDurations = + null === fiber.alternate || + fiber.child !== fiber.alternate.child, + child = fiber.child; + null !== child; + + ) { + var childUpdateExpirationTime = child.expirationTime, + childChildExpirationTime = child.childExpirationTime; + childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = childUpdateExpirationTime); + childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = childChildExpirationTime); + shouldBubbleActualDurations && + (actualDuration += child.actualDuration); + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + fiber.actualDuration = actualDuration; + fiber.treeBaseDuration = treeBaseDuration; + } else + for (actualDuration = fiber.child; null !== actualDuration; ) + (treeBaseDuration = actualDuration.expirationTime), + (shouldBubbleActualDurations = + actualDuration.childExpirationTime), + treeBaseDuration > newChildExpirationTime && + (newChildExpirationTime = treeBaseDuration), + shouldBubbleActualDurations > newChildExpirationTime && + (newChildExpirationTime = shouldBubbleActualDurations), + (actualDuration = actualDuration.sibling); + fiber.childExpirationTime = newChildExpirationTime; + } + if (null !== current$$1) return current$$1; + null !== unitOfWork && + 0 === (unitOfWork.effectTag & 1024) && + (null === unitOfWork.firstEffect && + (unitOfWork.firstEffect = workInProgress.firstEffect), + null !== workInProgress.lastEffect && + (null !== unitOfWork.lastEffect && + (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), + (unitOfWork.lastEffect = workInProgress.lastEffect)), + 1 < workInProgress.effectTag && + (null !== unitOfWork.lastEffect + ? (unitOfWork.lastEffect.nextEffect = workInProgress) + : (unitOfWork.firstEffect = workInProgress), + (unitOfWork.lastEffect = workInProgress))); + } else { + current$$1 = unwindWork(workInProgress, renderExpirationTime); + if (0 !== (workInProgress.mode & 4)) { + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + fiber = workInProgress.actualDuration; + for ( + newChildExpirationTime = workInProgress.child; + null !== newChildExpirationTime; + + ) + (fiber += newChildExpirationTime.actualDuration), + (newChildExpirationTime = newChildExpirationTime.sibling); + workInProgress.actualDuration = fiber; + } + if (null !== current$$1) + return (current$$1.effectTag &= 1023), current$$1; + null !== unitOfWork && + ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), + (unitOfWork.effectTag |= 1024)); + } + current$$1 = workInProgress.sibling; + if (null !== current$$1) return current$$1; + workInProgress = unitOfWork; + } while (null !== workInProgress); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootCompleted); + return null; +} +function commitRoot(root, expirationTime) { + runWithPriority(99, commitRootImpl.bind(null, root, expirationTime)); + null !== rootWithPendingPassiveEffects && + ((root = getCurrentPriorityLevel()), + scheduleCallback(root, function() { + flushPassiveEffects(); + return null; + })); + return null; +} +function commitRootImpl(root, expirationTime) { + flushPassiveEffects(); + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Should not already be working."); + var finishedWork = root.current.alternate; + if (null === finishedWork) + throw ReactError("Should have a work-in-progress root."); + root.callbackNode = null; + root.callbackExpirationTime = 0; + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, + childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + updateExpirationTimeBeforeCommit = + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit; + root.firstPendingTime = updateExpirationTimeBeforeCommit; + updateExpirationTimeBeforeCommit < root.lastPendingTime && + (root.lastPendingTime = updateExpirationTimeBeforeCommit); + root === workInProgressRoot && + ((workInProgress = workInProgressRoot = null), (renderExpirationTime = 0)); + if (1 < finishedWork.effectTag) + if (null !== finishedWork.lastEffect) { + finishedWork.lastEffect.nextEffect = finishedWork; + var firstEffect = finishedWork.firstEffect; + } else firstEffect = finishedWork; + else firstEffect = finishedWork.firstEffect; + if (null !== firstEffect) { + updateExpirationTimeBeforeCommit = workPhase; + workPhase = CommitPhase; + childExpirationTimeBeforeCommit = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + ReactCurrentOwner$2.current = null; + nextEffect = firstEffect; + do + try { + for (; null !== nextEffect; ) { + if (0 !== (nextEffect.effectTag & 256)) { + var current$$1 = nextEffect.alternate, + finishedWork$jscomp$0 = nextEffect; + switch (finishedWork$jscomp$0.tag) { + case 0: + case 11: + case 15: + commitHookEffectList( + UnmountSnapshot, + NoEffect$1, + finishedWork$jscomp$0 + ); + break; + case 1: + if ( + finishedWork$jscomp$0.effectTag & 256 && + null !== current$$1 + ) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState, + instance = finishedWork$jscomp$0.stateNode, + snapshot = instance.getSnapshotBeforeUpdate( + finishedWork$jscomp$0.elementType === + finishedWork$jscomp$0.type + ? prevProps + : resolveDefaultProps( + finishedWork$jscomp$0.type, + prevProps + ), + prevState + ); + instance.__reactInternalSnapshotBeforeUpdate = snapshot; + } + break; + case 3: + case 5: + case 6: + case 4: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + commitTime = now$1(); + nextEffect = firstEffect; + do + try { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 128) { + var current$$1$jscomp$0 = nextEffect.alternate; + if (null !== current$$1$jscomp$0) { + var currentRef = current$$1$jscomp$0.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (effectTag & 14) { + case 2: + commitPlacement(nextEffect); + nextEffect.effectTag &= -3; + break; + case 6: + commitPlacement(nextEffect); + nextEffect.effectTag &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + current$$1 = nextEffect; + unmountHostComponents(current$$1); + current$$1.return = null; + current$$1.child = null; + current$$1.memoizedState = null; + current$$1.updateQueue = null; + var alternate = current$$1.alternate; + null !== alternate && + ((alternate.return = null), + (alternate.child = null), + (alternate.memoizedState = null), + (alternate.updateQueue = null)); + } + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + root.current = finishedWork; + nextEffect = firstEffect; + do + try { + for ( + effectTag = root, current$$1$jscomp$0 = expirationTime; + null !== nextEffect; + + ) { + var effectTag$jscomp$0 = nextEffect.effectTag; + if (effectTag$jscomp$0 & 36) { + current$$1 = effectTag; + var current$$1$jscomp$1 = nextEffect.alternate; + currentRef = nextEffect; + alternate = current$$1$jscomp$0; + switch (currentRef.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(UnmountLayout, MountLayout, currentRef); + break; + case 1: + var instance$jscomp$0 = currentRef.stateNode; + if (currentRef.effectTag & 4) + if (null === current$$1$jscomp$1) + instance$jscomp$0.componentDidMount(); + else { + var prevProps$jscomp$0 = + currentRef.elementType === currentRef.type + ? current$$1$jscomp$1.memoizedProps + : resolveDefaultProps( + currentRef.type, + current$$1$jscomp$1.memoizedProps + ); + instance$jscomp$0.componentDidUpdate( + prevProps$jscomp$0, + current$$1$jscomp$1.memoizedState, + instance$jscomp$0.__reactInternalSnapshotBeforeUpdate + ); + } + var updateQueue = currentRef.updateQueue; + null !== updateQueue && + commitUpdateQueue( + currentRef, + updateQueue, + instance$jscomp$0, + alternate + ); + break; + case 3: + var _updateQueue = currentRef.updateQueue; + if (null !== _updateQueue) { + current$$1 = null; + if (null !== currentRef.child) + switch (currentRef.child.tag) { + case 5: + current$$1 = currentRef.child.stateNode; + break; + case 1: + current$$1 = currentRef.child.stateNode; + } + commitUpdateQueue( + currentRef, + _updateQueue, + current$$1, + alternate + ); + } + break; + case 5: + break; + case 6: + break; + case 4: + break; + case 12: + var onRender = currentRef.memoizedProps.onRender; + onRender( + currentRef.memoizedProps.id, + null === current$$1$jscomp$1 ? "mount" : "update", + currentRef.actualDuration, + currentRef.treeBaseDuration, + currentRef.actualStartTime, + commitTime, + current$$1.memoizedInteractions + ); + break; + case 13: + case 17: + break; + case 20: + break; + case 19: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + if (effectTag$jscomp$0 & 128) { + var ref = nextEffect.ref; + if (null !== ref) { + var instance$jscomp$1 = nextEffect.stateNode; + switch (nextEffect.tag) { + case 5: + var instanceToUse = instance$jscomp$1; + break; + default: + instanceToUse = instance$jscomp$1; + } + "function" === typeof ref + ? ref(instanceToUse) + : (ref.current = instanceToUse); + } + } + effectTag$jscomp$0 & 512 && (rootDoesHavePassiveEffects = !0); + nextEffect = nextEffect.nextEffect; + } + } catch (error) { + if (null === nextEffect) + throw ReactError("Should be working on an effect."); + captureCommitPhaseError(nextEffect, error); + nextEffect = nextEffect.nextEffect; + } + while (null !== nextEffect); + nextEffect = null; + tracing.__interactionsRef.current = childExpirationTimeBeforeCommit; + workPhase = updateExpirationTimeBeforeCommit; + } else (root.current = finishedWork), (commitTime = now$1()); + rootDoesHavePassiveEffects + ? ((rootDoesHavePassiveEffects = !1), + (rootWithPendingPassiveEffects = root), + (pendingPassiveEffectsExpirationTime = expirationTime)) + : finishPendingInteractions(root, expirationTime); + expirationTime = root.firstPendingTime; + 0 !== expirationTime + ? ((effectTag$jscomp$0 = requestCurrentTime()), + (effectTag$jscomp$0 = inferPriorityFromExpirationTime( + effectTag$jscomp$0, + expirationTime + )), + scheduleCallbackForRoot(root, effectTag$jscomp$0, expirationTime)) + : (legacyErrorBoundariesThatAlreadyFailed = null); + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode); + 1073741823 === expirationTime + ? root === rootWithNestedUpdates + ? nestedUpdateCount++ + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) + : (nestedUpdateCount = 0); + if (hasUncaughtError) + throw ((hasUncaughtError = !1), + (root = firstUncaughtError), + (firstUncaughtError = null), + root); + if (workPhase === LegacyUnbatchedPhase) return null; + flushImmediateQueue(); + return null; +} +function flushPassiveEffects() { + if (null === rootWithPendingPassiveEffects) return !1; + var root = rootWithPendingPassiveEffects, + expirationTime = pendingPassiveEffectsExpirationTime; + rootWithPendingPassiveEffects = null; + pendingPassiveEffectsExpirationTime = 0; + var prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + if (workPhase === RenderPhase || workPhase === CommitPhase) + throw ReactError("Cannot flush passive effects while already rendering."); + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + for (var effect = root.current.firstEffect; null !== effect; ) { + try { + var finishedWork = effect; + commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); + commitHookEffectList(NoEffect$1, MountPassive, finishedWork); + } catch (error) { + if (null === effect) throw ReactError("Should be working on an effect."); + captureCommitPhaseError(effect, error); + } + effect = effect.nextEffect; + } + tracing.__interactionsRef.current = prevInteractions; + finishPendingInteractions(root, expirationTime); + workPhase = prevWorkPhase; + flushImmediateQueue(); + return !0; +} +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + sourceFiber = createCapturedValue(error, sourceFiber); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); + enqueueUpdate(rootFiber, sourceFiber); + rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); + null !== rootFiber && scheduleCallbackForRoot(rootFiber, 99, 1073741823); +} +function captureCommitPhaseError(sourceFiber, error) { + if (3 === sourceFiber.tag) + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + else + for (var fiber = sourceFiber.return; null !== fiber; ) { + if (3 === fiber.tag) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + break; + } else if (1 === fiber.tag) { + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(error, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); + null !== fiber && scheduleCallbackForRoot(fiber, 99, 1073741823); + break; + } + } + fiber = fiber.return; + } +} +function pingSuspendedRoot(root, thenable, suspendedTime) { + var pingCache = root.pingCache; + null !== pingCache && pingCache.delete(thenable); + workInProgressRoot === root && renderExpirationTime === suspendedTime + ? prepareFreshStack(root, renderExpirationTime) + : root.lastPendingTime < suspendedTime || + ((thenable = root.pingTime), + (0 !== thenable && thenable < suspendedTime) || + ((root.pingTime = suspendedTime), + (thenable = requestCurrentTime()), + (thenable = inferPriorityFromExpirationTime(thenable, suspendedTime)), + scheduleCallbackForRoot(root, thenable, suspendedTime))); +} +function resolveRetryThenable(boundaryFiber, thenable) { + var retryCache = boundaryFiber.stateNode; + null !== retryCache && retryCache.delete(thenable); + retryCache = requestCurrentTime(); + thenable = computeExpirationForFiber(retryCache, boundaryFiber); + retryCache = inferPriorityFromExpirationTime(retryCache, thenable); + boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); + null !== boundaryFiber && + scheduleCallbackForRoot(boundaryFiber, retryCache, thenable); +} +var beginWork$$1 = void 0; +beginWork$$1 = function(current$$1, workInProgress, renderExpirationTime) { + var updateExpirationTime = workInProgress.expirationTime; + if (null !== current$$1) + if ( + current$$1.memoizedProps !== workInProgress.pendingProps || + didPerformWorkStackCursor.current + ) + didReceiveUpdate = !0; + else { + if (updateExpirationTime < renderExpirationTime) { + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ); + break; + case 10: + pushProvider(workInProgress, workInProgress.memoizedProps.value); + break; + case 12: + workInProgress.effectTag |= 4; + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + return null !== workInProgress ? workInProgress.sibling : null; + } + } + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } + } + else didReceiveUpdate = !1; + workInProgress.expirationTime = 0; + switch (workInProgress.tag) { + case 2: + updateExpirationTime = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + var context = getMaskedContext( + workInProgress, + contextStackCursor.current + ); + prepareToReadContext(workInProgress, renderExpirationTime); + context = renderWithHooks( + null, + workInProgress, + updateExpirationTime, + current$$1, + context, + renderExpirationTime + ); + workInProgress.effectTag |= 1; + if ( + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof + ) { + workInProgress.tag = 1; + resetHooks(); + if (isContextProvider(updateExpirationTime)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + workInProgress.memoizedState = + null !== context.state && void 0 !== context.state + ? context.state + : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current$$1, + renderExpirationTime + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + hasContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 0), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), + (workInProgress = workInProgress.child); + return workInProgress; + case 16: + context = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + context = readLazyComponentType(context); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current$$1 = resolveDefaultProps(context, current$$1); + switch (hasContext) { + case 0: + workInProgress = updateFunctionComponent( + null, + workInProgress, + context, + current$$1, + renderExpirationTime + ); + break; + case 1: + workInProgress = updateClassComponent( + null, + workInProgress, + context, + current$$1, + renderExpirationTime + ); + break; + case 11: + workInProgress = updateForwardRef( + null, + workInProgress, + context, + current$$1, + renderExpirationTime + ); + break; + case 14: + workInProgress = updateMemoComponent( + null, + workInProgress, + context, + resolveDefaultProps(context.type, current$$1), + updateExpirationTime, + renderExpirationTime + ); + break; + default: + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + context + + ". Lazy element type must resolve to a class or function." + ); + } + return workInProgress; + case 0: + return ( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateFunctionComponent( + current$$1, + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ) + ); + case 1: + return ( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateClassComponent( + current$$1, + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ) + ); + case 3: + pushHostRootContext(workInProgress); + updateExpirationTime = workInProgress.updateQueue; + if (null === updateExpirationTime) + throw ReactError( + "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." + ); + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; + processUpdateQueue( + workInProgress, + updateExpirationTime, + workInProgress.pendingProps, + null, + renderExpirationTime + ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context + ? (workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + )) + : (reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child)); + return workInProgress; + case 5: + return ( + pushHostContext(workInProgress), + null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), + (updateExpirationTime = workInProgress.pendingProps.children), + markRef(current$$1, workInProgress), + reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + workInProgress.child + ); + case 6: + return ( + null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), + null + ); + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + case 4: + return ( + pushHostContainer( + workInProgress, + workInProgress.stateNode.containerInfo + ), + (updateExpirationTime = workInProgress.pendingProps), + null === current$$1 + ? (workInProgress.child = reconcileChildFibers( + workInProgress, + null, + updateExpirationTime, + renderExpirationTime + )) + : reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + workInProgress.child + ); + case 11: + return ( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateForwardRef( + current$$1, + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ) + ); + case 7: + return ( + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps, + renderExpirationTime + ), + workInProgress.child + ); + case 8: + return ( + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps.children, + renderExpirationTime + ), + workInProgress.child + ); + case 12: + return ( + (workInProgress.effectTag |= 4), + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps.children, + renderExpirationTime + ), + workInProgress.child + ); + case 10: + a: { + updateExpirationTime = workInProgress.type._context; + context = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + hasContext = context.value; + pushProvider(workInProgress, hasContext); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + hasContext = is(oldValue, hasContext) + ? 0 + : ("function" === typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + hasContext + ) + : 1073741823) | 0; + if (0 === hasContext) { + if ( + getDerivedStateFromProps.children === context.children && + !didPerformWorkStackCursor.current + ) { + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + break a; + } + } else + for ( + oldValue = workInProgress.child, + null !== oldValue && (oldValue.return = workInProgress); + null !== oldValue; + + ) { + var list = oldValue.contextDependencies; + if (null !== list) { + getDerivedStateFromProps = oldValue.child; + for (var dependency = list.first; null !== dependency; ) { + if ( + dependency.context === updateExpirationTime && + 0 !== (dependency.observedBits & hasContext) + ) { + 1 === oldValue.tag && + ((dependency = createUpdate(renderExpirationTime)), + (dependency.tag = 2), + enqueueUpdate(oldValue, dependency)); + oldValue.expirationTime < renderExpirationTime && + (oldValue.expirationTime = renderExpirationTime); + dependency = oldValue.alternate; + null !== dependency && + dependency.expirationTime < renderExpirationTime && + (dependency.expirationTime = renderExpirationTime); + dependency = renderExpirationTime; + for (var node = oldValue.return; null !== node; ) { + var alternate = node.alternate; + if (node.childExpirationTime < dependency) + (node.childExpirationTime = dependency), + null !== alternate && + alternate.childExpirationTime < dependency && + (alternate.childExpirationTime = dependency); + else if ( + null !== alternate && + alternate.childExpirationTime < dependency + ) + alternate.childExpirationTime = dependency; + else break; + node = node.return; + } + list.expirationTime < renderExpirationTime && + (list.expirationTime = renderExpirationTime); + break; + } + dependency = dependency.next; + } + } else + getDerivedStateFromProps = + 10 === oldValue.tag + ? oldValue.type === workInProgress.type + ? null + : oldValue.child + : oldValue.child; + if (null !== getDerivedStateFromProps) + getDerivedStateFromProps.return = oldValue; + else + for ( + getDerivedStateFromProps = oldValue; + null !== getDerivedStateFromProps; + + ) { + if (getDerivedStateFromProps === workInProgress) { + getDerivedStateFromProps = null; + break; + } + oldValue = getDerivedStateFromProps.sibling; + if (null !== oldValue) { + oldValue.return = getDerivedStateFromProps.return; + getDerivedStateFromProps = oldValue; + break; + } + getDerivedStateFromProps = getDerivedStateFromProps.return; + } + oldValue = getDerivedStateFromProps; + } + } + reconcileChildren( + current$$1, + workInProgress, + context.children, + renderExpirationTime + ); + workInProgress = workInProgress.child; + } + return workInProgress; + case 9: + return ( + (context = workInProgress.type), + (hasContext = workInProgress.pendingProps), + (updateExpirationTime = hasContext.children), + prepareToReadContext(workInProgress, renderExpirationTime), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(context)), + (workInProgress.effectTag |= 1), + reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + workInProgress.child + ); + case 14: + return ( + (context = workInProgress.type), + (hasContext = resolveDefaultProps( + context, + workInProgress.pendingProps + )), + (hasContext = resolveDefaultProps(context.type, hasContext)), + updateMemoComponent( + current$$1, + workInProgress, + context, + hasContext, + updateExpirationTime, + renderExpirationTime + ) + ); + case 15: + return updateSimpleMemoComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + updateExpirationTime, + renderExpirationTime + ); + case 17: + return ( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + (workInProgress.tag = 1), + isContextProvider(updateExpirationTime) + ? ((current$$1 = !0), pushContextProvider(workInProgress)) + : (current$$1 = !1), + prepareToReadContext(workInProgress, renderExpirationTime), + constructClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime + ) + ); + } + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); +}; +function schedulePendingInteraction(root, expirationTime) { + var interactions = tracing.__interactionsRef.current; + if (0 < interactions.size) { + var pendingInteractionMap = root.pendingInteractionMap, + pendingInteractions = pendingInteractionMap.get(expirationTime); null != pendingInteractions - ? fiber.forEach(function(interaction) { + ? interactions.forEach(function(interaction) { pendingInteractions.has(interaction) || interaction.__count++; pendingInteractions.add(interaction); }) - : (alternate.set(expirationTime, new Set(fiber)), - fiber.forEach(function(interaction) { + : (pendingInteractionMap.set(expirationTime, new Set(interactions)), + interactions.forEach(function(interaction) { interaction.__count++; })); - alternate = tracing.__subscriberRef.current; - if (null !== alternate) - alternate.onWorkScheduled( - fiber, + pendingInteractionMap = tracing.__subscriberRef.current; + if (null !== pendingInteractionMap) + pendingInteractionMap.onWorkScheduled( + interactions, 1e3 * expirationTime + root.interactionThreadID ); } - return root; } -function scheduleWork(fiber, expirationTime) { - fiber = scheduleWorkToRoot(fiber, expirationTime); - null !== fiber && - (!isWorking && - 0 !== nextRenderExpirationTime && - expirationTime > nextRenderExpirationTime && - resetStack(), - markPendingPriorityLevel(fiber, expirationTime), - (isWorking && !isCommitting$1 && nextRoot === fiber) || - requestWork(fiber, fiber.expirationTime), - nestedUpdateCount > NESTED_UPDATE_LIMIT && - ((nestedUpdateCount = 0), - invariant( - !1, - "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." - ))); -} -var firstScheduledRoot = null, - lastScheduledRoot = null, - callbackExpirationTime = 0, - callbackID = void 0, - isRendering = !1, - nextFlushedRoot = null, - nextFlushedExpirationTime = 0, - lowestPriorityPendingInteractiveExpirationTime = 0, - hasUnhandledError = !1, - unhandledError = null, - isBatchingUpdates = !1, - isUnbatchingUpdates = !1, - completedBatches = null, - originalStartTimeMs = now$1(), - currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), - currentSchedulerTime = currentRendererTime, - NESTED_UPDATE_LIMIT = 50, - nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null; -function recomputeCurrentRendererTime() { - currentRendererTime = - 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); -} -function scheduleCallbackWithExpirationTime(root, expirationTime) { - if (0 !== callbackExpirationTime) { - if (expirationTime < callbackExpirationTime) return; - null !== callbackID && - ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); - } - callbackExpirationTime = expirationTime; - root = now$1() - originalStartTimeMs; - callbackID = scheduleDeferredCallback$1(performAsyncWork, { - timeout: 10 * (1073741822 - expirationTime) - root - }); -} -function onComplete(root, finishedWork, expirationTime) { - root.pendingCommitExpirationTime = expirationTime; - root.finishedWork = finishedWork; -} -function onSuspend( - root, - finishedWork, - suspendedExpirationTime, - rootExpirationTime, - msUntilTimeout -) { - root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || frameDeadline <= now$1() - ? 0 < msUntilTimeout && - (root.timeoutHandle = scheduleTimeout( - onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), - msUntilTimeout - )) - : ((root.pendingCommitExpirationTime = suspendedExpirationTime), - (root.finishedWork = finishedWork)); -} -function onTimeout(root, finishedWork, suspendedExpirationTime) { - root.pendingCommitExpirationTime = suspendedExpirationTime; - root.finishedWork = finishedWork; - recomputeCurrentRendererTime(); - currentSchedulerTime = currentRendererTime; - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); - nextFlushedRoot = root; - nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); -} -function onCommit(root, expirationTime) { - root.expirationTime = expirationTime; - root.finishedWork = null; -} -function requestCurrentTime() { - if (isRendering) return currentSchedulerTime; - findHighestPriorityRoot(); - if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - return currentSchedulerTime; -} -function requestWork(root, expirationTime) { - null === root.nextScheduledRoot - ? ((root.expirationTime = expirationTime), - null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = root), - (root.nextScheduledRoot = root)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) - : expirationTime > root.expirationTime && - (root.expirationTime = expirationTime); - isRendering || - (isBatchingUpdates - ? isUnbatchingUpdates && - ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1073741823), - performWorkOnRoot(root, 1073741823, !1)) - : 1073741823 === expirationTime - ? performWork(1073741823, !1) - : scheduleCallbackWithExpirationTime(root, expirationTime)); -} -function findHighestPriorityRoot() { - var highestPriorityWork = 0, - highestPriorityRoot = null; - if (null !== lastScheduledRoot) - for ( - var previousScheduledRoot = lastScheduledRoot, root = firstScheduledRoot; - null !== root; - - ) { - var remainingExpirationTime = root.expirationTime; - if (0 === remainingExpirationTime) { - invariant( - null !== previousScheduledRoot && null !== lastScheduledRoot, - "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." - ); - if (root === root.nextScheduledRoot) { - firstScheduledRoot = lastScheduledRoot = root.nextScheduledRoot = null; - break; - } else if (root === firstScheduledRoot) - (firstScheduledRoot = remainingExpirationTime = - root.nextScheduledRoot), - (lastScheduledRoot.nextScheduledRoot = remainingExpirationTime), - (root.nextScheduledRoot = null); - else if (root === lastScheduledRoot) { - lastScheduledRoot = previousScheduledRoot; - lastScheduledRoot.nextScheduledRoot = firstScheduledRoot; - root.nextScheduledRoot = null; - break; - } else - (previousScheduledRoot.nextScheduledRoot = root.nextScheduledRoot), - (root.nextScheduledRoot = null); - root = previousScheduledRoot.nextScheduledRoot; - } else { - remainingExpirationTime > highestPriorityWork && - ((highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root)); - if (root === lastScheduledRoot) break; - if (1073741823 === highestPriorityWork) break; - previousScheduledRoot = root; - root = root.nextScheduledRoot; - } - } - nextFlushedRoot = highestPriorityRoot; - nextFlushedExpirationTime = highestPriorityWork; -} -function performAsyncWork(didTimeout) { - if (didTimeout && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - didTimeout = firstScheduledRoot; - do { - var expirationTime = didTimeout.expirationTime; - 0 !== expirationTime && - currentRendererTime <= expirationTime && - (didTimeout.nextExpirationTimeToWorkOn = currentRendererTime); - didTimeout = didTimeout.nextScheduledRoot; - } while (didTimeout !== firstScheduledRoot); - } - performWork(0, !0); -} -function performWork(minExpirationTime, isYieldy) { - findHighestPriorityRoot(); - if (isYieldy) - for ( - recomputeCurrentRendererTime(), - currentSchedulerTime = currentRendererTime; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !( - frameDeadline <= now$1() && - currentRendererTime > nextFlushedExpirationTime - ); - - ) - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ), - findHighestPriorityRoot(), - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - else - for ( - ; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; - - ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), - findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); - 0 !== nextFlushedExpirationTime && - scheduleCallbackWithExpirationTime( - nextFlushedRoot, - nextFlushedExpirationTime - ); - nestedUpdateCount = 0; - lastCommittedRootDuringThisBatch = null; - if (null !== completedBatches) - for ( - minExpirationTime = completedBatches, - completedBatches = null, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ - ) { - var batch = minExpirationTime[isYieldy]; - try { - batch._onComplete(); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - } - if (hasUnhandledError) - throw ((minExpirationTime = unhandledError), - (unhandledError = null), - (hasUnhandledError = !1), - minExpirationTime); -} -function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - isRendering = !0; - if (isYieldy) { - var _finishedWork = root.finishedWork; - null !== _finishedWork - ? completeRoot(root, _finishedWork, expirationTime) - : ((root.finishedWork = null), - (_finishedWork = root.timeoutHandle), - -1 !== _finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), - renderRoot(root, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - (frameDeadline <= now$1() - ? (root.finishedWork = _finishedWork) - : completeRoot(root, _finishedWork, expirationTime))); - } else - (_finishedWork = root.finishedWork), - null !== _finishedWork - ? completeRoot(root, _finishedWork, expirationTime) - : ((root.finishedWork = null), - (_finishedWork = root.timeoutHandle), - -1 !== _finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), - renderRoot(root, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - completeRoot(root, _finishedWork, expirationTime)); - isRendering = !1; -} -function completeRoot(root, finishedWork, expirationTime) { - var firstBatch = root.firstBatch; - if ( - null !== firstBatch && - firstBatch._expirationTime >= expirationTime && - (null === completedBatches - ? (completedBatches = [firstBatch]) - : completedBatches.push(firstBatch), - firstBatch._defer) +function startWorkOnPendingInteraction(root, expirationTime) { + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime ) { - root.finishedWork = finishedWork; - root.expirationTime = 0; - return; - } - root.finishedWork = null; - root === lastCommittedRootDuringThisBatch - ? nestedUpdateCount++ - : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); + scheduledExpirationTime >= expirationTime && + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + }); + root.memoizedInteractions = interactions; + if (0 < interactions.size) { + var subscriber = tracing.__subscriberRef.current; + if (null !== subscriber) { + root = 1e3 * expirationTime + root.interactionThreadID; + try { + subscriber.onWorkStarted(interactions, root); + } catch (error) { + scheduleCallback(99, function() { + throw error; + }); + } } - ); + } } -function onUncaughtError(error) { - invariant( - null !== nextFlushedRoot, - "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." - ); - nextFlushedRoot.expirationTime = 0; - hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); +function finishPendingInteractions(root, committedExpirationTime) { + var earliestRemainingTimeAfterCommit = root.firstPendingTime, + subscriber = void 0; + try { + if ( + ((subscriber = tracing.__subscriberRef.current), + null !== subscriber && 0 < root.memoizedInteractions.size) + ) + subscriber.onWorkStopped( + root.memoizedInteractions, + 1e3 * committedExpirationTime + root.interactionThreadID + ); + } catch (error) { + scheduleCallback(99, function() { + throw error; + }); + } finally { + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + scheduledExpirationTime > earliestRemainingTimeAfterCommit && + (pendingInteractionMap.delete(scheduledExpirationTime), + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + if (null !== subscriber && 0 === interaction.__count) + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + scheduleCallback(99, function() { + throw error; + }); + } + })); + }); + } } function findHostInstance(component) { var fiber = component._reactInternalFiber; - void 0 === fiber && - ("function" === typeof component.render - ? invariant(!1, "Unable to find node on an unmounted component.") - : invariant( - !1, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - )); + if (void 0 === fiber) { + if ("function" === typeof component.render) + throw ReactError("Unable to find node on an unmounted component."); + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } component = findCurrentHostFiber(fiber); return null === component ? null : component.stateNode; } @@ -7185,10 +7002,13 @@ function updateContainer(element, container, parentComponent, callback) { a: if (parentComponent) { parentComponent = parentComponent._reactInternalFiber; b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); + if ( + 2 !== isFiberMountedImpl(parentComponent) || + 1 !== parentComponent.tag + ) + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); var parentContext = parentComponent; do { switch (parentContext.tag) { @@ -7205,11 +7025,9 @@ function updateContainer(element, container, parentComponent, callback) { } parentContext = parentContext.return; } while (null !== parentContext); - invariant( - !1, + throw ReactError( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); - parentContext = void 0; } if (1 === parentComponent.tag) { var Component = parentComponent.type; @@ -7234,7 +7052,7 @@ function updateContainer(element, container, parentComponent, callback) { null !== container && (callback.callback = container); flushPassiveEffects(); enqueueUpdate(currentTime, callback); - scheduleWork(currentTime, current$$1); + scheduleUpdateOnFiber(currentTime, current$$1); return current$$1; } function createPortal(children, containerInfo, implementation) { @@ -7269,7 +7087,9 @@ function _inherits(subClass, superClass) { } var getInspectorDataForViewTag = void 0; getInspectorDataForViewTag = function() { - invariant(!1, "getInspectorDataForViewTag() is not available in production"); + throw ReactError( + "getInspectorDataForViewTag() is not available in production" + ); }; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7285,21 +7105,18 @@ function findNodeHandle(componentOrHandle) { : componentOrHandle._nativeTag; } _batchedUpdatesImpl = function(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; + if (0 !== workPhase) return fn(a); + workPhase = 1; try { return fn(a); } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1073741823, !1); + (workPhase = 0), flushImmediateQueue(); } }; _flushInteractiveUpdatesImpl = function() { - isRendering || - 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), - (lowestPriorityPendingInteractiveExpirationTime = 0)); + workPhase !== RenderPhase && + workPhase !== CommitPhase && + flushPendingDiscreteUpdates(); }; var roots = new Map(), ReactNativeRenderer = { @@ -7326,35 +7143,67 @@ var roots = new Map(), TextInputState.focusTextInput(findNodeHandle(this)); }; ReactNativeComponent.prototype.measure = function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureLayout = function( relativeToNativeNode, onSuccess, onFail ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { + if (null != maybeInstance && !maybeInstance.canonical) { var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; maybeInstance = @@ -7395,35 +7244,12 @@ var roots = new Map(), render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = 0; - isDevToolsPresent && (root |= 4); - root = createFiber(3, null, null, root); - var root$jscomp$0 = { - current: root, - containerInfo: containerTag, - pendingChildren: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - pingCache: null, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: !1, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null, - interactionThreadID: tracing.unstable_getThreadID(), - memoizedInteractions: new Set(), - pendingInteractionMap: new Map() - }; - root = root.stateNode = root$jscomp$0; + root = new FiberRootNode(containerTag, !1); + var uninitializedFiber = 0; + isDevToolsPresent && (uninitializedFiber |= 4); + uninitializedFiber = createFiber(3, null, null, uninitializedFiber); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -7462,31 +7288,63 @@ var roots = new Map(), NativeMethodsMixin: (function(findNodeHandle, findHostInstance) { return { measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? nativeFabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }, setNativeProps: function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { + if (null != maybeInstance && !maybeInstance.canonical) { var nativeTag = maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; maybeInstance = @@ -7524,7 +7382,10 @@ var roots = new Map(), var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: null, overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { fiber = findCurrentHostFiber(fiber); @@ -7541,7 +7402,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.8.3", + version: "16.8.6", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 1e145ed5e..3e777114d 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -89,7 +89,7 @@ class ReactNativeComponent extends React.Component { measure(callback: MeasureOnSuccessCallback): void {} measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {} measureLayout( - relativeToNativeNode: number, + relativeToNativeNode: number | Object, onSuccess: MeasureLayoutOnSuccessCallback, onFail?: () => void, ): void {} @@ -106,7 +106,7 @@ export type NativeMethodsMixinType = { measure(callback: MeasureOnSuccessCallback): void, measureInWindow(callback: MeasureInWindowOnSuccessCallback): void, measureLayout( - relativeToNativeNode: number, + relativeToNativeNode: number | Object, onSuccess: MeasureLayoutOnSuccessCallback, onFail: () => void, ): void, diff --git a/Libraries/Renderer/shims/ReactTypes.js b/Libraries/Renderer/shims/ReactTypes.js index f09207928..3fb4c46ce 100644 --- a/Libraries/Renderer/shims/ReactTypes.js +++ b/Libraries/Renderer/shims/ReactTypes.js @@ -13,7 +13,9 @@ export type ReactNode = | ReactText | ReactFragment | ReactProvider - | ReactConsumer; + | ReactConsumer + | ReactEventComponent + | ReactEventTarget; export type ReactEmpty = null | void | boolean; @@ -78,3 +80,112 @@ export type ReactPortal = { export type RefObject = {| current: any, |}; + +export type ReactEventResponderEventType = + | string + | {name: string, passive?: boolean}; + +export type ReactEventResponder = { + targetEventTypes?: Array, + rootEventTypes?: Array, + createInitialState?: (props: null | Object) => Object, + stopLocalPropagation: boolean, + onEvent?: ( + event: ReactResponderEvent, + context: ReactResponderContext, + props: null | Object, + state: null | Object, + ) => void, + onEventCapture?: ( + event: ReactResponderEvent, + context: ReactResponderContext, + props: null | Object, + state: null | Object, + ) => void, + onRootEvent?: ( + event: ReactResponderEvent, + context: ReactResponderContext, + props: null | Object, + state: null | Object, + ) => void, + onMount?: ( + context: ReactResponderContext, + props: null | Object, + state: null | Object, + ) => void, + onUnmount?: ( + context: ReactResponderContext, + props: null | Object, + state: null | Object, + ) => void, + onOwnershipChange?: ( + context: ReactResponderContext, + props: null | Object, + state: null | Object, + ) => void, +}; + +export type ReactEventComponentInstance = {| + currentFiber: mixed, + props: null | Object, + responder: ReactEventResponder, + rootEventTypes: null | Set, + rootInstance: mixed, + state: null | Object, +|}; + +export type ReactEventComponent = {| + $$typeof: Symbol | number, + displayName?: string, + props: null | Object, + responder: ReactEventResponder, +|}; + +export type ReactEventTarget = {| + $$typeof: Symbol | number, + displayName?: string, + type: Symbol | number, +|}; + +type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | Touch; + +export type ReactResponderEvent = { + nativeEvent: AnyNativeEvent, + target: Element | Document, + type: string, + passive: boolean, + passiveSupported: boolean, +}; + +export type ReactResponderDispatchEventOptions = { + discrete?: boolean, +}; + +export type ReactResponderContext = { + dispatchEvent: ( + eventObject: Object, + listener: (Object) => void, + options: ReactResponderDispatchEventOptions, + ) => void, + isTargetWithinElement: ( + childTarget: Element | Document, + parentTarget: Element | Document, + ) => boolean, + isTargetWithinEventComponent: (Element | Document) => boolean, + isTargetWithinEventResponderScope: (Element | Document) => boolean, + isPositionWithinTouchHitTarget: (x: number, y: number) => boolean, + addRootEventTypes: ( + rootEventTypes: Array, + ) => void, + removeRootEventTypes: ( + rootEventTypes: Array, + ) => void, + hasOwnership: () => boolean, + requestResponderOwnership: () => boolean, + requestGlobalOwnership: () => boolean, + releaseOwnership: () => boolean, + setTimeout: (func: () => void, timeout: number) => Symbol, + clearTimeout: (timerId: Symbol) => void, + getFocusableElementsInScope(): Array, + getActiveDocument(): Document, +}; diff --git a/package.json b/package.json index ea4e06c0b..8a20b8931 100644 --- a/package.json +++ b/package.json @@ -75,7 +75,7 @@ "test-ios-e2e": "detox test -c ios.sim.release RNTester/e2e" }, "peerDependencies": { - "react": "16.8.3" + "react": "16.8.6" }, "dependencies": { "@babel/runtime": "^7.0.0", @@ -132,8 +132,8 @@ "jscodeshift": "^0.6.2", "mkdirp": "^0.5.1", "prettier": "1.16.4", - "react": "16.8.3", - "react-test-renderer": "16.8.3", + "react": "16.8.6", + "react-test-renderer": "16.8.6", "shelljs": "^0.7.8", "ws": "^6.1.4", "yargs": "^9.0.0" diff --git a/yarn.lock b/yarn.lock index 8b2959186..a31939b0b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6028,10 +6028,10 @@ react-is@^16.8.1, react-is@^16.8.4: resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.4.tgz#90f336a68c3a29a096a3d648ab80e87ec61482a2" integrity sha512-PVadd+WaUDOAciICm/J1waJaSvgq+4rHE/K70j0PFqKhkTBsPv/82UGQJNXAngz1fOQLLxI6z1sEDmJDQhCTAA== -react-is@^16.8.3: - version "16.8.3" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.3.tgz#4ad8b029c2a718fc0cfc746c8d4e1b7221e5387d" - integrity sha512-Y4rC1ZJmsxxkkPuMLwvKvlL1Zfpbcu+Bf4ZigkHup3v9EfdYhAlWAaVyA19olXq2o2mGn0w+dFKvk3pVVlYcIA== +react-is@^16.8.6: + version "16.8.6" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16" + integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA== react-proxy@^1.1.7: version "1.1.8" @@ -6041,15 +6041,15 @@ react-proxy@^1.1.7: lodash "^4.6.1" react-deep-force-update "^1.0.0" -react-test-renderer@16.8.3: - version "16.8.3" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.8.3.tgz#230006af264cc46aeef94392e04747c21839e05e" - integrity sha512-rjJGYebduKNZH0k1bUivVrRLX04JfIQ0FKJLPK10TAb06XWhfi4gTobooF9K/DEFNW98iGac3OSxkfIJUN9Mdg== +react-test-renderer@16.8.6: + version "16.8.6" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.8.6.tgz#188d8029b8c39c786f998aa3efd3ffe7642d5ba1" + integrity sha512-H2srzU5IWYT6cZXof6AhUcx/wEyJddQ8l7cLM/F7gDXYyPr4oq+vCIxJYXVGhId1J706sqziAjuOEjyNkfgoEw== dependencies: object-assign "^4.1.1" prop-types "^15.6.2" - react-is "^16.8.3" - scheduler "^0.13.3" + react-is "^16.8.6" + scheduler "^0.13.6" react-transform-hmr@^1.0.4: version "1.0.4" @@ -6059,15 +6059,15 @@ react-transform-hmr@^1.0.4: global "^4.3.0" react-proxy "^1.1.7" -react@16.8.3: - version "16.8.3" - resolved "https://registry.yarnpkg.com/react/-/react-16.8.3.tgz#c6f988a2ce895375de216edcfaedd6b9a76451d9" - integrity sha512-3UoSIsEq8yTJuSu0luO1QQWYbgGEILm+eJl2QN/VLDi7hL+EN18M3q3oVZwmVzzBJ3DkM7RMdRwBmZZ+b4IzSA== +react@16.8.6: + version "16.8.6" + resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe" + integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.13.3" + scheduler "^0.13.6" read-pkg-up@^2.0.0: version "2.0.0" @@ -6480,10 +6480,10 @@ sax@~1.1.1: resolved "https://registry.yarnpkg.com/sax/-/sax-1.1.6.tgz#5d616be8a5e607d54e114afae55b7eaf2fcc3240" integrity sha1-XWFr6KXmB9VOEUr65Vt+ry/MMkA= -scheduler@^0.13.3: - version "0.13.3" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.3.tgz#bed3c5850f62ea9c716a4d781f9daeb9b2a58896" - integrity sha512-UxN5QRYWtpR1egNWzJcVLk8jlegxAugswQc984lD3kU7NuobsO37/sRfbpTdBjtnD5TBNFA2Q2oLV5+UmPSmEQ== +scheduler@^0.13.6: + version "0.13.6" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889" + integrity sha512-IWnObHt413ucAYKsD9J1QShUKkbKLQQHdxRyw73sw4FN26iWr3DY/H34xGPe4nmL1DwXyWmSWmMrA9TfQbE/XQ== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1"