scheduler
Advanced tools
Comparing version 0.0.0-d5e1bf0-aee1b84 to 0.0.0-db3ae32b8
@@ -1,2 +0,2 @@ | ||
/** @license React v16.6.1 | ||
/** @license React v0.0.0-db3ae32b8 | ||
* scheduler-tracing.development.js | ||
@@ -43,7 +43,13 @@ * | ||
// Only used in www builds. | ||
// TODO: true? Here it might just be false. | ||
// Only used in www builds. | ||
// Only used in www builds. | ||
// Disable javascript: URL strings in href for XSS protection. | ||
// React Fire: prevent the value and checked attributes from syncing | ||
@@ -56,2 +62,42 @@ // with their related DOM properties | ||
// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information | ||
// This is a flag so we can fix warnings in RN core before turning it on | ||
// Experimental React Flare event system and event components support. | ||
// Experimental Host Component support. | ||
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107 | ||
// We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?) | ||
// Till then, we warn about the missing mock, but still fallback to a sync mode compatible version | ||
// Temporary flag to revert the fix in #15650 | ||
// For tests, we flush suspense fallbacks in an act scope; | ||
// *except* in some of our own tests, where we test incremental loading states. | ||
// Changes priority of some events like mousemove to user-blocking priority, | ||
// but without making them discrete. The flag exists in case it causes | ||
// starvation problems. | ||
// Add a callback property to suspense to notify which promises are currently | ||
// in the update queue. This allows reporting and tracing of what is causing | ||
// the user to see a loading state. | ||
// Part of the simplification of React.createElement so we can eventually move | ||
// from React.createElement to React.jsx | ||
// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md | ||
var DEFAULT_THREAD_ID = 0; | ||
@@ -58,0 +104,0 @@ |
@@ -1,2 +0,2 @@ | ||
/** @license React v16.6.1 | ||
/** @license React v0.0.0-db3ae32b8 | ||
* scheduler-tracing.production.min.js | ||
@@ -3,0 +3,0 @@ * |
@@ -1,2 +0,2 @@ | ||
/** @license React v16.6.1 | ||
/** @license React v0.0.0-db3ae32b8 | ||
* scheduler-tracing.profiling.min.js | ||
@@ -3,0 +3,0 @@ * |
@@ -1,2 +0,2 @@ | ||
/** @license React v16.6.1 | ||
/** @license React v0.0.0-db3ae32b8 | ||
* scheduler.development.js | ||
@@ -20,2 +20,372 @@ * | ||
var enableSchedulerDebugging = false; | ||
var enableIsInputPending = false; | ||
var requestIdleCallbackBeforeFirstFrame = false; | ||
var requestTimerEventBeforeFirstFrame = false; | ||
var enableMessageLoopImplementation = false; | ||
// The DOM Scheduler implementation is similar to requestIdleCallback. It | ||
// works by scheduling a requestAnimationFrame, storing the time for the start | ||
// of the frame, then scheduling a postMessage which gets scheduled after paint. | ||
// Within the postMessage handler do as much work as possible until time + frame | ||
// rate. By separating the idle call into a separate event tick we ensure that | ||
// layout, paint and other browser work is counted against the available time. | ||
// The frame rate is dynamically adjusted. | ||
var requestHostCallback = void 0; | ||
var requestHostTimeout = void 0; | ||
var cancelHostTimeout = void 0; | ||
var shouldYieldToHost = void 0; | ||
var requestPaint = void 0; | ||
exports.unstable_now = void 0; | ||
exports.unstable_forceFrameRate = void 0; | ||
if ( | ||
// If Scheduler runs in a non-DOM environment, it falls back to a naive | ||
// implementation using setTimeout. | ||
typeof window === 'undefined' || | ||
// Check if MessageChannel is supported, too. | ||
typeof MessageChannel !== 'function') { | ||
// If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore, | ||
// fallback to a naive implementation. | ||
var _callback = null; | ||
var _timeoutID = null; | ||
var _flushCallback = function () { | ||
if (_callback !== null) { | ||
try { | ||
var currentTime = exports.unstable_now(); | ||
var hasRemainingTime = true; | ||
_callback(hasRemainingTime, currentTime); | ||
_callback = null; | ||
} catch (e) { | ||
setTimeout(_flushCallback, 0); | ||
throw e; | ||
} | ||
} | ||
}; | ||
exports.unstable_now = function () { | ||
return Date.now(); | ||
}; | ||
requestHostCallback = function (cb) { | ||
if (_callback !== null) { | ||
// Protect against re-entrancy. | ||
setTimeout(requestHostCallback, 0, cb); | ||
} else { | ||
_callback = cb; | ||
setTimeout(_flushCallback, 0); | ||
} | ||
}; | ||
requestHostTimeout = function (cb, ms) { | ||
_timeoutID = setTimeout(cb, ms); | ||
}; | ||
cancelHostTimeout = function () { | ||
clearTimeout(_timeoutID); | ||
}; | ||
shouldYieldToHost = function () { | ||
return false; | ||
}; | ||
requestPaint = exports.unstable_forceFrameRate = function () {}; | ||
} else { | ||
// Capture local references to native APIs, in case a polyfill overrides them. | ||
var performance = window.performance; | ||
var _Date = window.Date; | ||
var _setTimeout = window.setTimeout; | ||
var _clearTimeout = window.clearTimeout; | ||
var requestAnimationFrame = window.requestAnimationFrame; | ||
var cancelAnimationFrame = window.cancelAnimationFrame; | ||
var requestIdleCallback = window.requestIdleCallback; | ||
if (typeof console !== 'undefined') { | ||
// TODO: Remove fb.me link | ||
if (typeof requestAnimationFrame !== 'function') { | ||
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); | ||
} | ||
if (typeof cancelAnimationFrame !== 'function') { | ||
console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); | ||
} | ||
} | ||
var requestIdleCallbackBeforeFirstFrame$1 = requestIdleCallbackBeforeFirstFrame && typeof requestIdleCallback === 'function' && typeof cancelIdleCallback === 'function'; | ||
exports.unstable_now = typeof performance === 'object' && typeof performance.now === 'function' ? function () { | ||
return performance.now(); | ||
} : function () { | ||
return _Date.now(); | ||
}; | ||
var isRAFLoopRunning = false; | ||
var isMessageLoopRunning = false; | ||
var scheduledHostCallback = null; | ||
var rAFTimeoutID = -1; | ||
var taskTimeoutID = -1; | ||
var frameLength = enableMessageLoopImplementation ? // We won't attempt to align with the vsync. Instead we'll yield multiple | ||
// times per frame, often enough to keep it responsive even at really | ||
// high frame rates > 120. | ||
5 : // Use a heuristic to measure the frame rate and yield at the end of the | ||
// frame. We start out assuming that we run at 30fps but then the | ||
// heuristic tracking will adjust this value to a faster fps if we get | ||
// more frequent animation frames. | ||
33.33; | ||
var prevRAFTime = -1; | ||
var prevRAFInterval = -1; | ||
var frameDeadline = 0; | ||
var fpsLocked = false; | ||
// TODO: Make this configurable | ||
// TODO: Adjust this based on priority? | ||
var maxFrameLength = 300; | ||
var needsPaint = false; | ||
if (enableIsInputPending && navigator !== undefined && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined) { | ||
var scheduling = navigator.scheduling; | ||
shouldYieldToHost = function () { | ||
var currentTime = exports.unstable_now(); | ||
if (currentTime >= frameDeadline) { | ||
// There's no time left in the frame. We may want to yield control of | ||
// the main thread, so the browser can perform high priority tasks. The | ||
// main ones are painting and user input. If there's a pending paint or | ||
// a pending input, then we should yield. But if there's neither, then | ||
// we can yield less often while remaining responsive. We'll eventually | ||
// yield regardless, since there could be a pending paint that wasn't | ||
// accompanied by a call to `requestPaint`, or other main thread tasks | ||
// like network events. | ||
if (needsPaint || scheduling.isInputPending()) { | ||
// There is either a pending paint or a pending input. | ||
return true; | ||
} | ||
// There's no pending input. Only yield if we've reached the max | ||
// frame length. | ||
return currentTime >= frameDeadline + maxFrameLength; | ||
} else { | ||
// There's still time left in the frame. | ||
return false; | ||
} | ||
}; | ||
requestPaint = function () { | ||
needsPaint = true; | ||
}; | ||
} else { | ||
// `isInputPending` is not available. Since we have no way of knowing if | ||
// there's pending input, always yield at the end of the frame. | ||
shouldYieldToHost = function () { | ||
return exports.unstable_now() >= frameDeadline; | ||
}; | ||
// Since we yield every frame regardless, `requestPaint` has no effect. | ||
requestPaint = function () {}; | ||
} | ||
exports.unstable_forceFrameRate = function (fps) { | ||
if (fps < 0 || fps > 125) { | ||
console.error('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported'); | ||
return; | ||
} | ||
if (fps > 0) { | ||
frameLength = Math.floor(1000 / fps); | ||
fpsLocked = true; | ||
} else { | ||
// reset the framerate | ||
frameLength = 33.33; | ||
fpsLocked = false; | ||
} | ||
}; | ||
var performWorkUntilDeadline = function () { | ||
if (enableMessageLoopImplementation) { | ||
if (scheduledHostCallback !== null) { | ||
var currentTime = exports.unstable_now(); | ||
// Yield after `frameLength` ms, regardless of where we are in the vsync | ||
// cycle. This means there's always time remaining at the beginning of | ||
// the message event. | ||
frameDeadline = currentTime + frameLength; | ||
var hasTimeRemaining = true; | ||
try { | ||
var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); | ||
if (!hasMoreWork) { | ||
isMessageLoopRunning = false; | ||
scheduledHostCallback = null; | ||
} else { | ||
// If there's more work, schedule the next message event at the end | ||
// of the preceding one. | ||
port.postMessage(null); | ||
} | ||
} catch (error) { | ||
// If a scheduler task throws, exit the current browser task so the | ||
// error can be observed. | ||
port.postMessage(null); | ||
throw error; | ||
} | ||
} | ||
// Yielding to the browser will give it a chance to paint, so we can | ||
// reset this. | ||
needsPaint = false; | ||
} else { | ||
if (scheduledHostCallback !== null) { | ||
var _currentTime = exports.unstable_now(); | ||
var _hasTimeRemaining = frameDeadline - _currentTime > 0; | ||
try { | ||
var _hasMoreWork = scheduledHostCallback(_hasTimeRemaining, _currentTime); | ||
if (!_hasMoreWork) { | ||
scheduledHostCallback = null; | ||
} | ||
} catch (error) { | ||
// If a scheduler task throws, exit the current browser task so the | ||
// error can be observed, and post a new task as soon as possible | ||
// so we can continue where we left off. | ||
port.postMessage(null); | ||
throw error; | ||
} | ||
} | ||
// Yielding to the browser will give it a chance to paint, so we can | ||
// reset this. | ||
needsPaint = false; | ||
} | ||
}; | ||
var channel = new MessageChannel(); | ||
var port = channel.port2; | ||
channel.port1.onmessage = performWorkUntilDeadline; | ||
var onAnimationFrame = function (rAFTime) { | ||
if (scheduledHostCallback === null) { | ||
// No scheduled work. Exit. | ||
prevRAFTime = -1; | ||
prevRAFInterval = -1; | ||
isRAFLoopRunning = false; | ||
return; | ||
} | ||
// Eagerly schedule the next animation callback at the beginning of the | ||
// frame. If the scheduler queue is not empty at the end of the frame, it | ||
// will continue flushing inside that callback. If the queue *is* empty, | ||
// then it will exit immediately. Posting the callback at the start of the | ||
// frame ensures it's fired within the earliest possible frame. If we | ||
// waited until the end of the frame to post the callback, we risk the | ||
// browser skipping a frame and not firing the callback until the frame | ||
// after that. | ||
isRAFLoopRunning = true; | ||
requestAnimationFrame(function (nextRAFTime) { | ||
_clearTimeout(rAFTimeoutID); | ||
onAnimationFrame(nextRAFTime); | ||
}); | ||
// requestAnimationFrame is throttled when the tab is backgrounded. We | ||
// don't want to stop working entirely. So we'll fallback to a timeout loop. | ||
// TODO: Need a better heuristic for backgrounded work. | ||
var onTimeout = function () { | ||
frameDeadline = exports.unstable_now() + frameLength / 2; | ||
performWorkUntilDeadline(); | ||
rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3); | ||
}; | ||
rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3); | ||
if (prevRAFTime !== -1 && | ||
// Make sure this rAF time is different from the previous one. This check | ||
// could fail if two rAFs fire in the same frame. | ||
rAFTime - prevRAFTime > 0.1) { | ||
var rAFInterval = rAFTime - prevRAFTime; | ||
if (!fpsLocked && prevRAFInterval !== -1) { | ||
// We've observed two consecutive frame intervals. We'll use this to | ||
// dynamically adjust the frame rate. | ||
// | ||
// If one frame goes long, then the next one can be short to catch up. | ||
// If two frames are short in a row, then that's an indication that we | ||
// actually have a higher frame rate than what we're currently | ||
// optimizing. For example, if we're running on 120hz display or 90hz VR | ||
// display. Take the max of the two in case one of them was an anomaly | ||
// due to missed frame deadlines. | ||
if (rAFInterval < frameLength && prevRAFInterval < frameLength) { | ||
frameLength = rAFInterval < prevRAFInterval ? prevRAFInterval : rAFInterval; | ||
if (frameLength < 8.33) { | ||
// Defensive coding. We don't support higher frame rates than 120hz. | ||
// If the calculated frame length gets lower than 8, it is probably | ||
// a bug. | ||
frameLength = 8.33; | ||
} | ||
} | ||
} | ||
prevRAFInterval = rAFInterval; | ||
} | ||
prevRAFTime = rAFTime; | ||
frameDeadline = rAFTime + frameLength; | ||
// We use the postMessage trick to defer idle work until after the repaint. | ||
port.postMessage(null); | ||
}; | ||
requestHostCallback = function (callback) { | ||
scheduledHostCallback = callback; | ||
if (enableMessageLoopImplementation) { | ||
if (!isMessageLoopRunning) { | ||
isMessageLoopRunning = true; | ||
port.postMessage(null); | ||
} | ||
} else { | ||
if (!isRAFLoopRunning) { | ||
// Start a rAF loop. | ||
isRAFLoopRunning = true; | ||
requestAnimationFrame(function (rAFTime) { | ||
if (requestIdleCallbackBeforeFirstFrame$1) { | ||
cancelIdleCallback(idleCallbackID); | ||
} | ||
if (requestTimerEventBeforeFirstFrame) { | ||
_clearTimeout(idleTimeoutID); | ||
} | ||
onAnimationFrame(rAFTime); | ||
}); | ||
// If we just missed the last vsync, the next rAF might not happen for | ||
// another frame. To claim as much idle time as possible, post a | ||
// callback with `requestIdleCallback`, which should fire if there's | ||
// idle time left in the frame. | ||
// | ||
// This should only be an issue for the first rAF in the loop; | ||
// subsequent rAFs are scheduled at the beginning of the | ||
// preceding frame. | ||
var idleCallbackID = void 0; | ||
if (requestIdleCallbackBeforeFirstFrame$1) { | ||
idleCallbackID = requestIdleCallback(function onIdleCallbackBeforeFirstFrame() { | ||
if (requestTimerEventBeforeFirstFrame) { | ||
_clearTimeout(idleTimeoutID); | ||
} | ||
frameDeadline = exports.unstable_now() + frameLength; | ||
performWorkUntilDeadline(); | ||
}); | ||
} | ||
// Alternate strategy to address the same problem. Scheduler a timer | ||
// with no delay. If this fires before the rAF, that likely indicates | ||
// that there's idle time before the next vsync. This isn't always the | ||
// case, but we'll be aggressive and assume it is, as a trade off to | ||
// prevent idle periods. | ||
var idleTimeoutID = void 0; | ||
if (requestTimerEventBeforeFirstFrame) { | ||
idleTimeoutID = _setTimeout(function onTimerEventBeforeFirstFrame() { | ||
if (requestIdleCallbackBeforeFirstFrame$1) { | ||
cancelIdleCallback(idleCallbackID); | ||
} | ||
frameDeadline = exports.unstable_now() + frameLength; | ||
performWorkUntilDeadline(); | ||
}, 0); | ||
} | ||
} | ||
} | ||
}; | ||
requestHostTimeout = function (callback, ms) { | ||
taskTimeoutID = _setTimeout(function () { | ||
callback(exports.unstable_now()); | ||
}, ms); | ||
}; | ||
cancelHostTimeout = function () { | ||
_clearTimeout(taskTimeoutID); | ||
taskTimeoutID = -1; | ||
}; | ||
} | ||
/* eslint-disable no-var */ | ||
@@ -44,65 +414,85 @@ | ||
// Callbacks are stored as a circular, doubly linked list. | ||
var firstCallbackNode = null; | ||
// Tasks are stored as a circular, doubly linked list. | ||
var firstTask = null; | ||
var firstDelayedTask = null; | ||
var currentDidTimeout = false; | ||
// Pausing the scheduler is useful for debugging. | ||
var isSchedulerPaused = false; | ||
var currentTask = null; | ||
var currentPriorityLevel = NormalPriority; | ||
var currentEventStartTime = -1; | ||
var currentExpirationTime = -1; | ||
// This is set when a callback is being executed, to prevent re-entrancy. | ||
var isExecutingCallback = false; | ||
// This is set while performing work, to prevent re-entrancy. | ||
var isPerformingWork = false; | ||
var isHostCallbackScheduled = false; | ||
var isHostTimeoutScheduled = false; | ||
var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; | ||
function ensureHostCallbackIsScheduled() { | ||
if (isExecutingCallback) { | ||
// Don't schedule work yet; wait until the next time we yield. | ||
return; | ||
} | ||
// Schedule the host callback using the earliest expiration in the list. | ||
var expirationTime = firstCallbackNode.expirationTime; | ||
if (!isHostCallbackScheduled) { | ||
isHostCallbackScheduled = true; | ||
} else { | ||
// Cancel the existing host callback. | ||
cancelHostCallback(); | ||
} | ||
requestHostCallback(flushWork, expirationTime); | ||
function scheduler_flushTaskAtPriority_Immediate(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
function scheduler_flushTaskAtPriority_UserBlocking(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
function scheduler_flushTaskAtPriority_Normal(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
function scheduler_flushTaskAtPriority_Low(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
function scheduler_flushTaskAtPriority_Idle(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
function flushFirstCallback() { | ||
var flushedNode = firstCallbackNode; | ||
// Remove the node from the list before calling the callback. That way the | ||
function flushTask(task, currentTime) { | ||
// Remove the task from the list before calling the callback. That way the | ||
// list is in a consistent state even if the callback throws. | ||
var next = firstCallbackNode.next; | ||
if (firstCallbackNode === next) { | ||
// This is the last callback in the list. | ||
firstCallbackNode = null; | ||
next = null; | ||
var next = task.next; | ||
if (next === task) { | ||
// This is the only scheduled task. Clear the list. | ||
firstTask = null; | ||
} else { | ||
var lastCallbackNode = firstCallbackNode.previous; | ||
firstCallbackNode = lastCallbackNode.next = next; | ||
next.previous = lastCallbackNode; | ||
// Remove the task from its position in the list. | ||
if (task === firstTask) { | ||
firstTask = next; | ||
} | ||
var previous = task.previous; | ||
previous.next = next; | ||
next.previous = previous; | ||
} | ||
task.next = task.previous = null; | ||
flushedNode.next = flushedNode.previous = null; | ||
// Now it's safe to call the callback. | ||
var callback = flushedNode.callback; | ||
var expirationTime = flushedNode.expirationTime; | ||
var priorityLevel = flushedNode.priorityLevel; | ||
// Now it's safe to execute the task. | ||
var callback = task.callback; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousExpirationTime = currentExpirationTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentExpirationTime = expirationTime; | ||
var previousTask = currentTask; | ||
currentPriorityLevel = task.priorityLevel; | ||
currentTask = task; | ||
var continuationCallback; | ||
try { | ||
continuationCallback = callback(); | ||
var didUserCallbackTimeout = task.expirationTime <= currentTime; | ||
// Add an extra function to the callstack. Profiling tools can use this | ||
// to infer the priority of work that appears higher in the stack. | ||
switch (currentPriorityLevel) { | ||
case ImmediatePriority: | ||
continuationCallback = scheduler_flushTaskAtPriority_Immediate(callback, didUserCallbackTimeout); | ||
break; | ||
case UserBlockingPriority: | ||
continuationCallback = scheduler_flushTaskAtPriority_UserBlocking(callback, didUserCallbackTimeout); | ||
break; | ||
case NormalPriority: | ||
continuationCallback = scheduler_flushTaskAtPriority_Normal(callback, didUserCallbackTimeout); | ||
break; | ||
case LowPriority: | ||
continuationCallback = scheduler_flushTaskAtPriority_Low(callback, didUserCallbackTimeout); | ||
break; | ||
case IdlePriority: | ||
continuationCallback = scheduler_flushTaskAtPriority_Idle(callback, didUserCallbackTimeout); | ||
break; | ||
} | ||
} catch (error) { | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentExpirationTime = previousExpirationTime; | ||
currentTask = previousTask; | ||
} | ||
@@ -113,44 +503,38 @@ | ||
if (typeof continuationCallback === 'function') { | ||
var continuationNode = { | ||
callback: continuationCallback, | ||
priorityLevel: priorityLevel, | ||
expirationTime: expirationTime, | ||
next: null, | ||
previous: null | ||
}; | ||
var expirationTime = task.expirationTime; | ||
var continuationTask = task; | ||
continuationTask.callback = continuationCallback; | ||
// Insert the new callback into the list, sorted by its expiration. This is | ||
// Insert the new callback into the list, sorted by its timeout. This is | ||
// almost the same as the code in `scheduleCallback`, except the callback | ||
// is inserted into the list *before* callbacks of equal expiration instead | ||
// is inserted into the list *before* callbacks of equal timeout instead | ||
// of after. | ||
if (firstCallbackNode === null) { | ||
if (firstTask === null) { | ||
// This is the first callback in the list. | ||
firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode; | ||
firstTask = continuationTask.next = continuationTask.previous = continuationTask; | ||
} else { | ||
var nextAfterContinuation = null; | ||
var node = firstCallbackNode; | ||
var t = firstTask; | ||
do { | ||
if (node.expirationTime >= expirationTime) { | ||
// This callback expires at or after the continuation. We will insert | ||
// the continuation *before* this callback. | ||
nextAfterContinuation = node; | ||
if (expirationTime <= t.expirationTime) { | ||
// This task times out at or after the continuation. We will insert | ||
// the continuation *before* this task. | ||
nextAfterContinuation = t; | ||
break; | ||
} | ||
node = node.next; | ||
} while (node !== firstCallbackNode); | ||
t = t.next; | ||
} while (t !== firstTask); | ||
if (nextAfterContinuation === null) { | ||
// No equal or lower priority callback was found, which means the new | ||
// callback is the lowest priority callback in the list. | ||
nextAfterContinuation = firstCallbackNode; | ||
} else if (nextAfterContinuation === firstCallbackNode) { | ||
// The new callback is the highest priority callback in the list. | ||
firstCallbackNode = continuationNode; | ||
ensureHostCallbackIsScheduled(); | ||
// No equal or lower priority task was found, which means the new task | ||
// is the lowest priority task in the list. | ||
nextAfterContinuation = firstTask; | ||
} else if (nextAfterContinuation === firstTask) { | ||
// The new task is the highest priority task in the list. | ||
firstTask = continuationTask; | ||
} | ||
var previous = nextAfterContinuation.previous; | ||
previous.next = nextAfterContinuation.previous = continuationNode; | ||
continuationNode.next = nextAfterContinuation; | ||
continuationNode.previous = previous; | ||
var _previous = nextAfterContinuation.previous; | ||
_previous.next = nextAfterContinuation.previous = continuationTask; | ||
continuationTask.next = nextAfterContinuation; | ||
continuationTask.previous = _previous; | ||
} | ||
@@ -160,21 +544,32 @@ } | ||
function flushImmediateWork() { | ||
if ( | ||
// Confirm we've exited the outer most event handler | ||
currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) { | ||
isExecutingCallback = true; | ||
try { | ||
do { | ||
flushFirstCallback(); | ||
} while ( | ||
// Keep flushing until there are no more immediate callbacks | ||
firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority); | ||
} finally { | ||
isExecutingCallback = false; | ||
if (firstCallbackNode !== null) { | ||
// There's still work remaining. Request another callback. | ||
ensureHostCallbackIsScheduled(); | ||
function advanceTimers(currentTime) { | ||
// Check for tasks that are no longer delayed and add them to the queue. | ||
if (firstDelayedTask !== null && firstDelayedTask.startTime <= currentTime) { | ||
do { | ||
var task = firstDelayedTask; | ||
var next = task.next; | ||
if (task === next) { | ||
firstDelayedTask = null; | ||
} else { | ||
isHostCallbackScheduled = false; | ||
firstDelayedTask = next; | ||
var previous = task.previous; | ||
previous.next = next; | ||
next.previous = previous; | ||
} | ||
task.next = task.previous = null; | ||
insertScheduledTask(task, task.expirationTime); | ||
} while (firstDelayedTask !== null && firstDelayedTask.startTime <= currentTime); | ||
} | ||
} | ||
function handleTimeout(currentTime) { | ||
isHostTimeoutScheduled = false; | ||
advanceTimers(currentTime); | ||
if (!isHostCallbackScheduled) { | ||
if (firstTask !== null) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} else if (firstDelayedTask !== null) { | ||
requestHostTimeout(handleTimeout, firstDelayedTask.startTime - currentTime); | ||
} | ||
@@ -184,41 +579,51 @@ } | ||
function flushWork(didTimeout) { | ||
isExecutingCallback = true; | ||
var previousDidTimeout = currentDidTimeout; | ||
currentDidTimeout = didTimeout; | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
// Exit right away if we're currently paused | ||
if (enableSchedulerDebugging && isSchedulerPaused) { | ||
return; | ||
} | ||
// We'll need a host callback the next time work is scheduled. | ||
isHostCallbackScheduled = false; | ||
if (isHostTimeoutScheduled) { | ||
// We scheduled a timeout but it's no longer needed. Cancel it. | ||
isHostTimeoutScheduled = false; | ||
cancelHostTimeout(); | ||
} | ||
var currentTime = initialTime; | ||
advanceTimers(currentTime); | ||
isPerformingWork = true; | ||
try { | ||
if (didTimeout) { | ||
if (!hasTimeRemaining) { | ||
// Flush all the expired callbacks without yielding. | ||
while (firstCallbackNode !== null) { | ||
// Read the current time. Flush all the callbacks that expire at or | ||
// earlier than that time. Then read the current time again and repeat. | ||
// This optimizes for as few performance.now calls as possible. | ||
var currentTime = exports.unstable_now(); | ||
if (firstCallbackNode.expirationTime <= currentTime) { | ||
do { | ||
flushFirstCallback(); | ||
} while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime); | ||
continue; | ||
} | ||
break; | ||
// TODO: Split flushWork into two separate functions instead of using | ||
// a boolean argument? | ||
while (firstTask !== null && firstTask.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused)) { | ||
flushTask(firstTask, currentTime); | ||
currentTime = exports.unstable_now(); | ||
advanceTimers(currentTime); | ||
} | ||
} else { | ||
// Keep flushing callbacks until we run out of time in the frame. | ||
if (firstCallbackNode !== null) { | ||
if (firstTask !== null) { | ||
do { | ||
flushFirstCallback(); | ||
} while (firstCallbackNode !== null && !shouldYieldToHost()); | ||
flushTask(firstTask, currentTime); | ||
currentTime = exports.unstable_now(); | ||
advanceTimers(currentTime); | ||
} while (firstTask !== null && !shouldYieldToHost() && !(enableSchedulerDebugging && isSchedulerPaused)); | ||
} | ||
} | ||
} finally { | ||
isExecutingCallback = false; | ||
currentDidTimeout = previousDidTimeout; | ||
if (firstCallbackNode !== null) { | ||
// There's still work remaining. Request another callback. | ||
ensureHostCallbackIsScheduled(); | ||
// Return whether there's additional work | ||
if (firstTask !== null) { | ||
return true; | ||
} else { | ||
isHostCallbackScheduled = false; | ||
if (firstDelayedTask !== null) { | ||
requestHostTimeout(handleTimeout, firstDelayedTask.startTime - currentTime); | ||
} | ||
return false; | ||
} | ||
// Before exiting, flush all the immediate work that was scheduled. | ||
flushImmediateWork(); | ||
} finally { | ||
isPerformingWork = false; | ||
} | ||
@@ -240,5 +645,3 @@ } | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentEventStartTime = exports.unstable_now(); | ||
@@ -249,7 +652,28 @@ try { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
} | ||
// Before exiting, flush all the immediate work that was scheduled. | ||
flushImmediateWork(); | ||
function unstable_next(eventHandler) { | ||
var priorityLevel; | ||
switch (currentPriorityLevel) { | ||
case ImmediatePriority: | ||
case UserBlockingPriority: | ||
case NormalPriority: | ||
// Shift down to normal priority | ||
priorityLevel = NormalPriority; | ||
break; | ||
default: | ||
// Anything lower than normal priority should remain at the current level. | ||
priorityLevel = currentPriorityLevel; | ||
break; | ||
} | ||
var previousPriorityLevel = currentPriorityLevel; | ||
currentPriorityLevel = priorityLevel; | ||
try { | ||
return eventHandler(); | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
} | ||
} | ||
@@ -262,5 +686,3 @@ | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = parentPriorityLevel; | ||
currentEventStartTime = exports.unstable_now(); | ||
@@ -271,4 +693,2 @@ try { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
flushImmediateWork(); | ||
} | ||
@@ -278,32 +698,42 @@ }; | ||
function unstable_scheduleCallback(callback, deprecated_options) { | ||
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : exports.unstable_now(); | ||
function timeoutForPriorityLevel(priorityLevel) { | ||
switch (priorityLevel) { | ||
case ImmediatePriority: | ||
return IMMEDIATE_PRIORITY_TIMEOUT; | ||
case UserBlockingPriority: | ||
return USER_BLOCKING_PRIORITY; | ||
case IdlePriority: | ||
return IDLE_PRIORITY; | ||
case LowPriority: | ||
return LOW_PRIORITY_TIMEOUT; | ||
case NormalPriority: | ||
default: | ||
return NORMAL_PRIORITY_TIMEOUT; | ||
} | ||
} | ||
var expirationTime; | ||
if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') { | ||
// FIXME: Remove this branch once we lift expiration times out of React. | ||
expirationTime = startTime + deprecated_options.timeout; | ||
function unstable_scheduleCallback(priorityLevel, callback, options) { | ||
var currentTime = exports.unstable_now(); | ||
var startTime; | ||
var timeout; | ||
if (typeof options === 'object' && options !== null) { | ||
var delay = options.delay; | ||
if (typeof delay === 'number' && delay > 0) { | ||
startTime = currentTime + delay; | ||
} else { | ||
startTime = currentTime; | ||
} | ||
timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel); | ||
} else { | ||
switch (currentPriorityLevel) { | ||
case ImmediatePriority: | ||
expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT; | ||
break; | ||
case UserBlockingPriority: | ||
expirationTime = startTime + USER_BLOCKING_PRIORITY; | ||
break; | ||
case IdlePriority: | ||
expirationTime = startTime + IDLE_PRIORITY; | ||
break; | ||
case LowPriority: | ||
expirationTime = startTime + LOW_PRIORITY_TIMEOUT; | ||
break; | ||
case NormalPriority: | ||
default: | ||
expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT; | ||
} | ||
timeout = timeoutForPriorityLevel(priorityLevel); | ||
startTime = currentTime; | ||
} | ||
var newNode = { | ||
var expirationTime = startTime + timeout; | ||
var newTask = { | ||
callback: callback, | ||
priorityLevel: currentPriorityLevel, | ||
priorityLevel: priorityLevel, | ||
startTime: startTime, | ||
expirationTime: expirationTime, | ||
@@ -314,42 +744,115 @@ next: null, | ||
// Insert the new callback into the list, ordered first by expiration, then | ||
// by insertion. So the new callback is inserted any other callback with | ||
// equal expiration. | ||
if (firstCallbackNode === null) { | ||
// This is the first callback in the list. | ||
firstCallbackNode = newNode.next = newNode.previous = newNode; | ||
ensureHostCallbackIsScheduled(); | ||
if (startTime > currentTime) { | ||
// This is a delayed task. | ||
insertDelayedTask(newTask, startTime); | ||
if (firstTask === null && firstDelayedTask === newTask) { | ||
// All tasks are delayed, and this is the task with the earliest delay. | ||
if (isHostTimeoutScheduled) { | ||
// Cancel an existing timeout. | ||
cancelHostTimeout(); | ||
} else { | ||
isHostTimeoutScheduled = true; | ||
} | ||
// Schedule a timeout. | ||
requestHostTimeout(handleTimeout, startTime - currentTime); | ||
} | ||
} else { | ||
insertScheduledTask(newTask, expirationTime); | ||
// Schedule a host callback, if needed. If we're already performing work, | ||
// wait until the next time we yield. | ||
if (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
} | ||
return newTask; | ||
} | ||
function insertScheduledTask(newTask, expirationTime) { | ||
// Insert the new task into the list, ordered first by its timeout, then by | ||
// insertion. So the new task is inserted after any other task the | ||
// same timeout | ||
if (firstTask === null) { | ||
// This is the first task in the list. | ||
firstTask = newTask.next = newTask.previous = newTask; | ||
} else { | ||
var next = null; | ||
var node = firstCallbackNode; | ||
var task = firstTask; | ||
do { | ||
if (node.expirationTime > expirationTime) { | ||
// The new callback expires before this one. | ||
next = node; | ||
if (expirationTime < task.expirationTime) { | ||
// The new task times out before this one. | ||
next = task; | ||
break; | ||
} | ||
node = node.next; | ||
} while (node !== firstCallbackNode); | ||
task = task.next; | ||
} while (task !== firstTask); | ||
if (next === null) { | ||
// No callback with a later expiration was found, which means the new | ||
// callback has the latest expiration in the list. | ||
next = firstCallbackNode; | ||
} else if (next === firstCallbackNode) { | ||
// The new callback has the earliest expiration in the entire list. | ||
firstCallbackNode = newNode; | ||
ensureHostCallbackIsScheduled(); | ||
// No task with a later timeout was found, which means the new task has | ||
// the latest timeout in the list. | ||
next = firstTask; | ||
} else if (next === firstTask) { | ||
// The new task has the earliest expiration in the entire list. | ||
firstTask = newTask; | ||
} | ||
var previous = next.previous; | ||
previous.next = next.previous = newNode; | ||
newNode.next = next; | ||
newNode.previous = previous; | ||
previous.next = next.previous = newTask; | ||
newTask.next = next; | ||
newTask.previous = previous; | ||
} | ||
} | ||
return newNode; | ||
function insertDelayedTask(newTask, startTime) { | ||
// Insert the new task into the list, ordered by its start time. | ||
if (firstDelayedTask === null) { | ||
// This is the first task in the list. | ||
firstDelayedTask = newTask.next = newTask.previous = newTask; | ||
} else { | ||
var next = null; | ||
var task = firstDelayedTask; | ||
do { | ||
if (startTime < task.startTime) { | ||
// The new task times out before this one. | ||
next = task; | ||
break; | ||
} | ||
task = task.next; | ||
} while (task !== firstDelayedTask); | ||
if (next === null) { | ||
// No task with a later timeout was found, which means the new task has | ||
// the latest timeout in the list. | ||
next = firstDelayedTask; | ||
} else if (next === firstDelayedTask) { | ||
// The new task has the earliest expiration in the entire list. | ||
firstDelayedTask = newTask; | ||
} | ||
var previous = next.previous; | ||
previous.next = next.previous = newTask; | ||
newTask.next = next; | ||
newTask.previous = previous; | ||
} | ||
} | ||
function unstable_cancelCallback(callbackNode) { | ||
var next = callbackNode.next; | ||
function unstable_pauseExecution() { | ||
isSchedulerPaused = true; | ||
} | ||
function unstable_continueExecution() { | ||
isSchedulerPaused = false; | ||
if (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
} | ||
function unstable_getFirstCallbackNode() { | ||
return firstTask; | ||
} | ||
function unstable_cancelCallback(task) { | ||
var next = task.next; | ||
if (next === null) { | ||
@@ -360,11 +863,15 @@ // Already cancelled. | ||
if (next === callbackNode) { | ||
// This is the only scheduled callback. Clear the list. | ||
firstCallbackNode = null; | ||
if (task === next) { | ||
if (task === firstTask) { | ||
firstTask = null; | ||
} else if (task === firstDelayedTask) { | ||
firstDelayedTask = null; | ||
} | ||
} else { | ||
// Remove the callback from its position in the list. | ||
if (callbackNode === firstCallbackNode) { | ||
firstCallbackNode = next; | ||
if (task === firstTask) { | ||
firstTask = next; | ||
} else if (task === firstDelayedTask) { | ||
firstDelayedTask = next; | ||
} | ||
var previous = callbackNode.previous; | ||
var previous = task.previous; | ||
previous.next = next; | ||
@@ -374,3 +881,3 @@ next.previous = previous; | ||
callbackNode.next = callbackNode.previous = null; | ||
task.next = task.previous = null; | ||
} | ||
@@ -383,259 +890,9 @@ | ||
function unstable_shouldYield() { | ||
return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost()); | ||
var currentTime = exports.unstable_now(); | ||
advanceTimers(currentTime); | ||
return currentTask !== null && firstTask !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost(); | ||
} | ||
// The remaining code is essentially a polyfill for requestIdleCallback. It | ||
// works by scheduling a requestAnimationFrame, storing the time for the start | ||
// of the frame, then scheduling a postMessage which gets scheduled after paint. | ||
// Within the postMessage handler do as much work as possible until time + frame | ||
// rate. By separating the idle call into a separate event tick we ensure that | ||
// layout, paint and other browser work is counted against the available time. | ||
// The frame rate is dynamically adjusted. | ||
var unstable_requestPaint = requestPaint; | ||
// We capture a local reference to any global, in case it gets polyfilled after | ||
// this module is initially evaluated. We want to be using a | ||
// consistent implementation. | ||
var localDate = Date; | ||
// This initialization code may run even on server environments if a component | ||
// just imports ReactDOM (e.g. for findDOMNode). Some environments might not | ||
// have setTimeout or clearTimeout. However, we always expect them to be defined | ||
// on the client. https://github.com/facebook/react/pull/13088 | ||
var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined; | ||
var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined; | ||
// We don't expect either of these to necessarily be defined, but we will error | ||
// later if they are missing on the client. | ||
var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined; | ||
var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined; | ||
// requestAnimationFrame does not run when the tab is in the background. If | ||
// we're backgrounded we prefer for that work to happen so that the page | ||
// continues to load in the background. So we also schedule a 'setTimeout' as | ||
// a fallback. | ||
// TODO: Need a better heuristic for backgrounded work. | ||
var ANIMATION_FRAME_TIMEOUT = 100; | ||
var rAFID; | ||
var rAFTimeoutID; | ||
var requestAnimationFrameWithTimeout = function (callback) { | ||
// schedule rAF and also a setTimeout | ||
rAFID = localRequestAnimationFrame(function (timestamp) { | ||
// cancel the setTimeout | ||
localClearTimeout(rAFTimeoutID); | ||
callback(timestamp); | ||
}); | ||
rAFTimeoutID = localSetTimeout(function () { | ||
// cancel the requestAnimationFrame | ||
localCancelAnimationFrame(rAFID); | ||
callback(exports.unstable_now()); | ||
}, ANIMATION_FRAME_TIMEOUT); | ||
}; | ||
if (hasNativePerformanceNow) { | ||
var Performance = performance; | ||
exports.unstable_now = function () { | ||
return Performance.now(); | ||
}; | ||
} else { | ||
exports.unstable_now = function () { | ||
return localDate.now(); | ||
}; | ||
} | ||
var requestHostCallback; | ||
var cancelHostCallback; | ||
var shouldYieldToHost; | ||
if (typeof window !== 'undefined' && window._schedMock) { | ||
// Dynamic injection, only for testing purposes. | ||
var impl = window._schedMock; | ||
requestHostCallback = impl[0]; | ||
cancelHostCallback = impl[1]; | ||
shouldYieldToHost = impl[2]; | ||
} else if ( | ||
// If Scheduler runs in a non-DOM environment, it falls back to a naive | ||
// implementation using setTimeout. | ||
typeof window === 'undefined' || | ||
// "addEventListener" might not be available on the window object | ||
// if this is a mocked "window" object. So we need to validate that too. | ||
typeof window.addEventListener !== 'function') { | ||
var _callback = null; | ||
var _currentTime = -1; | ||
var _flushCallback = function (didTimeout, ms) { | ||
if (_callback !== null) { | ||
var cb = _callback; | ||
_callback = null; | ||
try { | ||
_currentTime = ms; | ||
cb(didTimeout); | ||
} finally { | ||
_currentTime = -1; | ||
} | ||
} | ||
}; | ||
requestHostCallback = function (cb, ms) { | ||
if (_currentTime !== -1) { | ||
// Protect against re-entrancy. | ||
setTimeout(requestHostCallback, 0, cb, ms); | ||
} else { | ||
_callback = cb; | ||
setTimeout(_flushCallback, ms, true, ms); | ||
setTimeout(_flushCallback, maxSigned31BitInt, false, maxSigned31BitInt); | ||
} | ||
}; | ||
cancelHostCallback = function () { | ||
_callback = null; | ||
}; | ||
shouldYieldToHost = function () { | ||
return false; | ||
}; | ||
exports.unstable_now = function () { | ||
return _currentTime === -1 ? 0 : _currentTime; | ||
}; | ||
} else { | ||
if (typeof console !== 'undefined') { | ||
// TODO: Remove fb.me link | ||
if (typeof localRequestAnimationFrame !== 'function') { | ||
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); | ||
} | ||
if (typeof localCancelAnimationFrame !== 'function') { | ||
console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills'); | ||
} | ||
} | ||
var scheduledHostCallback = null; | ||
var isMessageEventScheduled = false; | ||
var timeoutTime = -1; | ||
var isAnimationFrameScheduled = false; | ||
var isFlushingHostCallback = false; | ||
var frameDeadline = 0; | ||
// We start out assuming that we run at 30fps but then the heuristic tracking | ||
// will adjust this value to a faster fps if we get more frequent animation | ||
// frames. | ||
var previousFrameTime = 33; | ||
var activeFrameTime = 33; | ||
shouldYieldToHost = function () { | ||
return frameDeadline <= exports.unstable_now(); | ||
}; | ||
// We use the postMessage trick to defer idle work until after the repaint. | ||
var messageKey = '__reactIdleCallback$' + Math.random().toString(36).slice(2); | ||
var idleTick = function (event) { | ||
if (event.source !== window || event.data !== messageKey) { | ||
return; | ||
} | ||
isMessageEventScheduled = false; | ||
var prevScheduledCallback = scheduledHostCallback; | ||
var prevTimeoutTime = timeoutTime; | ||
scheduledHostCallback = null; | ||
timeoutTime = -1; | ||
var currentTime = exports.unstable_now(); | ||
var didTimeout = false; | ||
if (frameDeadline - currentTime <= 0) { | ||
// There's no time left in this idle period. Check if the callback has | ||
// a timeout and whether it's been exceeded. | ||
if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) { | ||
// Exceeded the timeout. Invoke the callback even though there's no | ||
// time left. | ||
didTimeout = true; | ||
} else { | ||
// No timeout. | ||
if (!isAnimationFrameScheduled) { | ||
// Schedule another animation callback so we retry later. | ||
isAnimationFrameScheduled = true; | ||
requestAnimationFrameWithTimeout(animationTick); | ||
} | ||
// Exit without invoking the callback. | ||
scheduledHostCallback = prevScheduledCallback; | ||
timeoutTime = prevTimeoutTime; | ||
return; | ||
} | ||
} | ||
if (prevScheduledCallback !== null) { | ||
isFlushingHostCallback = true; | ||
try { | ||
prevScheduledCallback(didTimeout); | ||
} finally { | ||
isFlushingHostCallback = false; | ||
} | ||
} | ||
}; | ||
// Assumes that we have addEventListener in this environment. Might need | ||
// something better for old IE. | ||
window.addEventListener('message', idleTick, false); | ||
var animationTick = function (rafTime) { | ||
if (scheduledHostCallback !== null) { | ||
// Eagerly schedule the next animation callback at the beginning of the | ||
// frame. If the scheduler queue is not empty at the end of the frame, it | ||
// will continue flushing inside that callback. If the queue *is* empty, | ||
// then it will exit immediately. Posting the callback at the start of the | ||
// frame ensures it's fired within the earliest possible frame. If we | ||
// waited until the end of the frame to post the callback, we risk the | ||
// browser skipping a frame and not firing the callback until the frame | ||
// after that. | ||
requestAnimationFrameWithTimeout(animationTick); | ||
} else { | ||
// No pending work. Exit. | ||
isAnimationFrameScheduled = false; | ||
return; | ||
} | ||
var nextFrameTime = rafTime - frameDeadline + activeFrameTime; | ||
if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) { | ||
if (nextFrameTime < 8) { | ||
// Defensive coding. We don't support higher frame rates than 120hz. | ||
// If the calculated frame time gets lower than 8, it is probably a bug. | ||
nextFrameTime = 8; | ||
} | ||
// If one frame goes long, then the next one can be short to catch up. | ||
// If two frames are short in a row, then that's an indication that we | ||
// actually have a higher frame rate than what we're currently optimizing. | ||
// We adjust our heuristic dynamically accordingly. For example, if we're | ||
// running on 120hz display or 90hz VR display. | ||
// Take the max of the two in case one of them was an anomaly due to | ||
// missed frame deadlines. | ||
activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime; | ||
} else { | ||
previousFrameTime = nextFrameTime; | ||
} | ||
frameDeadline = rafTime + activeFrameTime; | ||
if (!isMessageEventScheduled) { | ||
isMessageEventScheduled = true; | ||
window.postMessage(messageKey, '*'); | ||
} | ||
}; | ||
requestHostCallback = function (callback, absoluteTimeout) { | ||
scheduledHostCallback = callback; | ||
timeoutTime = absoluteTimeout; | ||
if (isFlushingHostCallback || absoluteTimeout < 0) { | ||
// Don't wait for the next frame. Continue working ASAP, in a new event. | ||
window.postMessage(messageKey, '*'); | ||
} else if (!isAnimationFrameScheduled) { | ||
// If rAF didn't already schedule one, we need to schedule a frame. | ||
// TODO: If this rAF doesn't materialize because the browser throttles, we | ||
// might want to still have setTimeout trigger rIC as a backup to ensure | ||
// that we keep performing work. | ||
isAnimationFrameScheduled = true; | ||
requestAnimationFrameWithTimeout(animationTick); | ||
} | ||
}; | ||
cancelHostCallback = function () { | ||
scheduledHostCallback = null; | ||
isMessageEventScheduled = false; | ||
timeoutTime = -1; | ||
}; | ||
} | ||
exports.unstable_ImmediatePriority = ImmediatePriority; | ||
@@ -647,2 +904,3 @@ exports.unstable_UserBlockingPriority = UserBlockingPriority; | ||
exports.unstable_runWithPriority = unstable_runWithPriority; | ||
exports.unstable_next = unstable_next; | ||
exports.unstable_scheduleCallback = unstable_scheduleCallback; | ||
@@ -653,3 +911,7 @@ exports.unstable_cancelCallback = unstable_cancelCallback; | ||
exports.unstable_shouldYield = unstable_shouldYield; | ||
exports.unstable_requestPaint = unstable_requestPaint; | ||
exports.unstable_continueExecution = unstable_continueExecution; | ||
exports.unstable_pauseExecution = unstable_pauseExecution; | ||
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; | ||
})(); | ||
} |
@@ -1,2 +0,2 @@ | ||
/** @license React v16.6.1 | ||
/** @license React v0.0.0-db3ae32b8 | ||
* scheduler.production.min.js | ||
@@ -10,13 +10,15 @@ * | ||
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var d=null,f=!1,h=3,k=-1,l=-1,m=!1,n=!1;function p(){if(!m){var a=d.expirationTime;n?q():n=!0;r(t,a)}} | ||
function u(){var a=d,b=d.next;if(d===b)d=null;else{var c=d.previous;d=c.next=b;b.previous=c}a.next=a.previous=null;c=a.callback;b=a.expirationTime;a=a.priorityLevel;var e=h,Q=l;h=a;l=b;try{var g=c()}finally{h=e,l=Q}if("function"===typeof g)if(g={callback:g,priorityLevel:a,expirationTime:b,next:null,previous:null},null===d)d=g.next=g.previous=g;else{c=null;a=d;do{if(a.expirationTime>=b){c=a;break}a=a.next}while(a!==d);null===c?c=d:c===d&&(d=g,p());b=c.previous;b.next=c.previous=g;g.next=c;g.previous= | ||
b}}function v(){if(-1===k&&null!==d&&1===d.priorityLevel){m=!0;try{do u();while(null!==d&&1===d.priorityLevel)}finally{m=!1,null!==d?p():n=!1}}}function t(a){m=!0;var b=f;f=a;try{if(a)for(;null!==d;){var c=exports.unstable_now();if(d.expirationTime<=c){do u();while(null!==d&&d.expirationTime<=c)}else break}else if(null!==d){do u();while(null!==d&&!w())}}finally{m=!1,f=b,null!==d?p():n=!1,v()}} | ||
var x=Date,y="function"===typeof setTimeout?setTimeout:void 0,z="function"===typeof clearTimeout?clearTimeout:void 0,A="function"===typeof requestAnimationFrame?requestAnimationFrame:void 0,B="function"===typeof cancelAnimationFrame?cancelAnimationFrame:void 0,C,D;function E(a){C=A(function(b){z(D);a(b)});D=y(function(){B(C);a(exports.unstable_now())},100)} | ||
if("object"===typeof performance&&"function"===typeof performance.now){var F=performance;exports.unstable_now=function(){return F.now()}}else exports.unstable_now=function(){return x.now()};var r,q,w; | ||
if("undefined"!==typeof window&&window._schedMock){var G=window._schedMock;r=G[0];q=G[1];w=G[2]}else if("undefined"===typeof window||"function"!==typeof window.addEventListener){var H=null,I=-1,J=function(a,b){if(null!==H){var c=H;H=null;try{I=b,c(a)}finally{I=-1}}};r=function(a,b){-1!==I?setTimeout(r,0,a,b):(H=a,setTimeout(J,b,!0,b),setTimeout(J,1073741823,!1,1073741823))};q=function(){H=null};w=function(){return!1};exports.unstable_now=function(){return-1===I?0:I}}else{"undefined"!==typeof console&& | ||
("function"!==typeof A&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),"function"!==typeof B&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"));var K=null,L=!1,M=-1,N=!1,O=!1,P=0,R=33,S=33;w=function(){return P<=exports.unstable_now()};var T="__reactIdleCallback$"+Math.random().toString(36).slice(2); | ||
window.addEventListener("message",function(a){if(a.source===window&&a.data===T){L=!1;a=K;var b=M;K=null;M=-1;var c=exports.unstable_now(),e=!1;if(0>=P-c)if(-1!==b&&b<=c)e=!0;else{N||(N=!0,E(U));K=a;M=b;return}if(null!==a){O=!0;try{a(e)}finally{O=!1}}}},!1);var U=function(a){if(null!==K){E(U);var b=a-P+S;b<S&&R<S?(8>b&&(b=8),S=b<R?R:b):R=b;P=a+S;L||(L=!0,window.postMessage(T,"*"))}else N=!1};r=function(a,b){K=a;M=b;O||0>b?window.postMessage(T,"*"):N||(N=!0,E(U))};q=function(){K=null;L=!1;M=-1}} | ||
exports.unstable_ImmediatePriority=1;exports.unstable_UserBlockingPriority=2;exports.unstable_NormalPriority=3;exports.unstable_IdlePriority=5;exports.unstable_LowPriority=4;exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=h,e=k;h=a;k=exports.unstable_now();try{return b()}finally{h=c,k=e,v()}}; | ||
exports.unstable_scheduleCallback=function(a,b){var c=-1!==k?k:exports.unstable_now();if("object"===typeof b&&null!==b&&"number"===typeof b.timeout)b=c+b.timeout;else switch(h){case 1:b=c+-1;break;case 2:b=c+250;break;case 5:b=c+1073741823;break;case 4:b=c+1E4;break;default:b=c+5E3}a={callback:a,priorityLevel:h,expirationTime:b,next:null,previous:null};if(null===d)d=a.next=a.previous=a,p();else{c=null;var e=d;do{if(e.expirationTime>b){c=e;break}e=e.next}while(e!==d);null===c?c=d:c===d&&(d=a,p()); | ||
b=c.previous;b.next=c.previous=a;a.next=c;a.previous=b}return a};exports.unstable_cancelCallback=function(a){var b=a.next;if(null!==b){if(b===a)d=null;else{a===d&&(d=b);var c=a.previous;c.next=b;b.previous=c}a.next=a.previous=null}};exports.unstable_wrapCallback=function(a){var b=h;return function(){var c=h,e=k;h=b;k=exports.unstable_now();try{return a.apply(this,arguments)}finally{h=c,k=e,v()}}};exports.unstable_getCurrentPriorityLevel=function(){return h}; | ||
exports.unstable_shouldYield=function(){return!f&&(null!==d&&d.expirationTime<l||w())}; | ||
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var d=void 0,e=void 0,g=void 0,m=void 0,n=void 0;exports.unstable_now=void 0;exports.unstable_forceFrameRate=void 0; | ||
if("undefined"===typeof window||"function"!==typeof MessageChannel){var p=null,q=null,r=function(){if(null!==p)try{var a=exports.unstable_now();p(!0,a);p=null}catch(b){throw setTimeout(r,0),b;}};exports.unstable_now=function(){return Date.now()};d=function(a){null!==p?setTimeout(d,0,a):(p=a,setTimeout(r,0))};e=function(a,b){q=setTimeout(a,b)};g=function(){clearTimeout(q)};m=function(){return!1};n=exports.unstable_forceFrameRate=function(){}}else{var t=window.performance,u=window.Date,v=window.setTimeout, | ||
w=window.clearTimeout,x=window.requestAnimationFrame,y=window.cancelAnimationFrame;"undefined"!==typeof console&&("function"!==typeof x&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),"function"!==typeof y&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"));exports.unstable_now="object"===typeof t&& | ||
"function"===typeof t.now?function(){return t.now()}:function(){return u.now()};var z=!1,A=null,B=-1,C=-1,D=33.33,E=-1,F=-1,G=0,H=!1;m=function(){return exports.unstable_now()>=G};n=function(){};exports.unstable_forceFrameRate=function(a){0>a||125<a?console.error("forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported"):0<a?(D=Math.floor(1E3/a),H=!0):(D=33.33,H=!1)};var J=function(){if(null!==A){var a=exports.unstable_now(),b=0<G-a;try{A(b, | ||
a)||(A=null)}catch(c){throw I.postMessage(null),c;}}},K=new MessageChannel,I=K.port2;K.port1.onmessage=J;var L=function(a){if(null===A)F=E=-1,z=!1;else{z=!0;x(function(a){w(B);L(a)});var b=function(){G=exports.unstable_now()+D/2;J();B=v(b,3*D)};B=v(b,3*D);if(-1!==E&&.1<a-E){var c=a-E;!H&&-1!==F&&c<D&&F<D&&(D=c<F?F:c,8.33>D&&(D=8.33));F=c}E=a;G=a+D;I.postMessage(null)}};d=function(a){A=a;z||(z=!0,x(function(a){L(a)}))};e=function(a,b){C=v(function(){a(exports.unstable_now())},b)};g=function(){w(C); | ||
C=-1}}var M=null,N=null,O=null,P=3,Q=!1,R=!1,S=!1; | ||
function T(a,b){var c=a.next;if(c===a)M=null;else{a===M&&(M=c);var f=a.previous;f.next=c;c.previous=f}a.next=a.previous=null;c=a.callback;f=P;var l=O;P=a.priorityLevel;O=a;try{var h=a.expirationTime<=b;switch(P){case 1:var k=c(h);break;case 2:k=c(h);break;case 3:k=c(h);break;case 4:k=c(h);break;case 5:k=c(h)}}catch(Z){throw Z;}finally{P=f,O=l}if("function"===typeof k)if(b=a.expirationTime,a.callback=k,null===M)M=a.next=a.previous=a;else{k=null;h=M;do{if(b<=h.expirationTime){k=h;break}h=h.next}while(h!== | ||
M);null===k?k=M:k===M&&(M=a);b=k.previous;b.next=k.previous=a;a.next=k;a.previous=b}}function U(a){if(null!==N&&N.startTime<=a){do{var b=N,c=b.next;if(b===c)N=null;else{N=c;var f=b.previous;f.next=c;c.previous=f}b.next=b.previous=null;V(b,b.expirationTime)}while(null!==N&&N.startTime<=a)}}function W(a){S=!1;U(a);R||(null!==M?(R=!0,d(X)):null!==N&&e(W,N.startTime-a))} | ||
function X(a,b){R=!1;S&&(S=!1,g());U(b);Q=!0;try{if(!a)for(;null!==M&&M.expirationTime<=b;)T(M,b),b=exports.unstable_now(),U(b);else if(null!==M){do T(M,b),b=exports.unstable_now(),U(b);while(null!==M&&!m())}if(null!==M)return!0;null!==N&&e(W,N.startTime-b);return!1}finally{Q=!1}}function Y(a){switch(a){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4;default:return 5E3}} | ||
function V(a,b){if(null===M)M=a.next=a.previous=a;else{var c=null,f=M;do{if(b<f.expirationTime){c=f;break}f=f.next}while(f!==M);null===c?c=M:c===M&&(M=a);b=c.previous;b.next=c.previous=a;a.next=c;a.previous=b}}var aa=n;exports.unstable_ImmediatePriority=1;exports.unstable_UserBlockingPriority=2;exports.unstable_NormalPriority=3;exports.unstable_IdlePriority=5;exports.unstable_LowPriority=4; | ||
exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=P;P=a;try{return b()}finally{P=c}};exports.unstable_next=function(a){switch(P){case 1:case 2:case 3:var b=3;break;default:b=P}var c=P;P=b;try{return a()}finally{P=c}}; | ||
exports.unstable_scheduleCallback=function(a,b,c){var f=exports.unstable_now();if("object"===typeof c&&null!==c){var l=c.delay;l="number"===typeof l&&0<l?f+l:f;c="number"===typeof c.timeout?c.timeout:Y(a)}else c=Y(a),l=f;c=l+c;a={callback:b,priorityLevel:a,startTime:l,expirationTime:c,next:null,previous:null};if(l>f){c=l;if(null===N)N=a.next=a.previous=a;else{b=null;var h=N;do{if(c<h.startTime){b=h;break}h=h.next}while(h!==N);null===b?b=N:b===N&&(N=a);c=b.previous;c.next=b.previous=a;a.next=b;a.previous= | ||
c}null===M&&N===a&&(S?g():S=!0,e(W,l-f))}else V(a,c),R||Q||(R=!0,d(X));return a};exports.unstable_cancelCallback=function(a){var b=a.next;if(null!==b){if(a===b)a===M?M=null:a===N&&(N=null);else{a===M?M=b:a===N&&(N=b);var c=a.previous;c.next=b;b.previous=c}a.next=a.previous=null}};exports.unstable_wrapCallback=function(a){var b=P;return function(){var c=P;P=b;try{return a.apply(this,arguments)}finally{P=c}}};exports.unstable_getCurrentPriorityLevel=function(){return P}; | ||
exports.unstable_shouldYield=function(){var a=exports.unstable_now();U(a);return null!==O&&null!==M&&M.startTime<=a&&M.expirationTime<O.expirationTime||m()};exports.unstable_requestPaint=aa;exports.unstable_continueExecution=function(){R||Q||(R=!0,d(X))};exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return M}; |
{ | ||
"name": "scheduler", | ||
"version": "0.0.0-d5e1bf0-aee1b84", | ||
"version": "0.0.0-db3ae32b8", | ||
"description": "Cooperative scheduler for the browser environment.", | ||
"main": "index.js", | ||
"repository": "facebook/react", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/react.git", | ||
"directory": "packages/scheduler" | ||
}, | ||
"license": "MIT", | ||
@@ -22,5 +26,7 @@ "keywords": [ | ||
"README.md", | ||
"build-info.json", | ||
"index.js", | ||
"tracing.js", | ||
"tracing-profiling.js", | ||
"unstable_mock.js", | ||
"cjs/", | ||
@@ -33,9 +39,3 @@ "umd/" | ||
] | ||
}, | ||
"buildInfo": { | ||
"buildID": "d5e1bf0-aee1b84", | ||
"checksum": "d49ca941a51ddc0dec608acd2ce521b9a71397fc", | ||
"unstable": true, | ||
"partial": false | ||
} | ||
} | ||
} |
@@ -50,2 +50,9 @@ /** | ||
function unstable_requestPaint() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_requestPaint.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_runWithPriority() { | ||
@@ -58,2 +65,9 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_runWithPriority.apply( | ||
function unstable_next() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_next.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_wrapCallback() { | ||
@@ -73,2 +87,30 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_wrapCallback.apply( | ||
function unstable_getFirstCallbackNode() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_getFirstCallbackNode.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_pauseExecution() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_pauseExecution.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_continueExecution() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_continueExecution.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_forceFrameRate() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_forceFrameRate.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
return Object.freeze({ | ||
@@ -79,6 +121,32 @@ unstable_now: unstable_now, | ||
unstable_shouldYield: unstable_shouldYield, | ||
unstable_requestPaint: unstable_requestPaint, | ||
unstable_runWithPriority: unstable_runWithPriority, | ||
unstable_next: unstable_next, | ||
unstable_wrapCallback: unstable_wrapCallback, | ||
unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel, | ||
unstable_continueExecution: unstable_continueExecution, | ||
unstable_pauseExecution: unstable_pauseExecution, | ||
unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, | ||
unstable_forceFrameRate: unstable_forceFrameRate, | ||
get unstable_IdlePriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_IdlePriority; | ||
}, | ||
get unstable_ImmediatePriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_ImmediatePriority; | ||
}, | ||
get unstable_LowPriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_LowPriority; | ||
}, | ||
get unstable_NormalPriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_NormalPriority; | ||
}, | ||
get unstable_UserBlockingPriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_UserBlockingPriority; | ||
}, | ||
}); | ||
}); |
@@ -50,2 +50,9 @@ /** | ||
function unstable_requestPaint() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_requestPaint.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_runWithPriority() { | ||
@@ -58,2 +65,9 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_runWithPriority.apply( | ||
function unstable_next() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_next.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_wrapCallback() { | ||
@@ -73,2 +87,24 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_wrapCallback.apply( | ||
function unstable_getFirstCallbackNode() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_getFirstCallbackNode.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_pauseExecution() { | ||
return undefined; | ||
} | ||
function unstable_continueExecution() { | ||
return undefined; | ||
} | ||
function unstable_forceFrameRate() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_forceFrameRate.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
return Object.freeze({ | ||
@@ -79,6 +115,32 @@ unstable_now: unstable_now, | ||
unstable_shouldYield: unstable_shouldYield, | ||
unstable_requestPaint: unstable_requestPaint, | ||
unstable_runWithPriority: unstable_runWithPriority, | ||
unstable_next: unstable_next, | ||
unstable_wrapCallback: unstable_wrapCallback, | ||
unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel, | ||
unstable_continueExecution: unstable_continueExecution, | ||
unstable_pauseExecution: unstable_pauseExecution, | ||
unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, | ||
unstable_forceFrameRate: unstable_forceFrameRate, | ||
get unstable_IdlePriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_IdlePriority; | ||
}, | ||
get unstable_ImmediatePriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_ImmediatePriority; | ||
}, | ||
get unstable_LowPriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_LowPriority; | ||
}, | ||
get unstable_NormalPriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_NormalPriority; | ||
}, | ||
get unstable_UserBlockingPriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_UserBlockingPriority; | ||
}, | ||
}); | ||
}); |
@@ -50,2 +50,9 @@ /** | ||
function unstable_requestPaint() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_requestPaint.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_runWithPriority() { | ||
@@ -58,2 +65,9 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_runWithPriority.apply( | ||
function unstable_next() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_next.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_wrapCallback() { | ||
@@ -73,2 +87,24 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_wrapCallback.apply( | ||
function unstable_getFirstCallbackNode() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_getFirstCallbackNode.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
function unstable_pauseExecution() { | ||
return undefined; | ||
} | ||
function unstable_continueExecution() { | ||
return undefined; | ||
} | ||
function unstable_forceFrameRate() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_forceFrameRate.apply( | ||
this, | ||
arguments | ||
); | ||
} | ||
return Object.freeze({ | ||
@@ -79,6 +115,32 @@ unstable_now: unstable_now, | ||
unstable_shouldYield: unstable_shouldYield, | ||
unstable_requestPaint: unstable_requestPaint, | ||
unstable_runWithPriority: unstable_runWithPriority, | ||
unstable_next: unstable_next, | ||
unstable_wrapCallback: unstable_wrapCallback, | ||
unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel, | ||
unstable_continueExecution: unstable_continueExecution, | ||
unstable_pauseExecution: unstable_pauseExecution, | ||
unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, | ||
unstable_forceFrameRate: unstable_forceFrameRate, | ||
get unstable_IdlePriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_IdlePriority; | ||
}, | ||
get unstable_ImmediatePriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_ImmediatePriority; | ||
}, | ||
get unstable_LowPriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_LowPriority; | ||
}, | ||
get unstable_NormalPriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_NormalPriority; | ||
}, | ||
get unstable_UserBlockingPriority() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_UserBlockingPriority; | ||
}, | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
129437
23
3218
1