MCPcopy Create free account
hub / github.com/danielstocks/react-sortable / ReactFiberScheduler

Function ReactFiberScheduler

bundle.js:7671–7938  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

7669// This is not part of the public API, not even for React DevTools.
7670// You may only inject a debugTool if you work on React Fiber itself.
7671var ReactFiberInstrumentation$2={debugTool:null};var ReactFiberInstrumentation_1=ReactFiberInstrumentation$2;var popContextProvider$1=ReactFiberContext.popContextProvider;var reset$1=ReactFiberStack.reset;var getStackAddendumByWorkInProgressFiber$2=ReactFiberComponentTreeHook.getStackAddendumByWorkInProgressFiber;var logCapturedError=ReactFiberErrorLogger.logCapturedError;var invokeGuardedCallback$1=ReactErrorUtils_1.invokeGuardedCallback;var hasCaughtError=ReactErrorUtils_1.hasCaughtError;var clearCaughtError=ReactErrorUtils_1.clearCaughtError;var ReactCurrentOwner$1=ReactGlobalSharedState_1.ReactCurrentOwner;var createWorkInProgress$1=ReactFiber.createWorkInProgress;var largerPriority$1=ReactFiber.largerPriority;var onCommitRoot=ReactFiberDevToolsHook.onCommitRoot;var NoWork$2=ReactPriorityLevel.NoWork;var SynchronousPriority$1=ReactPriorityLevel.SynchronousPriority;var TaskPriority$1=ReactPriorityLevel.TaskPriority;var HighPriority=ReactPriorityLevel.HighPriority;var LowPriority=ReactPriorityLevel.LowPriority;var OffscreenPriority=ReactPriorityLevel.OffscreenPriority;var AsyncUpdates=ReactTypeOfInternalContext.AsyncUpdates;var PerformedWork=ReactTypeOfSideEffect.PerformedWork;var Placement$1=ReactTypeOfSideEffect.Placement;var Update=ReactTypeOfSideEffect.Update;var PlacementAndUpdate=ReactTypeOfSideEffect.PlacementAndUpdate;var Deletion=ReactTypeOfSideEffect.Deletion;var ContentReset=ReactTypeOfSideEffect.ContentReset;var Callback=ReactTypeOfSideEffect.Callback;var Err=ReactTypeOfSideEffect.Err;var Ref=ReactTypeOfSideEffect.Ref;var HostRoot$6=ReactTypeOfWork.HostRoot;var HostComponent$6=ReactTypeOfWork.HostComponent;var HostPortal$3=ReactTypeOfWork.HostPortal;var ClassComponent$5=ReactTypeOfWork.ClassComponent;var getUpdatePriority$1=ReactFiberUpdateQueue.getUpdatePriority;var _require14=ReactFiberContext;var resetContext$1=_require14.resetContext;{var warning$22=require$$0;var ReactFiberInstrumentation$1=ReactFiberInstrumentation_1;var ReactDebugCurrentFiber$3=ReactDebugCurrentFiber_1;var _require15=ReactDebugFiberPerf_1,recordEffect=_require15.recordEffect,recordScheduleUpdate=_require15.recordScheduleUpdate,startWorkTimer=_require15.startWorkTimer,stopWorkTimer=_require15.stopWorkTimer,stopFailedWorkTimer=_require15.stopFailedWorkTimer,startWorkLoopTimer=_require15.startWorkLoopTimer,stopWorkLoopTimer=_require15.stopWorkLoopTimer,startCommitTimer=_require15.startCommitTimer,stopCommitTimer=_require15.stopCommitTimer,startCommitHostEffectsTimer=_require15.startCommitHostEffectsTimer,stopCommitHostEffectsTimer=_require15.stopCommitHostEffectsTimer,startCommitLifeCyclesTimer=_require15.startCommitLifeCyclesTimer,stopCommitLifeCyclesTimer=_require15.stopCommitLifeCyclesTimer;var warnAboutUpdateOnUnmounted=function warnAboutUpdateOnUnmounted(instance){var ctor=instance.constructor;warning$22(false,'Can only update a mounted or mounting component. This usually means '+'you called setState, replaceState, or forceUpdate on an unmounted '+'component. This is a no-op.\n\nPlease check the code for the '+'%s component.',ctor&&(ctor.displayName||ctor.name)||'ReactClass');};var warnAboutInvalidUpdates=function warnAboutInvalidUpdates(instance){switch(ReactDebugCurrentFiber$3.phase){case'getChildContext':warning$22(false,'setState(...): Cannot call setState() inside getChildContext()');break;case'render':warning$22(false,'Cannot update during an existing state transition (such as within '+"`render` or another component's constructor). Render methods should "+'be a pure function of props and state; constructor side-effects are '+'an anti-pattern, but can be moved to `componentWillMount`.');break;}};}var timeHeuristicForUnitOfWork=1;var ReactFiberScheduler=function ReactFiberScheduler(config){var hostContext=ReactFiberHostContext(config);var hydrationContext=ReactFiberHydrationContext(config);var popHostContainer=hostContext.popHostContainer,popHostContext=hostContext.popHostContext,resetHostContainer=hostContext.resetHostContainer;var _ReactFiberBeginWork=ReactFiberBeginWork(config,hostContext,hydrationContext,scheduleUpdate,getPriorityContext),beginWork=_ReactFiberBeginWork.beginWork,beginFailedWork=_ReactFiberBeginWork.beginFailedWork;var _ReactFiberCompleteWo=ReactFiberCompleteWork(config,hostContext,hydrationContext),completeWork=_ReactFiberCompleteWo.completeWork;var _ReactFiberCommitWork=ReactFiberCommitWork(config,captureError),commitPlacement=_ReactFiberCommitWork.commitPlacement,commitDeletion=_ReactFiberCommitWork.commitDeletion,commitWork=_ReactFiberCommitWork.commitWork,commitLifeCycles=_ReactFiberCommitWork.commitLifeCycles,commitAttachRef=_ReactFiberCommitWork.commitAttachRef,commitDetachRef=_ReactFiberCommitWork.commitDetachRef;var scheduleDeferredCallback=config.scheduleDeferredCallback,useSyncScheduling=config.useSyncScheduling,prepareForCommit=config.prepareForCommit,resetAfterCommit=config.resetAfterCommit;// The priority level to use when scheduling an update. We use NoWork to
7672// represent the default priority.
7673// TODO: Should we change this to an array instead of using the call stack?
7674// Might be less confusing.
7675var priorityContext=NoWork$2;// Keeps track of whether we're currently in a work loop.
7676var isPerformingWork=false;// Keeps track of whether the current deadline has expired.
7677var deadlineHasExpired=false;// Keeps track of whether we should should batch sync updates.
7678var isBatchingUpdates=false;// This is needed for the weird case where the initial mount is synchronous
7679// even inside batchedUpdates :(
7680var isUnbatchingUpdates=false;// The next work in progress fiber that we're currently working on.
7681var nextUnitOfWork=null;var nextPriorityLevel=NoWork$2;// The next fiber with an effect that we're currently committing.
7682var nextEffect=null;var pendingCommit=null;// Linked list of roots with scheduled work on them.
7683var nextScheduledRoot=null;var lastScheduledRoot=null;// Keep track of which host environment callbacks are scheduled.
7684var isCallbackScheduled=false;// Keep track of which fibers have captured an error that need to be handled.
7685// Work is removed from this collection after componentDidCatch is called.
7686var capturedErrors=null;// Keep track of which fibers have failed during the current batch of work.
7687// This is a different set than capturedErrors, because it is not reset until
7688// the end of the batch. This is needed to propagate errors correctly if a
7689// subtree fails more than once.
7690var failedBoundaries=null;// Error boundaries that captured an error during the current commit.
7691var commitPhaseBoundaries=null;var firstUncaughtError=null;var didFatal=false;var isCommitting=false;var isUnmounting=false;// Use these to prevent an infinite loop of nested updates
7692var NESTED_UPDATE_LIMIT=1000;var nestedUpdateCount=0;var nextRenderedTree=null;function resetContextStack(){// Reset the stack
7693reset$1();// Reset the cursors
7694resetContext$1();resetHostContainer();}// resetNextUnitOfWork mutates the current priority context. It is reset after
7695// after the workLoop exits, so never call resetNextUnitOfWork from outside
7696// the work loop.
7697function resetNextUnitOfWork(){// Clear out roots with no more work on them, or if they have uncaught errors
7698while(nextScheduledRoot!==null&&nextScheduledRoot.current.pendingWorkPriority===NoWork$2){// Unschedule this root.
7699nextScheduledRoot.isScheduled=false;// Read the next pointer now.
7700// We need to clear it in case this root gets scheduled again later.
7701var next=nextScheduledRoot.nextScheduledRoot;nextScheduledRoot.nextScheduledRoot=null;// Exit if we cleared all the roots and there's no work to do.
7702if(nextScheduledRoot===lastScheduledRoot){nextScheduledRoot=null;lastScheduledRoot=null;nextPriorityLevel=NoWork$2;return null;}// Continue with the next root.
7703// If there's no work on it, it will get unscheduled too.
7704nextScheduledRoot=next;}var root=nextScheduledRoot;var highestPriorityRoot=null;var highestPriorityLevel=NoWork$2;while(root!==null){if(root.current.pendingWorkPriority!==NoWork$2&&(highestPriorityLevel===NoWork$2||highestPriorityLevel>root.current.pendingWorkPriority)){highestPriorityLevel=root.current.pendingWorkPriority;highestPriorityRoot=root;}// We didn't find anything to do in this root, so let's try the next one.
7705root=root.nextScheduledRoot;}if(highestPriorityRoot!==null){nextPriorityLevel=highestPriorityLevel;// Before we start any new work, let's make sure that we have a fresh
7706// stack to work from.
7707// TODO: This call is buried a bit too deep. It would be nice to have
7708// a single point which happens right before any new work and
7709// unfortunately this is it.
7710resetContextStack();nextUnitOfWork=createWorkInProgress$1(highestPriorityRoot.current,highestPriorityLevel);if(highestPriorityRoot!==nextRenderedTree){// We've switched trees. Reset the nested update counter.
7711nestedUpdateCount=0;nextRenderedTree=highestPriorityRoot;}return;}nextPriorityLevel=NoWork$2;nextUnitOfWork=null;nextRenderedTree=null;return;}function commitAllHostEffects(){while(nextEffect!==null){{ReactDebugCurrentFiber$3.setCurrentFiber(nextEffect,null);recordEffect();}var effectTag=nextEffect.effectTag;if(effectTag&ContentReset){config.resetTextContent(nextEffect.stateNode);}if(effectTag&Ref){var current=nextEffect.alternate;if(current!==null){commitDetachRef(current);}}// The following switch statement is only concerned about placement,
7712// updates, and deletions. To avoid needing to add a case for every
7713// possible bitmap value, we remove the secondary effects from the
7714// effect tag and switch on that value.
7715var primaryEffectTag=effectTag&~(Callback|Err|ContentReset|Ref|PerformedWork);switch(primaryEffectTag){case Placement$1:{commitPlacement(nextEffect);// Clear the "placement" from effect tag so that we know that this is inserted, before
7716// any life-cycles like componentDidMount gets called.
7717// TODO: findDOMNode doesn't rely on this any more but isMounted
7718// does and isMounted is deprecated anyway so we should be able
7719// to kill this.
7720nextEffect.effectTag&=~Placement$1;break;}case PlacementAndUpdate:{// Placement
7721commitPlacement(nextEffect);// Clear the "placement" from effect tag so that we know that this is inserted, before
7722// any life-cycles like componentDidMount gets called.
7723nextEffect.effectTag&=~Placement$1;// Update
7724var _current=nextEffect.alternate;commitWork(_current,nextEffect);break;}case Update:{var _current2=nextEffect.alternate;commitWork(_current2,nextEffect);break;}case Deletion:{isUnmounting=true;commitDeletion(nextEffect);isUnmounting=false;break;}}nextEffect=nextEffect.nextEffect;}{ReactDebugCurrentFiber$3.resetCurrentFiber();}}function commitAllLifeCycles(){while(nextEffect!==null){var effectTag=nextEffect.effectTag;// Use Task priority for lifecycle updates
7725if(effectTag&(Update|Callback)){{recordEffect();}var current=nextEffect.alternate;commitLifeCycles(current,nextEffect);}if(effectTag&Ref){{recordEffect();}commitAttachRef(nextEffect);}if(effectTag&Err){{recordEffect();}commitErrorHandling(nextEffect);}var next=nextEffect.nextEffect;// Ensure that we clean these up so that we don't accidentally keep them.
7726// I'm not actually sure this matters because we can't reset firstEffect
7727// and lastEffect since they're on every node, not just the effectful
7728// ones. So we have to clean everything as we reuse nodes anyway.

Callers 1

ReactFiberReconcilerFunction · 0.85

Calls 5

ReactFiberHostContextFunction · 0.85
ReactFiberBeginWorkFunction · 0.85
ReactFiberCompleteWorkFunction · 0.85
ReactFiberCommitWorkFunction · 0.85

Tested by

no test coverage detected