scheduler
Advanced tools
Comparing version 0.0.0-8b3c1e4-1d1a717 to 0.0.0-8d5403877
@@ -1,2 +0,2 @@ | ||
/** @license React v16.6.1 | ||
/** @license React v0.0.0-8d5403877 | ||
* scheduler-tracing.development.js | ||
@@ -22,4 +22,3 @@ * | ||
// In some cases, StrictMode should also double-render lifecycles. | ||
// In some cases, StrictMode should also double-render lifecycles. | ||
// This can be confusing for tests though, | ||
@@ -29,42 +28,66 @@ // And it can be bad for performance in production. | ||
// To preserve the "Pause on caught exceptions" behavior of the debugger, we | ||
// To preserve the "Pause on caught exceptions" behavior of the debugger, we | ||
// replay the begin phase of a failed component inside invokeGuardedCallback. | ||
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: | ||
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6: | ||
// Gather advanced timing metrics for Profiler subtrees. | ||
// Trace which interactions trigger each commit. | ||
// Gather advanced timing metrics for Profiler subtrees. | ||
var enableSchedulerTracing = true; // Only used in www builds. | ||
// TODO: true? Here it might just be false. | ||
// Only used in www builds. | ||
// Trace which interactions trigger each commit. | ||
var enableSchedulerTracing = true; | ||
// 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 | ||
// with their related DOM properties | ||
// Only used in www builds. | ||
// These APIs will no longer be "unstable" in the upcoming 16.7 release, | ||
// Control this behavior with a flag to support 16.6 minor releases in the meanwhile. | ||
// React Fire: prevent the value and checked attributes from syncing | ||
// 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. | ||
// These APIs will no longer be "unstable" in the upcoming 16.7 release, | ||
// Control this behavior with a flag to support 16.6 minor releases in the meanwhile. | ||
// Experimental Host Component support. | ||
var DEFAULT_THREAD_ID = 0; | ||
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107 | ||
// Counters used to generate unique IDs. | ||
// 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; // Counters used to generate unique IDs. | ||
var interactionIDCounter = 0; | ||
var threadIDCounter = 0; | ||
// Set of currently traced interactions. | ||
var threadIDCounter = 0; // Set of currently traced interactions. | ||
// Interactions "stack"– | ||
// Meaning that newly traced interactions are appended to the previously active set. | ||
// When an interaction goes out of scope, the previous set (if any) is restored. | ||
exports.__interactionsRef = null; | ||
// Listener(s) to notify when interactions begin and end. | ||
exports.__interactionsRef = null; // Listener(s) to notify when interactions begin and end. | ||
exports.__subscriberRef = null; | ||
@@ -95,3 +118,2 @@ | ||
} | ||
function unstable_getCurrent() { | ||
@@ -104,7 +126,5 @@ if (!enableSchedulerTracing) { | ||
} | ||
function unstable_getThreadID() { | ||
return ++threadIDCounter; | ||
} | ||
function unstable_trace(name, timestamp, callback) { | ||
@@ -123,14 +143,11 @@ var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; | ||
}; | ||
var prevInteractions = exports.__interactionsRef.current; | ||
// Traced interactions should stack/accumulate. | ||
var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate. | ||
// To do that, clone the current interactions. | ||
// The previous set will be restored upon completion. | ||
var interactions = new Set(prevInteractions); | ||
interactions.add(interaction); | ||
exports.__interactionsRef.current = interactions; | ||
var subscriber = exports.__subscriberRef.current; | ||
var returnValue = void 0; | ||
var returnValue; | ||
@@ -157,6 +174,5 @@ try { | ||
} finally { | ||
interaction.__count--; | ||
interaction.__count--; // If no async work was scheduled for this interaction, | ||
// Notify subscribers that it's completed. | ||
// If no async work was scheduled for this interaction, | ||
// Notify subscribers that it's completed. | ||
if (subscriber !== null && interaction.__count === 0) { | ||
@@ -172,3 +188,2 @@ subscriber.onInteractionScheduledWorkCompleted(interaction); | ||
} | ||
function unstable_wrap(callback) { | ||
@@ -182,14 +197,13 @@ var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; | ||
var wrappedInteractions = exports.__interactionsRef.current; | ||
var subscriber = exports.__subscriberRef.current; | ||
var subscriber = exports.__subscriberRef.current; | ||
if (subscriber !== null) { | ||
subscriber.onWorkScheduled(wrappedInteractions, threadID); | ||
} | ||
} // Update the pending async work count for the current interactions. | ||
// Update after calling subscribers in case of error. | ||
// Update the pending async work count for the current interactions. | ||
// Update after calling subscribers in case of error. | ||
wrappedInteractions.forEach(function (interaction) { | ||
interaction.__count++; | ||
}); | ||
var hasRun = false; | ||
@@ -200,7 +214,6 @@ | ||
exports.__interactionsRef.current = wrappedInteractions; | ||
subscriber = exports.__subscriberRef.current; | ||
try { | ||
var returnValue = void 0; | ||
var returnValue; | ||
@@ -229,7 +242,6 @@ try { | ||
// Only decrement the outstanding interaction counts once. | ||
hasRun = true; | ||
// Update pending async counts for all wrapped interactions. | ||
hasRun = true; // Update pending async counts for all wrapped interactions. | ||
// If this was the last scheduled async work for any of them, | ||
// Mark them as completed. | ||
wrappedInteractions.forEach(function (interaction) { | ||
@@ -271,2 +283,3 @@ interaction.__count--; | ||
var subscribers = null; | ||
if (enableSchedulerTracing) { | ||
@@ -292,3 +305,2 @@ subscribers = new Set(); | ||
} | ||
function unstable_unsubscribe(subscriber) { | ||
@@ -307,3 +319,2 @@ if (enableSchedulerTracing) { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -328,3 +339,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -349,3 +359,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -370,3 +379,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -391,3 +399,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -412,3 +419,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -415,0 +421,0 @@ try { |
@@ -1,2 +0,2 @@ | ||
/** @license React v16.6.1 | ||
/** @license React v0.0.0-8d5403877 | ||
* scheduler-tracing.production.min.js | ||
@@ -3,0 +3,0 @@ * |
@@ -1,2 +0,2 @@ | ||
/** @license React v16.6.1 | ||
/** @license React v0.0.0-8d5403877 | ||
* scheduler-tracing.profiling.min.js | ||
@@ -10,9 +10,8 @@ * | ||
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var g=0,m=0;exports.__interactionsRef=null;exports.__subscriberRef=null;exports.__interactionsRef={current:new Set};exports.__subscriberRef={current:null};var n=null;n=new Set;function p(e){var d=!1,a=null;n.forEach(function(c){try{c.onInteractionTraced(e)}catch(b){d||(d=!0,a=b)}});if(d)throw a;} | ||
function q(e){var d=!1,a=null;n.forEach(function(c){try{c.onInteractionScheduledWorkCompleted(e)}catch(b){d||(d=!0,a=b)}});if(d)throw a;}function r(e,d){var a=!1,c=null;n.forEach(function(b){try{b.onWorkScheduled(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}function t(e,d){var a=!1,c=null;n.forEach(function(b){try{b.onWorkStarted(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}function u(e,d){var a=!1,c=null;n.forEach(function(b){try{b.onWorkStopped(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;} | ||
function v(e,d){var a=!1,c=null;n.forEach(function(b){try{b.onWorkCanceled(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}exports.unstable_clear=function(e){var d=exports.__interactionsRef.current;exports.__interactionsRef.current=new Set;try{return e()}finally{exports.__interactionsRef.current=d}};exports.unstable_getCurrent=function(){return exports.__interactionsRef.current};exports.unstable_getThreadID=function(){return++m}; | ||
exports.unstable_trace=function(e,d,a){var c=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,b={__count:1,id:g++,name:e,timestamp:d},f=exports.__interactionsRef.current,k=new Set(f);k.add(b);exports.__interactionsRef.current=k;var h=exports.__subscriberRef.current,l=void 0;try{if(null!==h)h.onInteractionTraced(b)}finally{try{if(null!==h)h.onWorkStarted(k,c)}finally{try{l=a()}finally{exports.__interactionsRef.current=f;try{if(null!==h)h.onWorkStopped(k,c)}finally{if(b.__count--,null!==h&& | ||
0===b.__count)h.onInteractionScheduledWorkCompleted(b)}}}}return l}; | ||
exports.unstable_wrap=function(e){function d(){var d=exports.__interactionsRef.current;exports.__interactionsRef.current=c;b=exports.__subscriberRef.current;try{var h=void 0;try{if(null!==b)b.onWorkStarted(c,a)}finally{try{h=e.apply(void 0,arguments)}finally{if(exports.__interactionsRef.current=d,null!==b)b.onWorkStopped(c,a)}}return h}finally{f||(f=!0,c.forEach(function(a){a.__count--;if(null!==b&&0===a.__count)b.onInteractionScheduledWorkCompleted(a)}))}}var a=1<arguments.length&&void 0!==arguments[1]? | ||
arguments[1]:0,c=exports.__interactionsRef.current,b=exports.__subscriberRef.current;if(null!==b)b.onWorkScheduled(c,a);c.forEach(function(a){a.__count++});var f=!1;d.cancel=function(){b=exports.__subscriberRef.current;try{if(null!==b)b.onWorkCanceled(c,a)}finally{c.forEach(function(a){a.__count--;if(b&&0===a.__count)b.onInteractionScheduledWorkCompleted(a)})}};return d}; | ||
exports.unstable_subscribe=function(e){n.add(e);1===n.size&&(exports.__subscriberRef.current={onInteractionScheduledWorkCompleted:q,onInteractionTraced:p,onWorkCanceled:v,onWorkScheduled:r,onWorkStarted:t,onWorkStopped:u})};exports.unstable_unsubscribe=function(e){n.delete(e);0===n.size&&(exports.__subscriberRef.current=null)}; | ||
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var g=0,l=0;exports.__interactionsRef=null;exports.__subscriberRef=null;exports.__interactionsRef={current:new Set};exports.__subscriberRef={current:null};var m=null;m=new Set;function n(e){var d=!1,a=null;m.forEach(function(c){try{c.onInteractionTraced(e)}catch(b){d||(d=!0,a=b)}});if(d)throw a;} | ||
function p(e){var d=!1,a=null;m.forEach(function(c){try{c.onInteractionScheduledWorkCompleted(e)}catch(b){d||(d=!0,a=b)}});if(d)throw a;}function q(e,d){var a=!1,c=null;m.forEach(function(b){try{b.onWorkScheduled(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}function r(e,d){var a=!1,c=null;m.forEach(function(b){try{b.onWorkStarted(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}function t(e,d){var a=!1,c=null;m.forEach(function(b){try{b.onWorkStopped(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;} | ||
function u(e,d){var a=!1,c=null;m.forEach(function(b){try{b.onWorkCanceled(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}exports.unstable_clear=function(e){var d=exports.__interactionsRef.current;exports.__interactionsRef.current=new Set;try{return e()}finally{exports.__interactionsRef.current=d}};exports.unstable_getCurrent=function(){return exports.__interactionsRef.current};exports.unstable_getThreadID=function(){return++l}; | ||
exports.unstable_trace=function(e,d,a){var c=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,b={__count:1,id:g++,name:e,timestamp:d},f=exports.__interactionsRef.current,k=new Set(f);k.add(b);exports.__interactionsRef.current=k;var h=exports.__subscriberRef.current;try{if(null!==h)h.onInteractionTraced(b)}finally{try{if(null!==h)h.onWorkStarted(k,c)}finally{try{var v=a()}finally{exports.__interactionsRef.current=f;try{if(null!==h)h.onWorkStopped(k,c)}finally{if(b.__count--,null!==h&&0===b.__count)h.onInteractionScheduledWorkCompleted(b)}}}}return v}; | ||
exports.unstable_wrap=function(e){function d(){var d=exports.__interactionsRef.current;exports.__interactionsRef.current=c;b=exports.__subscriberRef.current;try{try{if(null!==b)b.onWorkStarted(c,a)}finally{try{var h=e.apply(void 0,arguments)}finally{if(exports.__interactionsRef.current=d,null!==b)b.onWorkStopped(c,a)}}return h}finally{f||(f=!0,c.forEach(function(a){a.__count--;if(null!==b&&0===a.__count)b.onInteractionScheduledWorkCompleted(a)}))}}var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]: | ||
0,c=exports.__interactionsRef.current,b=exports.__subscriberRef.current;if(null!==b)b.onWorkScheduled(c,a);c.forEach(function(a){a.__count++});var f=!1;d.cancel=function(){b=exports.__subscriberRef.current;try{if(null!==b)b.onWorkCanceled(c,a)}finally{c.forEach(function(a){a.__count--;if(b&&0===a.__count)b.onInteractionScheduledWorkCompleted(a)})}};return d}; | ||
exports.unstable_subscribe=function(e){m.add(e);1===m.size&&(exports.__subscriberRef.current={onInteractionScheduledWorkCompleted:p,onInteractionTraced:n,onWorkCanceled:u,onWorkScheduled:q,onWorkStarted:r,onWorkStopped:t})};exports.unstable_unsubscribe=function(e){m.delete(e);0===m.size&&(exports.__subscriberRef.current=null)}; |
@@ -1,2 +0,2 @@ | ||
/** @license React v16.6.1 | ||
/** @license React v0.0.0-8d5403877 | ||
* scheduler.development.js | ||
@@ -20,5 +20,475 @@ * | ||
var enableSchedulerDebugging = false; | ||
var enableIsInputPending = false; | ||
var requestIdleCallbackBeforeFirstFrame = false; | ||
var requestTimerEventBeforeFirstFrame = false; | ||
var enableMessageLoopImplementation = false; | ||
// 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; | ||
var requestHostTimeout; | ||
var cancelHostTimeout; | ||
var shouldYieldToHost; | ||
var requestPaint; | ||
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; | ||
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; | ||
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; | ||
}; | ||
} | ||
function push(heap, node) { | ||
var index = heap.length; | ||
heap.push(node); | ||
siftUp(heap, node, index); | ||
} | ||
function peek(heap) { | ||
var first = heap[0]; | ||
return first === undefined ? null : first; | ||
} | ||
function pop(heap) { | ||
var first = heap[0]; | ||
if (first !== undefined) { | ||
var last = heap.pop(); | ||
if (last !== first) { | ||
heap[0] = last; | ||
siftDown(heap, last, 0); | ||
} | ||
return first; | ||
} else { | ||
return null; | ||
} | ||
} | ||
function siftUp(heap, node, index) { | ||
while (true) { | ||
var parentIndex = Math.floor((index - 1) / 2); | ||
var parent = heap[parentIndex]; | ||
if (parent !== undefined && compare(parent, node) > 0) { | ||
// The parent is larger. Swap positions. | ||
heap[parentIndex] = node; | ||
heap[index] = parent; | ||
index = parentIndex; | ||
} else { | ||
// The parent is smaller. Exit. | ||
return; | ||
} | ||
} | ||
} | ||
function siftDown(heap, node, index) { | ||
var length = heap.length; | ||
while (index < length) { | ||
var leftIndex = (index + 1) * 2 - 1; | ||
var left = heap[leftIndex]; | ||
var rightIndex = leftIndex + 1; | ||
var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those. | ||
if (left !== undefined && compare(left, node) < 0) { | ||
if (right !== undefined && compare(right, left) < 0) { | ||
heap[index] = right; | ||
heap[rightIndex] = node; | ||
index = rightIndex; | ||
} else { | ||
heap[index] = left; | ||
heap[leftIndex] = node; | ||
index = leftIndex; | ||
} | ||
} else if (right !== undefined && compare(right, node) < 0) { | ||
heap[index] = right; | ||
heap[rightIndex] = node; | ||
index = rightIndex; | ||
} else { | ||
// Neither child is smaller. Exit. | ||
return; | ||
} | ||
} | ||
} | ||
function compare(a, b) { | ||
// Compare sort index first, then task id. | ||
var diff = a.sortIndex - b.sortIndex; | ||
return diff !== 0 ? diff : a.id - b.id; | ||
} | ||
/* eslint-disable no-var */ | ||
// TODO: Use symbols? | ||
var ImmediatePriority = 1; | ||
@@ -28,150 +498,125 @@ var UserBlockingPriority = 2; | ||
var LowPriority = 4; | ||
var IdlePriority = 5; | ||
// Max 31 bit integer. The max integer size in V8 for 32-bit systems. | ||
var IdlePriority = 5; // Max 31 bit integer. The max integer size in V8 for 32-bit systems. | ||
// Math.pow(2, 30) - 1 | ||
// 0b111111111111111111111111111111 | ||
var maxSigned31BitInt = 1073741823; | ||
// Times out immediately | ||
var IMMEDIATE_PRIORITY_TIMEOUT = -1; | ||
// Eventually times out | ||
var maxSigned31BitInt = 1073741823; // Times out immediately | ||
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out | ||
var USER_BLOCKING_PRIORITY = 250; | ||
var NORMAL_PRIORITY_TIMEOUT = 5000; | ||
var LOW_PRIORITY_TIMEOUT = 10000; | ||
// Never times out | ||
var IDLE_PRIORITY = maxSigned31BitInt; | ||
var LOW_PRIORITY_TIMEOUT = 10000; // Never times out | ||
// Callbacks are stored as a circular, doubly linked list. | ||
var firstCallbackNode = null; | ||
var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap | ||
var currentDidTimeout = false; | ||
var currentPriorityLevel = NormalPriority; | ||
var currentEventStartTime = -1; | ||
var currentExpirationTime = -1; | ||
var taskQueue = []; | ||
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. | ||
// This is set when a callback is being executed, to prevent re-entrancy. | ||
var isExecutingCallback = false; | ||
var taskIdCounter = 0; // Pausing the scheduler is useful for debugging. | ||
var isSchedulerPaused = false; | ||
var currentTask = null; | ||
var currentPriorityLevel = NormalPriority; // 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 scheduler_flushTaskAtPriority_Immediate(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
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_UserBlocking(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
function flushFirstCallback() { | ||
var flushedNode = firstCallbackNode; | ||
function scheduler_flushTaskAtPriority_Normal(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
// Remove the node 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; | ||
} else { | ||
var lastCallbackNode = firstCallbackNode.previous; | ||
firstCallbackNode = lastCallbackNode.next = next; | ||
next.previous = lastCallbackNode; | ||
} | ||
function scheduler_flushTaskAtPriority_Low(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
flushedNode.next = flushedNode.previous = null; | ||
function scheduler_flushTaskAtPriority_Idle(callback, didTimeout) { | ||
return callback(didTimeout); | ||
} | ||
// Now it's safe to call the callback. | ||
var callback = flushedNode.callback; | ||
var expirationTime = flushedNode.expirationTime; | ||
var priorityLevel = flushedNode.priorityLevel; | ||
function flushTask(task, callback, currentTime) { | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousExpirationTime = currentExpirationTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentExpirationTime = expirationTime; | ||
var continuationCallback; | ||
var previousTask = currentTask; | ||
currentPriorityLevel = task.priorityLevel; | ||
currentTask = task; | ||
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. | ||
var continuationCallback; | ||
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; | ||
} | ||
return typeof continuationCallback === 'function' ? continuationCallback : null; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentExpirationTime = previousExpirationTime; | ||
currentTask = previousTask; | ||
} | ||
} | ||
// A callback may return a continuation. The continuation should be scheduled | ||
// with the same priority and expiration as the just-finished callback. | ||
if (typeof continuationCallback === 'function') { | ||
var continuationNode = { | ||
callback: continuationCallback, | ||
priorityLevel: priorityLevel, | ||
expirationTime: expirationTime, | ||
next: null, | ||
previous: null | ||
}; | ||
function advanceTimers(currentTime) { | ||
// Check for tasks that are no longer delayed and add them to the queue. | ||
var timer = peek(timerQueue); | ||
// Insert the new callback into the list, sorted by its expiration. This is | ||
// almost the same as the code in `scheduleCallback`, except the callback | ||
// is inserted into the list *before* callbacks of equal expiration instead | ||
// of after. | ||
if (firstCallbackNode === null) { | ||
// This is the first callback in the list. | ||
firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode; | ||
while (timer !== null) { | ||
if (timer.callback === null) { | ||
// Timer was cancelled. | ||
pop(timerQueue); | ||
} else if (timer.startTime <= currentTime) { | ||
// Timer fired. Transfer to the task queue. | ||
pop(timerQueue); | ||
timer.sortIndex = timer.expirationTime; | ||
push(taskQueue, timer); | ||
} else { | ||
var nextAfterContinuation = null; | ||
var node = firstCallbackNode; | ||
do { | ||
if (node.expirationTime >= expirationTime) { | ||
// This callback expires at or after the continuation. We will insert | ||
// the continuation *before* this callback. | ||
nextAfterContinuation = node; | ||
break; | ||
} | ||
node = node.next; | ||
} while (node !== firstCallbackNode); | ||
// Remaining timers are pending. | ||
return; | ||
} | ||
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(); | ||
} | ||
var previous = nextAfterContinuation.previous; | ||
previous.next = nextAfterContinuation.previous = continuationNode; | ||
continuationNode.next = nextAfterContinuation; | ||
continuationNode.previous = previous; | ||
} | ||
timer = peek(timerQueue); | ||
} | ||
} | ||
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(); | ||
} else { | ||
isHostCallbackScheduled = false; | ||
function handleTimeout(currentTime) { | ||
isHostTimeoutScheduled = false; | ||
advanceTimers(currentTime); | ||
if (!isHostCallbackScheduled) { | ||
if (peek(taskQueue) !== null) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} else { | ||
var firstTimer = peek(timerQueue); | ||
if (firstTimer !== null) { | ||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); | ||
} | ||
@@ -182,41 +627,62 @@ } | ||
function flushWork(didTimeout) { | ||
isExecutingCallback = true; | ||
var previousDidTimeout = currentDidTimeout; | ||
currentDidTimeout = didTimeout; | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
// 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(); | ||
} | ||
isPerformingWork = true; | ||
try { | ||
if (didTimeout) { | ||
// 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; | ||
} | ||
var currentTime = initialTime; | ||
advanceTimers(currentTime); | ||
var task = peek(taskQueue); | ||
while (task !== null && !(enableSchedulerDebugging && isSchedulerPaused)) { | ||
if (task.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { | ||
// This task hasn't expired, and we've reached the deadline. | ||
break; | ||
} | ||
var callback = task.callback; | ||
if (callback !== null) { | ||
task.callback = null; | ||
var continuation = flushTask(task, callback, currentTime); | ||
if (continuation !== null) { | ||
task.callback = continuation; | ||
} else { | ||
if (task === peek(taskQueue)) { | ||
pop(taskQueue); | ||
} | ||
} | ||
currentTime = exports.unstable_now(); | ||
advanceTimers(currentTime); | ||
} else { | ||
pop(taskQueue); | ||
} | ||
task = peek(taskQueue); | ||
} // Return whether there's additional work | ||
if (task !== null) { | ||
return true; | ||
} else { | ||
// Keep flushing callbacks until we run out of time in the frame. | ||
if (firstCallbackNode !== null) { | ||
do { | ||
flushFirstCallback(); | ||
} while (firstCallbackNode !== null && !shouldYieldToHost()); | ||
var firstTimer = peek(timerQueue); | ||
if (firstTimer !== null) { | ||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); | ||
} | ||
return false; | ||
} | ||
} finally { | ||
isExecutingCallback = false; | ||
currentDidTimeout = previousDidTimeout; | ||
if (firstCallbackNode !== null) { | ||
// There's still work remaining. Request another callback. | ||
ensureHostCallbackIsScheduled(); | ||
} else { | ||
isHostCallbackScheduled = false; | ||
} | ||
// Before exiting, flush all the immediate work that was scheduled. | ||
flushImmediateWork(); | ||
isPerformingWork = false; | ||
} | ||
@@ -233,2 +699,3 @@ } | ||
break; | ||
default: | ||
@@ -239,5 +706,3 @@ priorityLevel = NormalPriority; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentEventStartTime = exports.unstable_now(); | ||
@@ -248,7 +713,30 @@ 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; | ||
} | ||
} | ||
@@ -261,5 +749,3 @@ | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = parentPriorityLevel; | ||
currentEventStartTime = exports.unstable_now(); | ||
@@ -270,4 +756,2 @@ try { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
flushImmediateWork(); | ||
} | ||
@@ -277,360 +761,120 @@ }; | ||
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; | ||
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; | ||
} 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; | ||
} | ||
} | ||
case UserBlockingPriority: | ||
return USER_BLOCKING_PRIORITY; | ||
var newNode = { | ||
callback: callback, | ||
priorityLevel: currentPriorityLevel, | ||
expirationTime: expirationTime, | ||
next: null, | ||
previous: null | ||
}; | ||
case IdlePriority: | ||
return IDLE_PRIORITY; | ||
// 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(); | ||
} else { | ||
var next = null; | ||
var node = firstCallbackNode; | ||
do { | ||
if (node.expirationTime > expirationTime) { | ||
// The new callback expires before this one. | ||
next = node; | ||
break; | ||
} | ||
node = node.next; | ||
} while (node !== firstCallbackNode); | ||
case LowPriority: | ||
return LOW_PRIORITY_TIMEOUT; | ||
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(); | ||
} | ||
var previous = next.previous; | ||
previous.next = next.previous = newNode; | ||
newNode.next = next; | ||
newNode.previous = previous; | ||
case NormalPriority: | ||
default: | ||
return NORMAL_PRIORITY_TIMEOUT; | ||
} | ||
return newNode; | ||
} | ||
function unstable_cancelCallback(callbackNode) { | ||
var next = callbackNode.next; | ||
if (next === null) { | ||
// Already cancelled. | ||
return; | ||
} | ||
function unstable_scheduleCallback(priorityLevel, callback, options) { | ||
var currentTime = exports.unstable_now(); | ||
var startTime; | ||
var timeout; | ||
if (next === callbackNode) { | ||
// This is the only scheduled callback. Clear the list. | ||
firstCallbackNode = null; | ||
} else { | ||
// Remove the callback from its position in the list. | ||
if (callbackNode === firstCallbackNode) { | ||
firstCallbackNode = next; | ||
} | ||
var previous = callbackNode.previous; | ||
previous.next = next; | ||
next.previous = previous; | ||
} | ||
if (typeof options === 'object' && options !== null) { | ||
var delay = options.delay; | ||
callbackNode.next = callbackNode.previous = null; | ||
} | ||
function unstable_getCurrentPriorityLevel() { | ||
return currentPriorityLevel; | ||
} | ||
function unstable_shouldYield() { | ||
return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || 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. | ||
// 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); | ||
if (typeof delay === 'number' && delay > 0) { | ||
startTime = currentTime + delay; | ||
} else { | ||
_callback = cb; | ||
setTimeout(_flushCallback, ms, true, ms); | ||
setTimeout(_flushCallback, maxSigned31BitInt, false, maxSigned31BitInt); | ||
startTime = currentTime; | ||
} | ||
}; | ||
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'); | ||
} | ||
timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel); | ||
} else { | ||
timeout = timeoutForPriorityLevel(priorityLevel); | ||
startTime = currentTime; | ||
} | ||
var scheduledHostCallback = null; | ||
var isMessageEventScheduled = false; | ||
var timeoutTime = -1; | ||
var expirationTime = startTime + timeout; | ||
var newTask = { | ||
id: taskIdCounter++, | ||
callback: callback, | ||
priorityLevel: priorityLevel, | ||
startTime: startTime, | ||
expirationTime: expirationTime, | ||
sortIndex: -1 | ||
}; | ||
var isAnimationFrameScheduled = false; | ||
if (startTime > currentTime) { | ||
// This is a delayed task. | ||
newTask.sortIndex = startTime; | ||
push(timerQueue, newTask); | ||
var isFlushingHostCallback = false; | ||
if (peek(taskQueue) === null && newTask === peek(timerQueue)) { | ||
// 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. | ||
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(); | ||
}; | ||
requestHostTimeout(handleTimeout, startTime - currentTime); | ||
} | ||
} else { | ||
newTask.sortIndex = expirationTime; | ||
push(taskQueue, newTask); // Schedule a host callback, if needed. If we're already performing work, | ||
// wait until the next time we yield. | ||
// 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; | ||
if (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
} | ||
isMessageEventScheduled = false; | ||
return newTask; | ||
} | ||
var prevScheduledCallback = scheduledHostCallback; | ||
var prevTimeoutTime = timeoutTime; | ||
scheduledHostCallback = null; | ||
timeoutTime = -1; | ||
function unstable_pauseExecution() { | ||
isSchedulerPaused = true; | ||
} | ||
var currentTime = exports.unstable_now(); | ||
function unstable_continueExecution() { | ||
isSchedulerPaused = false; | ||
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 (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
} | ||
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); | ||
function unstable_getFirstCallbackNode() { | ||
return peek(taskQueue); | ||
} | ||
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; | ||
} | ||
function unstable_cancelCallback(task) { | ||
// Null out the callback to indicate the task has been canceled. (Can't remove | ||
// from the queue because you can't remove arbitrary nodes from an array based | ||
// heap, only the first one.) | ||
task.callback = null; | ||
} | ||
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, '*'); | ||
} | ||
}; | ||
function unstable_getCurrentPriorityLevel() { | ||
return currentPriorityLevel; | ||
} | ||
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; | ||
}; | ||
function unstable_shouldYield() { | ||
var currentTime = exports.unstable_now(); | ||
advanceTimers(currentTime); | ||
var firstTask = peek(taskQueue); | ||
return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost(); | ||
} | ||
var unstable_requestPaint = requestPaint; | ||
exports.unstable_ImmediatePriority = ImmediatePriority; | ||
@@ -642,2 +886,3 @@ exports.unstable_UserBlockingPriority = UserBlockingPriority; | ||
exports.unstable_runWithPriority = unstable_runWithPriority; | ||
exports.unstable_next = unstable_next; | ||
exports.unstable_scheduleCallback = unstable_scheduleCallback; | ||
@@ -648,3 +893,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-8d5403877 | ||
* scheduler.production.min.js | ||
@@ -10,13 +10,14 @@ * | ||
'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 f,g,h,k,p; | ||
if("undefined"===typeof window||"function"!==typeof MessageChannel){var r=null,t=null,u=function(){if(null!==r)try{var a=exports.unstable_now();r(!0,a);r=null}catch(b){throw setTimeout(u,0),b;}};exports.unstable_now=function(){return Date.now()};f=function(a){null!==r?setTimeout(f,0,a):(r=a,setTimeout(u,0))};g=function(a,b){t=setTimeout(a,b)};h=function(){clearTimeout(t)};k=function(){return!1};p=exports.unstable_forceFrameRate=function(){}}else{var v=window.performance,aa=window.Date,w=window.setTimeout, | ||
x=window.clearTimeout,y=window.requestAnimationFrame,ba=window.cancelAnimationFrame;"undefined"!==typeof console&&("function"!==typeof y&&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 ba&&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 v&& | ||
"function"===typeof v.now?function(){return v.now()}:function(){return aa.now()};var z=!1,A=null,C=-1,D=-1,E=33.33,F=-1,G=-1,H=0,I=!1;k=function(){return exports.unstable_now()>=H};p=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?(E=Math.floor(1E3/a),I=!0):(E=33.33,I=!1)};var K=function(){if(null!==A){var a=exports.unstable_now(),b=0<H-a;try{A(b, | ||
a)||(A=null)}catch(c){throw J.postMessage(null),c;}}},da=new MessageChannel,J=da.port2;da.port1.onmessage=K;var ea=function(a){if(null===A)G=F=-1,z=!1;else{z=!0;y(function(a){x(C);ea(a)});var b=function(){H=exports.unstable_now()+E/2;K();C=w(b,3*E)};C=w(b,3*E);if(-1!==F&&.1<a-F){var c=a-F;!I&&-1!==G&&c<E&&G<E&&(E=c<G?G:c,8.33>E&&(E=8.33));G=c}F=a;H=a+E;J.postMessage(null)}};f=function(a){A=a;z||(z=!0,y(function(a){ea(a)}))};g=function(a,b){D=w(function(){a(exports.unstable_now())},b)};h=function(){x(D); | ||
D=-1}}function L(a,b){var c=a.length;a.push(b);a:for(;;){var e=Math.floor((c-1)/2),d=a[e];if(void 0!==d&&0<M(d,b))a[e]=b,a[c]=d,c=e;else break a}}function N(a){a=a[0];return void 0===a?null:a}function O(a){var b=a[0];if(void 0!==b){var c=a.pop();if(c!==b){a[0]=c;a:for(var e=0,d=a.length;e<d;){var m=2*(e+1)-1,l=a[m],q=m+1,n=a[q];if(void 0!==l&&0>M(l,c))void 0!==n&&0>M(n,l)?(a[e]=n,a[q]=c,e=q):(a[e]=l,a[m]=c,e=m);else if(void 0!==n&&0>M(n,c))a[e]=n,a[q]=c,e=q;else break a}}return b}return null} | ||
function M(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}var P=[],Q=[],fa=0,R=null,S=3,T=!1,V=!1,W=!1;function X(a){for(var b=N(Q);null!==b;){if(null===b.callback)O(Q);else if(b.startTime<=a)O(Q),b.sortIndex=b.expirationTime,L(P,b);else break;b=N(Q)}}function Y(a){W=!1;X(a);if(!V)if(null!==N(P))V=!0,f(Z);else{var b=N(Q);null!==b&&g(Y,b.startTime-a)}} | ||
function Z(a,b){V=!1;W&&(W=!1,h());T=!0;try{X(b);for(var c=N(P);null!==c&&(!(c.expirationTime>b)||a&&!k());){var e=c.callback;if(null!==e){c.callback=null;a:{var d=void 0,m=c,l=e,q=b,n=S,ia=R;S=m.priorityLevel;R=m;try{var B=m.expirationTime<=q;switch(S){case 1:d=l(B);break;case 2:d=l(B);break;case 3:d=l(B);break;case 4:d=l(B);break;case 5:d=l(B)}var U="function"===typeof d?d:null;break a}finally{S=n,R=ia}U=void 0}null!==U?c.callback=U:c===N(P)&&O(P);b=exports.unstable_now();X(b)}else O(P);c=N(P)}if(null!== | ||
c)return!0;var ca=N(Q);null!==ca&&g(Y,ca.startTime-b);return!1}finally{T=!1}}function ha(a){switch(a){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4;default:return 5E3}}var ja=p;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=S;S=a;try{return b()}finally{S=c}};exports.unstable_next=function(a){switch(S){case 1:case 2:case 3:var b=3;break;default:b=S}var c=S;S=b;try{return a()}finally{S=c}}; | ||
exports.unstable_scheduleCallback=function(a,b,c){var e=exports.unstable_now();if("object"===typeof c&&null!==c){var d=c.delay;d="number"===typeof d&&0<d?e+d:e;c="number"===typeof c.timeout?c.timeout:ha(a)}else c=ha(a),d=e;c=d+c;a={id:fa++,callback:b,priorityLevel:a,startTime:d,expirationTime:c,sortIndex:-1};d>e?(a.sortIndex=d,L(Q,a),null===N(P)&&a===N(Q)&&(W?h():W=!0,g(Y,d-e))):(a.sortIndex=c,L(P,a),V||T||(V=!0,f(Z)));return a};exports.unstable_cancelCallback=function(a){a.callback=null}; | ||
exports.unstable_wrapCallback=function(a){var b=S;return function(){var c=S;S=b;try{return a.apply(this,arguments)}finally{S=c}}};exports.unstable_getCurrentPriorityLevel=function(){return S};exports.unstable_shouldYield=function(){var a=exports.unstable_now();X(a);var b=N(P);return b!==R&&null!==R&&null!==b&&null!==b.callback&&b.startTime<=a&&b.expirationTime<R.expirationTime||k()};exports.unstable_requestPaint=ja;exports.unstable_continueExecution=function(){V||T||(V=!0,f(Z))}; | ||
exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return N(P)}; |
{ | ||
"name": "scheduler", | ||
"version": "0.0.0-8b3c1e4-1d1a717", | ||
"version": "0.0.0-8d5403877", | ||
"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,20 +39,3 @@ "umd/" | ||
] | ||
}, | ||
"buildInfo": { | ||
"buildID": "8b3c1e4-1d1a717", | ||
"checksum": "d49ca941a51ddc0dec608acd2ce521b9a71397fc", | ||
"unstable": true, | ||
"partial": false, | ||
"packages": [ | ||
"create-subscription", | ||
"jest-react", | ||
"react", | ||
"react-art", | ||
"react-dom", | ||
"react-is", | ||
"react-reconciler", | ||
"react-test-renderer", | ||
"scheduler" | ||
] | ||
} | ||
} | ||
} |
@@ -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
120064
23
2972
1