scheduler
Advanced tools
Comparing version 0.0.0-50b50c26f to 0.0.0-553440bd1
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-50b50c26f | ||
/** @license React vundefined | ||
* scheduler-tracing.development.js | ||
@@ -12,4 +12,2 @@ * | ||
if (process.env.NODE_ENV !== "production") { | ||
@@ -19,82 +17,15 @@ (function() { | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs. | ||
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers: | ||
// In some cases, StrictMode should also double-render lifecycles. | ||
// This can be confusing for tests though, | ||
// And it can be bad for performance in production. | ||
// This feature flag can be used to control the behavior: | ||
// 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: | ||
// Gather advanced timing metrics for Profiler subtrees. | ||
// Trace which interactions trigger each commit. | ||
var enableSchedulerTracing = true; | ||
// 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. | ||
// Disables yielding during render in Concurrent Mode. Used for debugging only. | ||
// React Fire: prevent the value and checked attributes from syncing | ||
// with their related DOM properties | ||
// 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. | ||
// 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 Events support. Only used in www builds for now. | ||
// 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 | ||
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; | ||
if (enableSchedulerTracing) { | ||
{ | ||
exports.__interactionsRef = { | ||
@@ -107,7 +38,3 @@ current: new Set() | ||
} | ||
function unstable_clear(callback) { | ||
if (!enableSchedulerTracing) { | ||
return callback(); | ||
} | ||
@@ -123,22 +50,13 @@ var prevInteractions = exports.__interactionsRef.current; | ||
} | ||
function unstable_getCurrent() { | ||
if (!enableSchedulerTracing) { | ||
return null; | ||
} else { | ||
{ | ||
return exports.__interactionsRef.current; | ||
} | ||
} | ||
function unstable_getThreadID() { | ||
return ++threadIDCounter; | ||
} | ||
function unstable_trace(name, timestamp, callback) { | ||
var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID; | ||
if (!enableSchedulerTracing) { | ||
return callback(); | ||
} | ||
var interaction = { | ||
@@ -150,14 +68,11 @@ __count: 1, | ||
}; | ||
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; | ||
@@ -184,6 +99,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) { | ||
@@ -199,23 +113,17 @@ subscriber.onInteractionScheduledWorkCompleted(interaction); | ||
} | ||
function unstable_wrap(callback) { | ||
var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID; | ||
if (!enableSchedulerTracing) { | ||
return callback; | ||
} | ||
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; | ||
@@ -226,7 +134,6 @@ | ||
exports.__interactionsRef.current = wrappedInteractions; | ||
subscriber = exports.__subscriberRef.current; | ||
try { | ||
var returnValue = void 0; | ||
var returnValue; | ||
@@ -255,7 +162,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) { | ||
@@ -297,3 +203,4 @@ interaction.__count--; | ||
var subscribers = null; | ||
if (enableSchedulerTracing) { | ||
{ | ||
subscribers = new Set(); | ||
@@ -303,3 +210,3 @@ } | ||
function unstable_subscribe(subscriber) { | ||
if (enableSchedulerTracing) { | ||
{ | ||
subscribers.add(subscriber); | ||
@@ -319,5 +226,4 @@ | ||
} | ||
function unstable_unsubscribe(subscriber) { | ||
if (enableSchedulerTracing) { | ||
{ | ||
subscribers.delete(subscriber); | ||
@@ -334,3 +240,2 @@ | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -355,3 +260,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -376,3 +280,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -397,3 +300,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -418,3 +320,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -439,3 +340,2 @@ try { | ||
var caughtError = null; | ||
subscribers.forEach(function (subscriber) { | ||
@@ -460,7 +360,7 @@ try { | ||
exports.unstable_getThreadID = unstable_getThreadID; | ||
exports.unstable_subscribe = unstable_subscribe; | ||
exports.unstable_trace = unstable_trace; | ||
exports.unstable_unsubscribe = unstable_unsubscribe; | ||
exports.unstable_wrap = unstable_wrap; | ||
exports.unstable_subscribe = unstable_subscribe; | ||
exports.unstable_unsubscribe = unstable_unsubscribe; | ||
})(); | ||
} |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-50b50c26f | ||
/** @license React vundefined | ||
* scheduler-tracing.production.min.js | ||
@@ -9,3 +9,2 @@ * | ||
*/ | ||
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var b=0;exports.__interactionsRef=null;exports.__subscriberRef=null;exports.unstable_clear=function(a){return a()};exports.unstable_getCurrent=function(){return null};exports.unstable_getThreadID=function(){return++b};exports.unstable_trace=function(a,d,c){return c()};exports.unstable_wrap=function(a){return a};exports.unstable_subscribe=function(){};exports.unstable_unsubscribe=function(){}; | ||
'use strict';var b=0;exports.__interactionsRef=null;exports.__subscriberRef=null;exports.unstable_clear=function(a){return a()};exports.unstable_getCurrent=function(){return null};exports.unstable_getThreadID=function(){return++b};exports.unstable_subscribe=function(){};exports.unstable_trace=function(a,d,c){return c()};exports.unstable_unsubscribe=function(){};exports.unstable_wrap=function(a){return a}; |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-50b50c26f | ||
/** @license React vundefined | ||
* scheduler-tracing.profiling.min.js | ||
@@ -9,10 +9,9 @@ * | ||
*/ | ||
'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';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_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_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_unsubscribe=function(e){m.delete(e);0===m.size&&(exports.__subscriberRef.current=null)}; | ||
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}; |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-50b50c26f | ||
/** @license React vundefined | ||
* scheduler-unstable_mock.development.js | ||
@@ -12,4 +12,2 @@ * | ||
if (process.env.NODE_ENV !== "production") { | ||
@@ -19,140 +17,87 @@ (function() { | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = false; // TODO: enable to fix https://github.com/facebook/react/issues/20756. | ||
var currentTime = 0; | ||
var scheduledCallback = null; | ||
var scheduledCallbackExpiration = -1; | ||
var yieldedValues = null; | ||
var expectedNumberOfYields = -1; | ||
var didStop = false; | ||
var isFlushing = false; | ||
function requestHostCallback(callback, expiration) { | ||
scheduledCallback = callback; | ||
scheduledCallbackExpiration = expiration; | ||
function push(heap, node) { | ||
var index = heap.length; | ||
heap.push(node); | ||
siftUp(heap, node, index); | ||
} | ||
function cancelHostCallback() { | ||
scheduledCallback = null; | ||
scheduledCallbackExpiration = -1; | ||
function peek(heap) { | ||
var first = heap[0]; | ||
return first === undefined ? null : first; | ||
} | ||
function pop(heap) { | ||
var first = heap[0]; | ||
function shouldYieldToHost() { | ||
if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) { | ||
// We yielded at least as many values as expected. Stop flushing. | ||
didStop = true; | ||
return true; | ||
} | ||
return false; | ||
} | ||
if (first !== undefined) { | ||
var last = heap.pop(); | ||
function getCurrentTime() { | ||
return currentTime; | ||
} | ||
if (last !== first) { | ||
heap[0] = last; | ||
siftDown(heap, last, 0); | ||
} | ||
function forceFrameRate() { | ||
// No-op | ||
return first; | ||
} else { | ||
return null; | ||
} | ||
} | ||
function siftUp(heap, node, i) { | ||
var index = i; | ||
while (true) { | ||
var parentIndex = index - 1 >>> 1; | ||
var parent = heap[parentIndex]; | ||
// Should only be used via an assertion helper that inspects the yielded values. | ||
function unstable_flushNumberOfYields(count) { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
expectedNumberOfYields = count; | ||
isFlushing = true; | ||
try { | ||
while (scheduledCallback !== null && !didStop) { | ||
var cb = scheduledCallback; | ||
scheduledCallback = null; | ||
var didTimeout = scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime; | ||
cb(didTimeout); | ||
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; | ||
} | ||
} finally { | ||
expectedNumberOfYields = -1; | ||
didStop = false; | ||
isFlushing = false; | ||
} | ||
} | ||
function unstable_flushExpired() { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
if (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
scheduledCallback = null; | ||
isFlushing = true; | ||
try { | ||
cb(true); | ||
} finally { | ||
isFlushing = false; | ||
} | ||
} | ||
} | ||
function siftDown(heap, node, i) { | ||
var index = i; | ||
var length = heap.length; | ||
function unstable_flushWithoutYielding() { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
isFlushing = true; | ||
try { | ||
if (scheduledCallback === null) { | ||
return false; | ||
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; | ||
} | ||
while (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
scheduledCallback = null; | ||
var didTimeout = scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime; | ||
cb(didTimeout); | ||
} | ||
return true; | ||
} finally { | ||
expectedNumberOfYields = -1; | ||
didStop = false; | ||
isFlushing = false; | ||
} | ||
} | ||
function unstable_clearYields() { | ||
if (yieldedValues === null) { | ||
return []; | ||
} | ||
var values = yieldedValues; | ||
yieldedValues = null; | ||
return values; | ||
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; | ||
} | ||
function flushAll() { | ||
if (yieldedValues !== null) { | ||
throw new Error('Log is not empty. Assert on the log of yielded values before ' + 'flushing additional work.'); | ||
} | ||
unstable_flushWithoutYielding(); | ||
if (yieldedValues !== null) { | ||
throw new Error('While flushing work, something yielded a value. Use an ' + 'assertion helper to assert on the log of yielded values, e.g. ' + 'expect(Scheduler).toFlushAndYield([...])'); | ||
} | ||
} | ||
function yieldValue(value) { | ||
if (yieldedValues === null) { | ||
yieldedValues = [value]; | ||
} else { | ||
yieldedValues.push(value); | ||
} | ||
} | ||
function advanceTime(ms) { | ||
currentTime += ms; | ||
// If the host callback timed out, flush the expired work. | ||
if (!isFlushing && scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) { | ||
unstable_flushExpired(); | ||
} | ||
} | ||
/* eslint-disable no-var */ | ||
// TODO: Use symbols? | ||
@@ -165,183 +110,167 @@ var ImmediatePriority = 1; | ||
// Max 31 bit integer. The max integer size in V8 for 32-bit systems. | ||
function markTaskErrored(task, ms) { | ||
} | ||
/* eslint-disable no-var */ | ||
// Math.pow(2, 30) - 1 | ||
// 0b111111111111111111111111111111 | ||
var maxSigned31BitInt = 1073741823; | ||
// Times out immediately | ||
var IMMEDIATE_PRIORITY_TIMEOUT = -1; | ||
// Eventually times out | ||
var USER_BLOCKING_PRIORITY = 250; | ||
var maxSigned31BitInt = 1073741823; // Times out immediately | ||
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out | ||
var USER_BLOCKING_PRIORITY_TIMEOUT = 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_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap | ||
var currentHostCallbackDidTimeout = false; | ||
// Pausing the scheduler is useful for debugging. | ||
var isSchedulerPaused = false; | ||
var taskQueue = []; | ||
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. | ||
var currentPriorityLevel = NormalPriority; | ||
var currentEventStartTime = -1; | ||
var currentExpirationTime = -1; | ||
var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. | ||
var currentTask = null; | ||
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. | ||
// This is set while performing work, to prevent re-entrancy. | ||
var isPerformingWork = false; | ||
var isHostCallbackScheduled = false; | ||
var isHostTimeoutScheduled = false; | ||
var currentMockTime = 0; | ||
var scheduledCallback = null; | ||
var scheduledTimeout = null; | ||
var timeoutTime = -1; | ||
var yieldedValues = null; | ||
var expectedNumberOfYields = -1; | ||
var didStop = false; | ||
var isFlushing = false; | ||
var needsPaint = false; | ||
var shouldYieldForPaint = false; | ||
function scheduleHostCallbackIfNeeded() { | ||
if (isPerformingWork) { | ||
// Don't schedule work yet; wait until the next time we yield. | ||
return; | ||
} | ||
if (firstCallbackNode !== null) { | ||
// Schedule the host callback using the earliest expiration in the list. | ||
var expirationTime = firstCallbackNode.expirationTime; | ||
if (isHostCallbackScheduled) { | ||
// Cancel the existing host callback. | ||
cancelHostCallback(); | ||
function advanceTimers(currentTime) { | ||
// Check for tasks that are no longer delayed and add them to the queue. | ||
var timer = peek(timerQueue); | ||
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 { | ||
isHostCallbackScheduled = true; | ||
// Remaining timers are pending. | ||
return; | ||
} | ||
requestHostCallback(flushWork, expirationTime); | ||
timer = peek(timerQueue); | ||
} | ||
} | ||
function flushFirstCallback() { | ||
var currentlyFlushingCallback = firstCallbackNode; | ||
function handleTimeout(currentTime) { | ||
isHostTimeoutScheduled = false; | ||
advanceTimers(currentTime); | ||
// 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; | ||
if (!isHostCallbackScheduled) { | ||
if (peek(taskQueue) !== null) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} else { | ||
var firstTimer = peek(timerQueue); | ||
if (firstTimer !== null) { | ||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); | ||
} | ||
} | ||
} | ||
} | ||
currentlyFlushingCallback.next = currentlyFlushingCallback.previous = null; | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
// Now it's safe to call the callback. | ||
var callback = currentlyFlushingCallback.callback; | ||
var expirationTime = currentlyFlushingCallback.expirationTime; | ||
var priorityLevel = currentlyFlushingCallback.priorityLevel; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousExpirationTime = currentExpirationTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentExpirationTime = expirationTime; | ||
var continuationCallback; | ||
try { | ||
var didUserCallbackTimeout = currentHostCallbackDidTimeout || | ||
// Immediate priority callbacks are always called as if they timed out | ||
priorityLevel === ImmediatePriority; | ||
continuationCallback = callback(didUserCallbackTimeout); | ||
} catch (error) { | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentExpirationTime = previousExpirationTime; | ||
isHostCallbackScheduled = false; | ||
if (isHostTimeoutScheduled) { | ||
// We scheduled a timeout but it's no longer needed. Cancel it. | ||
isHostTimeoutScheduled = false; | ||
cancelHostTimeout(); | ||
} | ||
// 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 | ||
}; | ||
isPerformingWork = true; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
// 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; | ||
} 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; | ||
try { | ||
if (enableProfiling) { | ||
try { | ||
return workLoop(hasTimeRemaining, initialTime); | ||
} catch (error) { | ||
if (currentTask !== null) { | ||
var currentTime = getCurrentTime(); | ||
markTaskErrored(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
node = node.next; | ||
} while (node !== firstCallbackNode); | ||
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; | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
} | ||
var previous = nextAfterContinuation.previous; | ||
previous.next = nextAfterContinuation.previous = continuationNode; | ||
continuationNode.next = nextAfterContinuation; | ||
continuationNode.previous = previous; | ||
} else { | ||
// No catch in prod code path. | ||
return workLoop(hasTimeRemaining, initialTime); | ||
} | ||
} finally { | ||
currentTask = null; | ||
currentPriorityLevel = previousPriorityLevel; | ||
isPerformingWork = false; | ||
} | ||
} | ||
function flushWork(didUserCallbackTimeout) { | ||
// Exit right away if we're currently paused | ||
if (enableSchedulerDebugging && isSchedulerPaused) { | ||
return; | ||
} | ||
function workLoop(hasTimeRemaining, initialTime) { | ||
var currentTime = initialTime; | ||
advanceTimers(currentTime); | ||
currentTask = peek(taskQueue); | ||
// We'll need a new host callback the next time work is scheduled. | ||
isHostCallbackScheduled = false; | ||
while (currentTask !== null && !(enableSchedulerDebugging )) { | ||
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { | ||
// This currentTask hasn't expired, and we've reached the deadline. | ||
break; | ||
} | ||
isPerformingWork = true; | ||
var previousDidTimeout = currentHostCallbackDidTimeout; | ||
currentHostCallbackDidTimeout = didUserCallbackTimeout; | ||
try { | ||
if (didUserCallbackTimeout) { | ||
// Flush all the expired callbacks without yielding. | ||
while (firstCallbackNode !== null && !(enableSchedulerDebugging && isSchedulerPaused)) { | ||
// TODO Wrap in feature flag | ||
// 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 = getCurrentTime(); | ||
if (firstCallbackNode.expirationTime <= currentTime) { | ||
do { | ||
flushFirstCallback(); | ||
} while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused)); | ||
continue; | ||
var callback = currentTask.callback; | ||
if (typeof callback === 'function') { | ||
currentTask.callback = null; | ||
currentPriorityLevel = currentTask.priorityLevel; | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
var continuationCallback = callback(didUserCallbackTimeout); | ||
currentTime = getCurrentTime(); | ||
if (typeof continuationCallback === 'function') { | ||
currentTask.callback = continuationCallback; | ||
} else { | ||
if (currentTask === peek(taskQueue)) { | ||
pop(taskQueue); | ||
} | ||
break; | ||
} | ||
advanceTimers(currentTime); | ||
} else { | ||
// Keep flushing callbacks until we run out of time in the frame. | ||
if (firstCallbackNode !== null) { | ||
do { | ||
if (enableSchedulerDebugging && isSchedulerPaused) { | ||
break; | ||
} | ||
flushFirstCallback(); | ||
} while (firstCallbackNode !== null && !shouldYieldToHost()); | ||
} | ||
pop(taskQueue); | ||
} | ||
} finally { | ||
isPerformingWork = false; | ||
currentHostCallbackDidTimeout = previousDidTimeout; | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
currentTask = peek(taskQueue); | ||
} // Return whether there's additional work | ||
if (currentTask !== null) { | ||
return true; | ||
} else { | ||
var firstTimer = peek(timerQueue); | ||
if (firstTimer !== null) { | ||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); | ||
} | ||
return false; | ||
} | ||
@@ -358,2 +287,3 @@ } | ||
break; | ||
default: | ||
@@ -364,15 +294,8 @@ priorityLevel = NormalPriority; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentEventStartTime = getCurrentTime(); | ||
try { | ||
return eventHandler(); | ||
} catch (error) { | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
@@ -382,3 +305,4 @@ } | ||
function unstable_next(eventHandler) { | ||
var priorityLevel = void 0; | ||
var priorityLevel; | ||
switch (currentPriorityLevel) { | ||
@@ -391,2 +315,3 @@ case ImmediatePriority: | ||
break; | ||
default: | ||
@@ -399,15 +324,8 @@ // Anything lower than normal priority should remain at the current level. | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentEventStartTime = getCurrentTime(); | ||
try { | ||
return eventHandler(); | ||
} catch (error) { | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
@@ -421,15 +339,8 @@ } | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = parentPriorityLevel; | ||
currentEventStartTime = getCurrentTime(); | ||
try { | ||
return callback.apply(this, arguments); | ||
} catch (error) { | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
@@ -439,83 +350,93 @@ }; | ||
function unstable_scheduleCallback(priorityLevel, callback, deprecated_options) { | ||
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime(); | ||
function unstable_scheduleCallback(priorityLevel, callback, options) { | ||
var currentTime = getCurrentTime(); | ||
var startTime; | ||
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; | ||
if (typeof options === 'object' && options !== null) { | ||
var delay = options.delay; | ||
if (typeof delay === 'number' && delay > 0) { | ||
startTime = currentTime + delay; | ||
} else { | ||
startTime = currentTime; | ||
} | ||
} else { | ||
switch (priorityLevel) { | ||
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; | ||
} | ||
startTime = currentTime; | ||
} | ||
var newNode = { | ||
var timeout; | ||
switch (priorityLevel) { | ||
case ImmediatePriority: | ||
timeout = IMMEDIATE_PRIORITY_TIMEOUT; | ||
break; | ||
case UserBlockingPriority: | ||
timeout = USER_BLOCKING_PRIORITY_TIMEOUT; | ||
break; | ||
case IdlePriority: | ||
timeout = IDLE_PRIORITY_TIMEOUT; | ||
break; | ||
case LowPriority: | ||
timeout = LOW_PRIORITY_TIMEOUT; | ||
break; | ||
case NormalPriority: | ||
default: | ||
timeout = NORMAL_PRIORITY_TIMEOUT; | ||
break; | ||
} | ||
var expirationTime = startTime + timeout; | ||
var newTask = { | ||
id: taskIdCounter++, | ||
callback: callback, | ||
priorityLevel: priorityLevel, | ||
startTime: startTime, | ||
expirationTime: expirationTime, | ||
next: null, | ||
previous: null | ||
sortIndex: -1 | ||
}; | ||
// Insert the new callback into the list, ordered first by expiration, then | ||
// by insertion. So the new callback is inserted after any other callback | ||
// with equal expiration. | ||
if (firstCallbackNode === null) { | ||
// This is the first callback in the list. | ||
firstCallbackNode = newNode.next = newNode.previous = newNode; | ||
scheduleHostCallbackIfNeeded(); | ||
if (startTime > currentTime) { | ||
// This is a delayed task. | ||
newTask.sortIndex = startTime; | ||
push(timerQueue, newTask); | ||
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. | ||
requestHostTimeout(handleTimeout, startTime - currentTime); | ||
} | ||
} 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); | ||
newTask.sortIndex = expirationTime; | ||
push(taskQueue, newTask); | ||
// wait until the next time we yield. | ||
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; | ||
scheduleHostCallbackIfNeeded(); | ||
if (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
var previous = next.previous; | ||
previous.next = next.previous = newNode; | ||
newNode.next = next; | ||
newNode.previous = previous; | ||
} | ||
return newNode; | ||
return newTask; | ||
} | ||
function unstable_pauseExecution() { | ||
isSchedulerPaused = true; | ||
} | ||
function unstable_continueExecution() { | ||
isSchedulerPaused = false; | ||
if (firstCallbackNode !== null) { | ||
scheduleHostCallbackIfNeeded(); | ||
if (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
@@ -525,61 +446,260 @@ } | ||
function unstable_getFirstCallbackNode() { | ||
return firstCallbackNode; | ||
return peek(taskQueue); | ||
} | ||
function unstable_cancelCallback(callbackNode) { | ||
var next = callbackNode.next; | ||
if (next === null) { | ||
// Already cancelled. | ||
return; | ||
function unstable_cancelCallback(task) { | ||
// remove from the queue because you can't remove arbitrary nodes from an | ||
// array based heap, only the first one.) | ||
task.callback = null; | ||
} | ||
function unstable_getCurrentPriorityLevel() { | ||
return currentPriorityLevel; | ||
} | ||
function requestHostCallback(callback) { | ||
scheduledCallback = callback; | ||
} | ||
function requestHostTimeout(callback, ms) { | ||
scheduledTimeout = callback; | ||
timeoutTime = currentMockTime + ms; | ||
} | ||
function cancelHostTimeout() { | ||
scheduledTimeout = null; | ||
timeoutTime = -1; | ||
} | ||
function shouldYieldToHost() { | ||
if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || shouldYieldForPaint && needsPaint) { | ||
// We yielded at least as many values as expected. Stop flushing. | ||
didStop = true; | ||
return true; | ||
} | ||
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; | ||
return false; | ||
} | ||
function getCurrentTime() { | ||
return currentMockTime; | ||
} | ||
function forceFrameRate() {// No-op | ||
} | ||
function reset() { | ||
if (isFlushing) { | ||
throw new Error('Cannot reset while already flushing work.'); | ||
} | ||
currentMockTime = 0; | ||
scheduledCallback = null; | ||
scheduledTimeout = null; | ||
timeoutTime = -1; | ||
yieldedValues = null; | ||
expectedNumberOfYields = -1; | ||
didStop = false; | ||
isFlushing = false; | ||
needsPaint = false; | ||
} // Should only be used via an assertion helper that inspects the yielded values. | ||
function unstable_flushNumberOfYields(count) { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
if (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
expectedNumberOfYields = count; | ||
isFlushing = true; | ||
try { | ||
var hasMoreWork = true; | ||
do { | ||
hasMoreWork = cb(true, currentMockTime); | ||
} while (hasMoreWork && !didStop); | ||
if (!hasMoreWork) { | ||
scheduledCallback = null; | ||
} | ||
} finally { | ||
expectedNumberOfYields = -1; | ||
didStop = false; | ||
isFlushing = false; | ||
} | ||
var previous = callbackNode.previous; | ||
previous.next = next; | ||
next.previous = previous; | ||
} | ||
} | ||
callbackNode.next = callbackNode.previous = null; | ||
function unstable_flushUntilNextPaint() { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
if (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
shouldYieldForPaint = true; | ||
needsPaint = false; | ||
isFlushing = true; | ||
try { | ||
var hasMoreWork = true; | ||
do { | ||
hasMoreWork = cb(true, currentMockTime); | ||
} while (hasMoreWork && !didStop); | ||
if (!hasMoreWork) { | ||
scheduledCallback = null; | ||
} | ||
} finally { | ||
shouldYieldForPaint = false; | ||
didStop = false; | ||
isFlushing = false; | ||
} | ||
} | ||
} | ||
function unstable_getCurrentPriorityLevel() { | ||
return currentPriorityLevel; | ||
function unstable_flushExpired() { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
if (scheduledCallback !== null) { | ||
isFlushing = true; | ||
try { | ||
var hasMoreWork = scheduledCallback(false, currentMockTime); | ||
if (!hasMoreWork) { | ||
scheduledCallback = null; | ||
} | ||
} finally { | ||
isFlushing = false; | ||
} | ||
} | ||
} | ||
function unstable_shouldYield() { | ||
return !currentHostCallbackDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost()); | ||
function unstable_flushAllWithoutAsserting() { | ||
// Returns false if no work was flushed. | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
if (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
isFlushing = true; | ||
try { | ||
var hasMoreWork = true; | ||
do { | ||
hasMoreWork = cb(true, currentMockTime); | ||
} while (hasMoreWork); | ||
if (!hasMoreWork) { | ||
scheduledCallback = null; | ||
} | ||
return true; | ||
} finally { | ||
isFlushing = false; | ||
} | ||
} else { | ||
return false; | ||
} | ||
} | ||
exports.unstable_flushWithoutYielding = unstable_flushWithoutYielding; | ||
exports.unstable_flushNumberOfYields = unstable_flushNumberOfYields; | ||
exports.unstable_flushExpired = unstable_flushExpired; | ||
exports.unstable_clearYields = unstable_clearYields; | ||
exports.flushAll = flushAll; | ||
exports.yieldValue = yieldValue; | ||
exports.advanceTime = advanceTime; | ||
function unstable_clearYields() { | ||
if (yieldedValues === null) { | ||
return []; | ||
} | ||
var values = yieldedValues; | ||
yieldedValues = null; | ||
return values; | ||
} | ||
function unstable_flushAll() { | ||
if (yieldedValues !== null) { | ||
throw new Error('Log is not empty. Assert on the log of yielded values before ' + 'flushing additional work.'); | ||
} | ||
unstable_flushAllWithoutAsserting(); | ||
if (yieldedValues !== null) { | ||
throw new Error('While flushing work, something yielded a value. Use an ' + 'assertion helper to assert on the log of yielded values, e.g. ' + 'expect(Scheduler).toFlushAndYield([...])'); | ||
} | ||
} | ||
function unstable_yieldValue(value) { | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
if (console.log.name === 'disabledLog') { | ||
// If console.log has been patched, we assume we're in render | ||
// replaying and we ignore any values yielding in the second pass. | ||
return; | ||
} | ||
if (yieldedValues === null) { | ||
yieldedValues = [value]; | ||
} else { | ||
yieldedValues.push(value); | ||
} | ||
} | ||
function unstable_advanceTime(ms) { | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
if (console.log.name === 'disabledLog') { | ||
// If console.log has been patched, we assume we're in render | ||
// replaying and we ignore any time advancing in the second pass. | ||
return; | ||
} | ||
currentMockTime += ms; | ||
if (scheduledTimeout !== null && timeoutTime <= currentMockTime) { | ||
scheduledTimeout(currentMockTime); | ||
timeoutTime = -1; | ||
scheduledTimeout = null; | ||
} | ||
} | ||
function requestPaint() { | ||
needsPaint = true; | ||
} | ||
var unstable_Profiling = null; | ||
exports.reset = reset; | ||
exports.unstable_IdlePriority = IdlePriority; | ||
exports.unstable_ImmediatePriority = ImmediatePriority; | ||
exports.unstable_LowPriority = LowPriority; | ||
exports.unstable_NormalPriority = NormalPriority; | ||
exports.unstable_Profiling = unstable_Profiling; | ||
exports.unstable_UserBlockingPriority = UserBlockingPriority; | ||
exports.unstable_NormalPriority = NormalPriority; | ||
exports.unstable_IdlePriority = IdlePriority; | ||
exports.unstable_LowPriority = LowPriority; | ||
exports.unstable_runWithPriority = unstable_runWithPriority; | ||
exports.unstable_next = unstable_next; | ||
exports.unstable_scheduleCallback = unstable_scheduleCallback; | ||
exports.unstable_advanceTime = unstable_advanceTime; | ||
exports.unstable_cancelCallback = unstable_cancelCallback; | ||
exports.unstable_wrapCallback = unstable_wrapCallback; | ||
exports.unstable_clearYields = unstable_clearYields; | ||
exports.unstable_continueExecution = unstable_continueExecution; | ||
exports.unstable_flushAll = unstable_flushAll; | ||
exports.unstable_flushAllWithoutAsserting = unstable_flushAllWithoutAsserting; | ||
exports.unstable_flushExpired = unstable_flushExpired; | ||
exports.unstable_flushNumberOfYields = unstable_flushNumberOfYields; | ||
exports.unstable_flushUntilNextPaint = unstable_flushUntilNextPaint; | ||
exports.unstable_forceFrameRate = forceFrameRate; | ||
exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; | ||
exports.unstable_shouldYield = unstable_shouldYield; | ||
exports.unstable_continueExecution = unstable_continueExecution; | ||
exports.unstable_pauseExecution = unstable_pauseExecution; | ||
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; | ||
exports.unstable_next = unstable_next; | ||
exports.unstable_now = getCurrentTime; | ||
exports.unstable_forceFrameRate = forceFrameRate; | ||
exports.unstable_pauseExecution = unstable_pauseExecution; | ||
exports.unstable_requestPaint = requestPaint; | ||
exports.unstable_runWithPriority = unstable_runWithPriority; | ||
exports.unstable_scheduleCallback = unstable_scheduleCallback; | ||
exports.unstable_shouldYield = shouldYieldToHost; | ||
exports.unstable_wrapCallback = unstable_wrapCallback; | ||
exports.unstable_yieldValue = unstable_yieldValue; | ||
})(); | ||
} |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-50b50c26f | ||
/** @license React vundefined | ||
* scheduler-unstable_mock.production.min.js | ||
@@ -9,12 +9,12 @@ * | ||
*/ | ||
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var c=0,f=null,g=-1,h=null,k=-1,l=!1,m=!1;function n(){return-1!==k&&null!==h&&h.length>=k||-1!==g&&g<=c?l=!0:!1}function q(){if(m)throw Error("Already flushing work.");if(null!==f){var a=f;f=null;m=!0;try{a(!0)}finally{m=!1}}}function t(){if(m)throw Error("Already flushing work.");m=!0;try{if(null===f)return!1;for(;null!==f;){var a=f;f=null;a(-1!==g&&g<=c)}return!0}finally{k=-1,m=l=!1}}var u=null,v=!1,w=3,x=-1,y=-1,z=!1,A=!1; | ||
function B(){if(!z&&null!==u){var a=u.expirationTime;A?(f=null,g=-1):A=!0;f=C;g=a}} | ||
function D(){var a=u,d=u.next;if(u===d)u=null;else{var b=u.previous;u=b.next=d;d.previous=b}a.next=a.previous=null;b=a.callback;d=a.expirationTime;a=a.priorityLevel;var e=w,r=y;w=a;y=d;try{var p=b(v||1===a)}catch(E){throw E;}finally{w=e,y=r}if("function"===typeof p)if(p={callback:p,priorityLevel:a,expirationTime:d,next:null,previous:null},null===u)u=p.next=p.previous=p;else{b=null;a=u;do{if(a.expirationTime>=d){b=a;break}a=a.next}while(a!==u);null===b?b=u:b===u&&(u=p,B());d=b.previous;d.next=b.previous= | ||
p;p.next=b;p.previous=d}}function C(a){A=!1;z=!0;var d=v;v=a;try{if(a)for(;null!==u;)if(a=c,u.expirationTime<=a){do D();while(null!==u&&u.expirationTime<=a)}else break;else if(null!==u){do D();while(null!==u&&!n())}}finally{z=!1,v=d,B()}}exports.unstable_flushWithoutYielding=t;exports.unstable_flushNumberOfYields=function(a){if(m)throw Error("Already flushing work.");k=a;m=!0;try{for(;null!==f&&!l;)a=f,f=null,a(-1!==g&&g<=c)}finally{k=-1,m=l=!1}};exports.unstable_flushExpired=q; | ||
exports.unstable_clearYields=function(){if(null===h)return[];var a=h;h=null;return a};exports.flushAll=function(){if(null!==h)throw Error("Log is not empty. Assert on the log of yielded values before flushing additional work.");t();if(null!==h)throw Error("While flushing work, something yielded a value. Use an assertion helper to assert on the log of yielded values, e.g. expect(Scheduler).toFlushAndYield([...])");};exports.yieldValue=function(a){null===h?h=[a]:h.push(a)}; | ||
exports.advanceTime=function(a){c+=a;!m&&-1!==g&&g<=c&&q()};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,d){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var b=w,e=x;w=a;x=c;try{return d()}catch(r){throw B(),r;}finally{w=b,x=e}}; | ||
exports.unstable_next=function(a){switch(w){case 1:case 2:case 3:var d=3;break;default:d=w}var b=w,e=x;w=d;x=c;try{return a()}catch(r){throw B(),r;}finally{w=b,x=e}}; | ||
exports.unstable_scheduleCallback=function(a,d,b){var e=-1!==x?x:c;if("object"===typeof b&&null!==b&&"number"===typeof b.timeout)b=e+b.timeout;else switch(a){case 1:b=e+-1;break;case 2:b=e+250;break;case 5:b=e+1073741823;break;case 4:b=e+1E4;break;default:b=e+5E3}a={callback:d,priorityLevel:a,expirationTime:b,next:null,previous:null};if(null===u)u=a.next=a.previous=a,B();else{d=null;e=u;do{if(e.expirationTime>b){d=e;break}e=e.next}while(e!==u);null===d?d=u:d===u&&(u=a,B());b=d.previous;b.next=d.previous= | ||
a;a.next=d;a.previous=b}return a};exports.unstable_cancelCallback=function(a){var d=a.next;if(null!==d){if(d===a)u=null;else{a===u&&(u=d);var b=a.previous;b.next=d;d.previous=b}a.next=a.previous=null}};exports.unstable_wrapCallback=function(a){var d=w;return function(){var b=w,e=x;w=d;x=c;try{return a.apply(this,arguments)}catch(r){throw B(),r;}finally{w=b,x=e}}};exports.unstable_getCurrentPriorityLevel=function(){return w}; | ||
exports.unstable_shouldYield=function(){return!v&&(null!==u&&u.expirationTime<y||n())};exports.unstable_continueExecution=function(){null!==u&&B()};exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return u};exports.unstable_now=function(){return c};exports.unstable_forceFrameRate=function(){}; | ||
'use strict';function f(a,b){var c=a.length;a.push(b);a:for(;;){var d=c-1>>>1,e=a[d];if(void 0!==e&&0<g(e,b))a[d]=b,a[c]=e,c=d;else break a}}function h(a){a=a[0];return void 0===a?null:a}function k(a){var b=a[0];if(void 0!==b){var c=a.pop();if(c!==b){a[0]=c;a:for(var d=0,e=a.length;d<e;){var u=2*(d+1)-1,v=a[u],w=u+1,y=a[w];if(void 0!==v&&0>g(v,c))void 0!==y&&0>g(y,v)?(a[d]=y,a[w]=c,d=w):(a[d]=v,a[u]=c,d=u);else if(void 0!==y&&0>g(y,c))a[d]=y,a[w]=c,d=w;else break a}}return b}return null} | ||
function g(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}var l=[],m=[],n=1,p=null,q=3,r=!1,t=!1,x=!1,z=0,A=null,B=null,C=-1,D=null,E=-1,F=!1,G=!1,H=!1,I=!1;function J(a){for(var b=h(m);null!==b;){if(null===b.callback)k(m);else if(b.startTime<=a)k(m),b.sortIndex=b.expirationTime,f(l,b);else break;b=h(m)}}function K(a){x=!1;J(a);if(!t)if(null!==h(l))t=!0,A=L;else{var b=h(m);null!==b&&(a=b.startTime-a,B=K,C=z+a)}} | ||
function L(a,b){t=!1;x&&(x=!1,B=null,C=-1);r=!0;var c=q;try{J(b);for(p=h(l);null!==p&&(!(p.expirationTime>b)||a&&!M());){var d=p.callback;if("function"===typeof d){p.callback=null;q=p.priorityLevel;var e=d(p.expirationTime<=b);b=z;"function"===typeof e?p.callback=e:p===h(l)&&k(l);J(b)}else k(l);p=h(l)}if(null!==p)var u=!0;else{var v=h(m);if(null!==v){var w=v.startTime-b;B=K;C=z+w}u=!1}return u}finally{p=null,q=c,r=!1}}function M(){return-1!==E&&null!==D&&D.length>=E||I&&H?F=!0:!1} | ||
function N(){if(G)throw Error("Already flushing work.");if(null!==A){var a=A;G=!0;try{var b=!0;do b=a(!0,z);while(b);b||(A=null);return!0}finally{G=!1}}else return!1}exports.reset=function(){if(G)throw Error("Cannot reset while already flushing work.");z=0;B=A=null;C=-1;D=null;E=-1;H=G=F=!1};exports.unstable_IdlePriority=5;exports.unstable_ImmediatePriority=1;exports.unstable_LowPriority=4;exports.unstable_NormalPriority=3;exports.unstable_Profiling=null;exports.unstable_UserBlockingPriority=2; | ||
exports.unstable_advanceTime=function(a){"disabledLog"!==console.log.name&&(z+=a,null!==B&&C<=z&&(B(z),C=-1,B=null))};exports.unstable_cancelCallback=function(a){a.callback=null};exports.unstable_clearYields=function(){if(null===D)return[];var a=D;D=null;return a};exports.unstable_continueExecution=function(){t||r||(t=!0,A=L)}; | ||
exports.unstable_flushAll=function(){if(null!==D)throw Error("Log is not empty. Assert on the log of yielded values before flushing additional work.");N();if(null!==D)throw Error("While flushing work, something yielded a value. Use an assertion helper to assert on the log of yielded values, e.g. expect(Scheduler).toFlushAndYield([...])");};exports.unstable_flushAllWithoutAsserting=N; | ||
exports.unstable_flushExpired=function(){if(G)throw Error("Already flushing work.");if(null!==A){G=!0;try{A(!1,z)||(A=null)}finally{G=!1}}};exports.unstable_flushNumberOfYields=function(a){if(G)throw Error("Already flushing work.");if(null!==A){var b=A;E=a;G=!0;try{a=!0;do a=b(!0,z);while(a&&!F);a||(A=null)}finally{E=-1,G=F=!1}}}; | ||
exports.unstable_flushUntilNextPaint=function(){if(G)throw Error("Already flushing work.");if(null!==A){var a=A;I=!0;H=!1;G=!0;try{var b=!0;do b=a(!0,z);while(b&&!F);b||(A=null)}finally{G=F=I=!1}}};exports.unstable_forceFrameRate=function(){};exports.unstable_getCurrentPriorityLevel=function(){return q};exports.unstable_getFirstCallbackNode=function(){return h(l)};exports.unstable_next=function(a){switch(q){case 1:case 2:case 3:var b=3;break;default:b=q}var c=q;q=b;try{return a()}finally{q=c}}; | ||
exports.unstable_now=function(){return z};exports.unstable_pauseExecution=function(){};exports.unstable_requestPaint=function(){H=!0};exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=q;q=a;try{return b()}finally{q=c}}; | ||
exports.unstable_scheduleCallback=function(a,b,c){var d=z;"object"===typeof c&&null!==c?(c=c.delay,c="number"===typeof c&&0<c?d+c:d):c=d;switch(a){case 1:var e=-1;break;case 2:e=250;break;case 5:e=1073741823;break;case 4:e=1E4;break;default:e=5E3}e=c+e;a={id:n++,callback:b,priorityLevel:a,startTime:c,expirationTime:e,sortIndex:-1};c>d?(a.sortIndex=c,f(m,a),null===h(l)&&a===h(m)&&(x?(B=null,C=-1):x=!0,B=K,C=z+(c-d))):(a.sortIndex=e,f(l,a),t||r||(t=!0,A=L));return a};exports.unstable_shouldYield=M; | ||
exports.unstable_wrapCallback=function(a){var b=q;return function(){var c=q;q=b;try{return a.apply(this,arguments)}finally{q=c}}};exports.unstable_yieldValue=function(a){"disabledLog"!==console.log.name&&(null===D?D=[a]:D.push(a))}; |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-50b50c26f | ||
/** @license React vundefined | ||
* scheduler.development.js | ||
@@ -12,4 +12,2 @@ * | ||
if (process.env.NODE_ENV !== "production") { | ||
@@ -19,264 +17,87 @@ (function() { | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = false; // TODO: enable to fix https://github.com/facebook/react/issues/20756. | ||
// 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. | ||
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]; | ||
var requestHostCallback = void 0; | ||
var cancelHostCallback = void 0; | ||
var shouldYieldToHost = void 0; | ||
exports.unstable_now = void 0; | ||
exports.unstable_forceFrameRate = void 0; | ||
if (first !== undefined) { | ||
var last = heap.pop(); | ||
var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; | ||
if (last !== first) { | ||
heap[0] = last; | ||
siftDown(heap, last, 0); | ||
} | ||
// 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; | ||
return first; | ||
} else { | ||
return null; | ||
} | ||
} | ||
// 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; | ||
function siftUp(heap, node, i) { | ||
var index = i; | ||
// 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; | ||
while (true) { | ||
var parentIndex = index - 1 >>> 1; | ||
var parent = heap[parentIndex]; | ||
// 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 = void 0; | ||
var rAFTimeoutID = void 0; | ||
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(); | ||
}; | ||
} | ||
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 _flushCallback = function (didTimeout) { | ||
if (_callback !== null) { | ||
try { | ||
_callback(didTimeout); | ||
} finally { | ||
_callback = null; | ||
} | ||
} | ||
}; | ||
requestHostCallback = function (cb, ms) { | ||
if (_callback !== null) { | ||
// Protect against re-entrancy. | ||
setTimeout(requestHostCallback, 0, cb); | ||
if (parent !== undefined && compare(parent, node) > 0) { | ||
// The parent is larger. Swap positions. | ||
heap[parentIndex] = node; | ||
heap[index] = parent; | ||
index = parentIndex; | ||
} else { | ||
_callback = cb; | ||
setTimeout(_flushCallback, 0, false); | ||
// The parent is smaller. Exit. | ||
return; | ||
} | ||
}; | ||
cancelHostCallback = function () { | ||
_callback = null; | ||
}; | ||
shouldYieldToHost = function () { | ||
return false; | ||
}; | ||
exports.unstable_forceFrameRate = function () {}; | ||
} 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; | ||
function siftDown(heap, node, i) { | ||
var index = i; | ||
var length = heap.length; | ||
var isAnimationFrameScheduled = false; | ||
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. | ||
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; | ||
var fpsLocked = false; | ||
shouldYieldToHost = function () { | ||
return frameDeadline <= exports.unstable_now(); | ||
}; | ||
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) { | ||
activeFrameTime = Math.floor(1000 / fps); | ||
fpsLocked = true; | ||
} else { | ||
// reset the framerate | ||
activeFrameTime = 33; | ||
fpsLocked = false; | ||
} | ||
}; | ||
// We use the postMessage trick to defer idle work until after the repaint. | ||
var channel = new MessageChannel(); | ||
var port = channel.port2; | ||
channel.port1.onmessage = function (event) { | ||
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; | ||
if (left !== undefined && compare(left, node) < 0) { | ||
if (right !== undefined && compare(right, left) < 0) { | ||
heap[index] = right; | ||
heap[rightIndex] = node; | ||
index = rightIndex; | ||
} 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; | ||
heap[index] = left; | ||
heap[leftIndex] = node; | ||
index = leftIndex; | ||
} | ||
} | ||
if (prevScheduledCallback !== null) { | ||
isFlushingHostCallback = true; | ||
try { | ||
prevScheduledCallback(didTimeout); | ||
} finally { | ||
isFlushingHostCallback = 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 if (right !== undefined && compare(right, node) < 0) { | ||
heap[index] = right; | ||
heap[rightIndex] = node; | ||
index = rightIndex; | ||
} else { | ||
// No pending work. Exit. | ||
isAnimationFrameScheduled = false; | ||
// Neither child is smaller. Exit. | ||
return; | ||
} | ||
} | ||
} | ||
var nextFrameTime = rafTime - frameDeadline + activeFrameTime; | ||
if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime && !fpsLocked) { | ||
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; | ||
port.postMessage(undefined); | ||
} | ||
}; | ||
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. | ||
port.postMessage(undefined); | ||
} 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 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? | ||
@@ -289,134 +110,105 @@ var ImmediatePriority = 1; | ||
// Max 31 bit integer. The max integer size in V8 for 32-bit systems. | ||
function markTaskErrored(task, ms) { | ||
} | ||
/* eslint-disable no-var */ | ||
var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; | ||
if (hasPerformanceNow) { | ||
var localPerformance = performance; | ||
exports.unstable_now = function () { | ||
return localPerformance.now(); | ||
}; | ||
} else { | ||
var localDate = Date; | ||
var initialTime = localDate.now(); | ||
exports.unstable_now = function () { | ||
return localDate.now() - initialTime; | ||
}; | ||
} // 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 USER_BLOCKING_PRIORITY = 250; | ||
var maxSigned31BitInt = 1073741823; // Times out immediately | ||
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out | ||
var USER_BLOCKING_PRIORITY_TIMEOUT = 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_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap | ||
var currentHostCallbackDidTimeout = false; | ||
// Pausing the scheduler is useful for debugging. | ||
var isSchedulerPaused = false; | ||
var taskQueue = []; | ||
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. | ||
var currentPriorityLevel = NormalPriority; | ||
var currentEventStartTime = -1; | ||
var currentExpirationTime = -1; | ||
var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. | ||
var currentTask = null; | ||
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. | ||
// This is set while performing work, to prevent re-entrancy. | ||
var isPerformingWork = false; | ||
var isHostCallbackScheduled = false; | ||
var isHostTimeoutScheduled = false; // Capture local references to native APIs, in case a polyfill overrides them. | ||
function scheduleHostCallbackIfNeeded() { | ||
if (isPerformingWork) { | ||
// Don't schedule work yet; wait until the next time we yield. | ||
return; | ||
var setTimeout = window.setTimeout; | ||
var clearTimeout = window.clearTimeout; | ||
if (typeof console !== 'undefined') { | ||
// TODO: Scheduler no longer requires these methods to be polyfilled. But | ||
// maybe we want to continue warning if they don't exist, to preserve the | ||
// option to rely on it in the future? | ||
var requestAnimationFrame = window.requestAnimationFrame; | ||
var cancelAnimationFrame = window.cancelAnimationFrame; | ||
if (typeof requestAnimationFrame !== 'function') { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); | ||
} | ||
if (firstCallbackNode !== null) { | ||
// Schedule the host callback using the earliest expiration in the list. | ||
var expirationTime = firstCallbackNode.expirationTime; | ||
if (isHostCallbackScheduled) { | ||
// Cancel the existing host callback. | ||
cancelHostCallback(); | ||
} else { | ||
isHostCallbackScheduled = true; | ||
} | ||
requestHostCallback(flushWork, expirationTime); | ||
if (typeof cancelAnimationFrame !== 'function') { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); | ||
} | ||
} | ||
function flushFirstCallback() { | ||
var currentlyFlushingCallback = firstCallbackNode; | ||
function advanceTimers(currentTime) { | ||
// Check for tasks that are no longer delayed and add them to the queue. | ||
var timer = peek(timerQueue); | ||
// 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; | ||
} | ||
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 { | ||
// Remaining timers are pending. | ||
return; | ||
} | ||
currentlyFlushingCallback.next = currentlyFlushingCallback.previous = null; | ||
// Now it's safe to call the callback. | ||
var callback = currentlyFlushingCallback.callback; | ||
var expirationTime = currentlyFlushingCallback.expirationTime; | ||
var priorityLevel = currentlyFlushingCallback.priorityLevel; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousExpirationTime = currentExpirationTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentExpirationTime = expirationTime; | ||
var continuationCallback; | ||
try { | ||
var didUserCallbackTimeout = currentHostCallbackDidTimeout || | ||
// Immediate priority callbacks are always called as if they timed out | ||
priorityLevel === ImmediatePriority; | ||
continuationCallback = callback(didUserCallbackTimeout); | ||
} catch (error) { | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentExpirationTime = previousExpirationTime; | ||
timer = peek(timerQueue); | ||
} | ||
} | ||
// 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 handleTimeout(currentTime) { | ||
isHostTimeoutScheduled = false; | ||
advanceTimers(currentTime); | ||
// 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; | ||
if (!isHostCallbackScheduled) { | ||
if (peek(taskQueue) !== null) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} 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); | ||
var firstTimer = peek(timerQueue); | ||
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; | ||
scheduleHostCallbackIfNeeded(); | ||
if (firstTimer !== null) { | ||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); | ||
} | ||
var previous = nextAfterContinuation.previous; | ||
previous.next = nextAfterContinuation.previous = continuationNode; | ||
continuationNode.next = nextAfterContinuation; | ||
continuationNode.previous = previous; | ||
} | ||
@@ -426,50 +218,92 @@ } | ||
function flushWork(didUserCallbackTimeout) { | ||
// Exit right away if we're currently paused | ||
if (enableSchedulerDebugging && isSchedulerPaused) { | ||
return; | ||
} | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
// We'll need a new 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; | ||
var previousDidTimeout = currentHostCallbackDidTimeout; | ||
currentHostCallbackDidTimeout = didUserCallbackTimeout; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
try { | ||
if (didUserCallbackTimeout) { | ||
// Flush all the expired callbacks without yielding. | ||
while (firstCallbackNode !== null && !(enableSchedulerDebugging && isSchedulerPaused)) { | ||
// TODO Wrap in feature flag | ||
// 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 && !(enableSchedulerDebugging && isSchedulerPaused)); | ||
continue; | ||
if (enableProfiling) { | ||
try { | ||
return workLoop(hasTimeRemaining, initialTime); | ||
} catch (error) { | ||
if (currentTask !== null) { | ||
var currentTime = exports.unstable_now(); | ||
markTaskErrored(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
break; | ||
throw error; | ||
} | ||
} else { | ||
// Keep flushing callbacks until we run out of time in the frame. | ||
if (firstCallbackNode !== null) { | ||
do { | ||
if (enableSchedulerDebugging && isSchedulerPaused) { | ||
break; | ||
} | ||
flushFirstCallback(); | ||
} while (firstCallbackNode !== null && !shouldYieldToHost()); | ||
} | ||
// No catch in prod code path. | ||
return workLoop(hasTimeRemaining, initialTime); | ||
} | ||
} finally { | ||
currentTask = null; | ||
currentPriorityLevel = previousPriorityLevel; | ||
isPerformingWork = false; | ||
currentHostCallbackDidTimeout = previousDidTimeout; | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
} | ||
} | ||
function workLoop(hasTimeRemaining, initialTime) { | ||
var currentTime = initialTime; | ||
advanceTimers(currentTime); | ||
currentTask = peek(taskQueue); | ||
while (currentTask !== null && !(enableSchedulerDebugging )) { | ||
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { | ||
// This currentTask hasn't expired, and we've reached the deadline. | ||
break; | ||
} | ||
var callback = currentTask.callback; | ||
if (typeof callback === 'function') { | ||
currentTask.callback = null; | ||
currentPriorityLevel = currentTask.priorityLevel; | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
var continuationCallback = callback(didUserCallbackTimeout); | ||
currentTime = exports.unstable_now(); | ||
if (typeof continuationCallback === 'function') { | ||
currentTask.callback = continuationCallback; | ||
} else { | ||
if (currentTask === peek(taskQueue)) { | ||
pop(taskQueue); | ||
} | ||
} | ||
advanceTimers(currentTime); | ||
} else { | ||
pop(taskQueue); | ||
} | ||
currentTask = peek(taskQueue); | ||
} // Return whether there's additional work | ||
if (currentTask !== null) { | ||
return true; | ||
} else { | ||
var firstTimer = peek(timerQueue); | ||
if (firstTimer !== null) { | ||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); | ||
} | ||
return false; | ||
} | ||
} | ||
function unstable_runWithPriority(priorityLevel, eventHandler) { | ||
@@ -483,2 +317,3 @@ switch (priorityLevel) { | ||
break; | ||
default: | ||
@@ -489,15 +324,8 @@ priorityLevel = NormalPriority; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentEventStartTime = exports.unstable_now(); | ||
try { | ||
return eventHandler(); | ||
} catch (error) { | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
@@ -507,3 +335,4 @@ } | ||
function unstable_next(eventHandler) { | ||
var priorityLevel = void 0; | ||
var priorityLevel; | ||
switch (currentPriorityLevel) { | ||
@@ -516,2 +345,3 @@ case ImmediatePriority: | ||
break; | ||
default: | ||
@@ -524,15 +354,8 @@ // Anything lower than normal priority should remain at the current level. | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentEventStartTime = exports.unstable_now(); | ||
try { | ||
return eventHandler(); | ||
} catch (error) { | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
@@ -546,15 +369,8 @@ } | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = parentPriorityLevel; | ||
currentEventStartTime = exports.unstable_now(); | ||
try { | ||
return callback.apply(this, arguments); | ||
} catch (error) { | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
@@ -564,83 +380,93 @@ }; | ||
function unstable_scheduleCallback(priorityLevel, callback, deprecated_options) { | ||
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : exports.unstable_now(); | ||
function unstable_scheduleCallback(priorityLevel, callback, options) { | ||
var currentTime = exports.unstable_now(); | ||
var startTime; | ||
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; | ||
if (typeof options === 'object' && options !== null) { | ||
var delay = options.delay; | ||
if (typeof delay === 'number' && delay > 0) { | ||
startTime = currentTime + delay; | ||
} else { | ||
startTime = currentTime; | ||
} | ||
} else { | ||
switch (priorityLevel) { | ||
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; | ||
} | ||
startTime = currentTime; | ||
} | ||
var newNode = { | ||
var timeout; | ||
switch (priorityLevel) { | ||
case ImmediatePriority: | ||
timeout = IMMEDIATE_PRIORITY_TIMEOUT; | ||
break; | ||
case UserBlockingPriority: | ||
timeout = USER_BLOCKING_PRIORITY_TIMEOUT; | ||
break; | ||
case IdlePriority: | ||
timeout = IDLE_PRIORITY_TIMEOUT; | ||
break; | ||
case LowPriority: | ||
timeout = LOW_PRIORITY_TIMEOUT; | ||
break; | ||
case NormalPriority: | ||
default: | ||
timeout = NORMAL_PRIORITY_TIMEOUT; | ||
break; | ||
} | ||
var expirationTime = startTime + timeout; | ||
var newTask = { | ||
id: taskIdCounter++, | ||
callback: callback, | ||
priorityLevel: priorityLevel, | ||
startTime: startTime, | ||
expirationTime: expirationTime, | ||
next: null, | ||
previous: null | ||
sortIndex: -1 | ||
}; | ||
// Insert the new callback into the list, ordered first by expiration, then | ||
// by insertion. So the new callback is inserted after any other callback | ||
// with equal expiration. | ||
if (firstCallbackNode === null) { | ||
// This is the first callback in the list. | ||
firstCallbackNode = newNode.next = newNode.previous = newNode; | ||
scheduleHostCallbackIfNeeded(); | ||
if (startTime > currentTime) { | ||
// This is a delayed task. | ||
newTask.sortIndex = startTime; | ||
push(timerQueue, newTask); | ||
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. | ||
requestHostTimeout(handleTimeout, startTime - currentTime); | ||
} | ||
} 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); | ||
newTask.sortIndex = expirationTime; | ||
push(taskQueue, newTask); | ||
// wait until the next time we yield. | ||
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; | ||
scheduleHostCallbackIfNeeded(); | ||
if (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
var previous = next.previous; | ||
previous.next = next.previous = newNode; | ||
newNode.next = next; | ||
newNode.previous = previous; | ||
} | ||
return newNode; | ||
return newTask; | ||
} | ||
function unstable_pauseExecution() { | ||
isSchedulerPaused = true; | ||
} | ||
function unstable_continueExecution() { | ||
isSchedulerPaused = false; | ||
if (firstCallbackNode !== null) { | ||
scheduleHostCallbackIfNeeded(); | ||
if (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
@@ -650,52 +476,141 @@ } | ||
function unstable_getFirstCallbackNode() { | ||
return firstCallbackNode; | ||
return peek(taskQueue); | ||
} | ||
function unstable_cancelCallback(callbackNode) { | ||
var next = callbackNode.next; | ||
if (next === null) { | ||
// Already cancelled. | ||
function unstable_cancelCallback(task) { | ||
// remove from the queue because you can't remove arbitrary nodes from an | ||
// array based heap, only the first one.) | ||
task.callback = null; | ||
} | ||
function unstable_getCurrentPriorityLevel() { | ||
return currentPriorityLevel; | ||
} | ||
var isMessageLoopRunning = false; | ||
var scheduledHostCallback = null; | ||
var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main | ||
// thread, like user events. By default, it yields multiple times per frame. | ||
// It does not attempt to align with frame boundaries, since most tasks don't | ||
// need to be frame aligned; for those that do, use requestAnimationFrame. | ||
var yieldInterval = 5; | ||
var deadline = 0; // TODO: Make this configurable | ||
function shouldYieldToHost() { | ||
{ | ||
// `isInputPending` is not available. Since we have no way of knowing if | ||
// there's pending input, always yield at the end of the frame. | ||
return exports.unstable_now() >= deadline; | ||
} | ||
} | ||
function requestPaint() { | ||
} | ||
function forceFrameRate(fps) { | ||
if (fps < 0 || fps > 125) { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported'); | ||
return; | ||
} | ||
if (next === callbackNode) { | ||
// This is the only scheduled callback. Clear the list. | ||
firstCallbackNode = null; | ||
if (fps > 0) { | ||
yieldInterval = Math.floor(1000 / fps); | ||
} 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; | ||
// reset the framerate | ||
yieldInterval = 5; | ||
} | ||
} | ||
callbackNode.next = callbackNode.previous = null; | ||
var performWorkUntilDeadline = function () { | ||
if (scheduledHostCallback !== null) { | ||
var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync | ||
// cycle. This means there's always time remaining at the beginning of | ||
// the message event. | ||
deadline = currentTime + yieldInterval; | ||
var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the | ||
// error can be observed. | ||
// | ||
// Intentionally not using a try-catch, since that makes some debugging | ||
// techniques harder. Instead, if `scheduledHostCallback` errors, then | ||
// `hasMoreWork` will remain true, and we'll continue the work loop. | ||
var hasMoreWork = true; | ||
try { | ||
hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); | ||
} finally { | ||
if (hasMoreWork) { | ||
// If there's more work, schedule the next message event at the end | ||
// of the preceding one. | ||
schedulePerformWorkUntilDeadline(); | ||
} else { | ||
isMessageLoopRunning = false; | ||
scheduledHostCallback = null; | ||
} | ||
} | ||
} else { | ||
isMessageLoopRunning = false; | ||
} // Yielding to the browser will give it a chance to paint, so we can | ||
}; | ||
var schedulePerformWorkUntilDeadline; | ||
{ | ||
var channel = new MessageChannel(); | ||
var port = channel.port2; | ||
channel.port1.onmessage = performWorkUntilDeadline; | ||
schedulePerformWorkUntilDeadline = function () { | ||
port.postMessage(null); | ||
}; | ||
} | ||
function unstable_getCurrentPriorityLevel() { | ||
return currentPriorityLevel; | ||
function requestHostCallback(callback) { | ||
scheduledHostCallback = callback; | ||
if (!isMessageLoopRunning) { | ||
isMessageLoopRunning = true; | ||
schedulePerformWorkUntilDeadline(); | ||
} | ||
} | ||
function unstable_shouldYield() { | ||
return !currentHostCallbackDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost()); | ||
function requestHostTimeout(callback, ms) { | ||
taskTimeoutID = setTimeout(function () { | ||
callback(exports.unstable_now()); | ||
}, ms); | ||
} | ||
function cancelHostTimeout() { | ||
clearTimeout(taskTimeoutID); | ||
taskTimeoutID = -1; | ||
} | ||
var unstable_requestPaint = requestPaint; | ||
var unstable_Profiling = null; | ||
exports.unstable_IdlePriority = IdlePriority; | ||
exports.unstable_ImmediatePriority = ImmediatePriority; | ||
exports.unstable_LowPriority = LowPriority; | ||
exports.unstable_NormalPriority = NormalPriority; | ||
exports.unstable_Profiling = unstable_Profiling; | ||
exports.unstable_UserBlockingPriority = UserBlockingPriority; | ||
exports.unstable_NormalPriority = NormalPriority; | ||
exports.unstable_IdlePriority = IdlePriority; | ||
exports.unstable_LowPriority = LowPriority; | ||
exports.unstable_cancelCallback = unstable_cancelCallback; | ||
exports.unstable_continueExecution = unstable_continueExecution; | ||
exports.unstable_forceFrameRate = forceFrameRate; | ||
exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; | ||
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; | ||
exports.unstable_next = unstable_next; | ||
exports.unstable_pauseExecution = unstable_pauseExecution; | ||
exports.unstable_requestPaint = unstable_requestPaint; | ||
exports.unstable_runWithPriority = unstable_runWithPriority; | ||
exports.unstable_next = unstable_next; | ||
exports.unstable_scheduleCallback = unstable_scheduleCallback; | ||
exports.unstable_cancelCallback = unstable_cancelCallback; | ||
exports.unstable_shouldYield = shouldYieldToHost; | ||
exports.unstable_wrapCallback = unstable_wrapCallback; | ||
exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; | ||
exports.unstable_shouldYield = unstable_shouldYield; | ||
exports.unstable_continueExecution = unstable_continueExecution; | ||
exports.unstable_pauseExecution = unstable_pauseExecution; | ||
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; | ||
})(); | ||
} |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-50b50c26f | ||
/** @license React vundefined | ||
* scheduler.production.min.js | ||
@@ -9,14 +9,11 @@ * | ||
*/ | ||
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var d=void 0,f=void 0,g=void 0;exports.unstable_now=void 0;exports.unstable_forceFrameRate=void 0;var k=Date,l="function"===typeof setTimeout?setTimeout:void 0,n="function"===typeof clearTimeout?clearTimeout:void 0,p="function"===typeof requestAnimationFrame?requestAnimationFrame:void 0,q="function"===typeof cancelAnimationFrame?cancelAnimationFrame:void 0,r=void 0,t=void 0; | ||
function u(a){r=p(function(b){n(t);a(b)});t=l(function(){q(r);a(exports.unstable_now())},100)}if("object"===typeof performance&&"function"===typeof performance.now){var v=performance;exports.unstable_now=function(){return v.now()}}else exports.unstable_now=function(){return k.now()}; | ||
if("undefined"===typeof window||"function"!==typeof MessageChannel){var w=null,x=function(a){if(null!==w)try{w(a)}finally{w=null}};d=function(a){null!==w?setTimeout(d,0,a):(w=a,setTimeout(x,0,!1))};f=function(){w=null};g=function(){return!1};exports.unstable_forceFrameRate=function(){}}else{"undefined"!==typeof console&&("function"!==typeof p&&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 q&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"));var y=null,z=!1,A=-1,B=!1,C=!1,D=0,E=33,F=33,G=!1;g=function(){return D<=exports.unstable_now()};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?(F=Math.floor(1E3/a),G=!0):(F=33,G=!1)};var H=new MessageChannel, | ||
I=H.port2;H.port1.onmessage=function(){z=!1;var a=y,b=A;y=null;A=-1;var c=exports.unstable_now(),e=!1;if(0>=D-c)if(-1!==b&&b<=c)e=!0;else{B||(B=!0,u(J));y=a;A=b;return}if(null!==a){C=!0;try{a(e)}finally{C=!1}}};var J=function(a){if(null!==y){u(J);var b=a-D+F;b<F&&E<F&&!G?(8>b&&(b=8),F=b<E?E:b):E=b;D=a+F;z||(z=!0,I.postMessage(void 0))}else B=!1};d=function(a,b){y=a;A=b;C||0>b?I.postMessage(void 0):B||(B=!0,u(J))};f=function(){y=null;z=!1;A=-1}}var K=null,L=!1,M=3,N=-1,O=-1,P=!1,Q=!1; | ||
function R(){if(!P&&null!==K){var a=K.expirationTime;Q?f():Q=!0;d(S,a)}} | ||
function T(){var a=K,b=K.next;if(K===b)K=null;else{var c=K.previous;K=c.next=b;b.previous=c}a.next=a.previous=null;c=a.callback;b=a.expirationTime;a=a.priorityLevel;var e=M,m=O;M=a;O=b;try{var h=c(L||1===a)}catch(U){throw U;}finally{M=e,O=m}if("function"===typeof h)if(h={callback:h,priorityLevel:a,expirationTime:b,next:null,previous:null},null===K)K=h.next=h.previous=h;else{c=null;a=K;do{if(a.expirationTime>=b){c=a;break}a=a.next}while(a!==K);null===c?c=K:c===K&&(K=h,R());b=c.previous;b.next=c.previous= | ||
h;h.next=c;h.previous=b}}function S(a){Q=!1;P=!0;var b=L;L=a;try{if(a)for(;null!==K;){var c=exports.unstable_now();if(K.expirationTime<=c){do T();while(null!==K&&K.expirationTime<=c)}else break}else if(null!==K){do T();while(null!==K&&!g())}}finally{P=!1,L=b,R()}}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=M,e=N;M=a;N=exports.unstable_now();try{return b()}catch(m){throw R(),m;}finally{M=c,N=e}};exports.unstable_next=function(a){switch(M){case 1:case 2:case 3:var b=3;break;default:b=M}var c=M,e=N;M=b;N=exports.unstable_now();try{return a()}catch(m){throw R(),m;}finally{M=c,N=e}}; | ||
exports.unstable_scheduleCallback=function(a,b,c){var e=-1!==N?N:exports.unstable_now();if("object"===typeof c&&null!==c&&"number"===typeof c.timeout)c=e+c.timeout;else switch(a){case 1:c=e+-1;break;case 2:c=e+250;break;case 5:c=e+1073741823;break;case 4:c=e+1E4;break;default:c=e+5E3}a={callback:b,priorityLevel:a,expirationTime:c,next:null,previous:null};if(null===K)K=a.next=a.previous=a,R();else{b=null;e=K;do{if(e.expirationTime>c){b=e;break}e=e.next}while(e!==K);null===b?b=K:b===K&&(K=a,R());c= | ||
b.previous;c.next=b.previous=a;a.next=b;a.previous=c}return a};exports.unstable_cancelCallback=function(a){var b=a.next;if(null!==b){if(b===a)K=null;else{a===K&&(K=b);var c=a.previous;c.next=b;b.previous=c}a.next=a.previous=null}};exports.unstable_wrapCallback=function(a){var b=M;return function(){var c=M,e=N;M=b;N=exports.unstable_now();try{return a.apply(this,arguments)}catch(m){throw R(),m;}finally{M=c,N=e}}};exports.unstable_getCurrentPriorityLevel=function(){return M}; | ||
exports.unstable_shouldYield=function(){return!L&&(null!==K&&K.expirationTime<O||g())};exports.unstable_continueExecution=function(){null!==K&&R()};exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return K}; | ||
'use strict';function f(a,b){var c=a.length;a.push(b);a:for(;;){var d=c-1>>>1,e=a[d];if(void 0!==e&&0<g(e,b))a[d]=b,a[c]=e,c=d;else break a}}function h(a){a=a[0];return void 0===a?null:a}function k(a){var b=a[0];if(void 0!==b){var c=a.pop();if(c!==b){a[0]=c;a:for(var d=0,e=a.length;d<e;){var m=2*(d+1)-1,n=a[m],r=m+1,q=a[r];if(void 0!==n&&0>g(n,c))void 0!==q&&0>g(q,n)?(a[d]=q,a[r]=c,d=r):(a[d]=n,a[m]=c,d=m);else if(void 0!==q&&0>g(q,c))a[d]=q,a[r]=c,d=r;else break a}}return b}return null} | ||
function g(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}if("object"===typeof performance&&"function"===typeof performance.now){var l=performance;exports.unstable_now=function(){return l.now()}}else{var p=Date,t=p.now();exports.unstable_now=function(){return p.now()-t}}var u=[],v=[],w=1,x=null,y=3,z=!1,A=!1,B=!1,C=window.setTimeout,D=window.clearTimeout; | ||
if("undefined"!==typeof console){var E=window.cancelAnimationFrame;"function"!==typeof window.requestAnimationFrame&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");"function"!==typeof E&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills")} | ||
function F(a){for(var b=h(v);null!==b;){if(null===b.callback)k(v);else if(b.startTime<=a)k(v),b.sortIndex=b.expirationTime,f(u,b);else break;b=h(v)}}function G(a){B=!1;F(a);if(!A)if(null!==h(u))A=!0,H(I);else{var b=h(v);null!==b&&J(G,b.startTime-a)}} | ||
function I(a,b){A=!1;B&&(B=!1,D(K),K=-1);z=!0;var c=y;try{F(b);for(x=h(u);null!==x&&(!(x.expirationTime>b)||a&&!L());){var d=x.callback;if("function"===typeof d){x.callback=null;y=x.priorityLevel;var e=d(x.expirationTime<=b);b=exports.unstable_now();"function"===typeof e?x.callback=e:x===h(u)&&k(u);F(b)}else k(u);x=h(u)}if(null!==x)var m=!0;else{var n=h(v);null!==n&&J(G,n.startTime-b);m=!1}return m}finally{x=null,y=c,z=!1}}var M=!1,N=null,K=-1,O=5,P=0; | ||
function L(){return exports.unstable_now()>=P}var Q,R=new MessageChannel,S=R.port2;R.port1.onmessage=function(){if(null!==N){var a=exports.unstable_now();P=a+O;var b=!0;try{b=N(!0,a)}finally{b?Q():(M=!1,N=null)}}else M=!1};Q=function(){S.postMessage(null)};function H(a){N=a;M||(M=!0,Q())}function J(a,b){K=C(function(){a(exports.unstable_now())},b)}exports.unstable_IdlePriority=5;exports.unstable_ImmediatePriority=1;exports.unstable_LowPriority=4;exports.unstable_NormalPriority=3; | ||
exports.unstable_Profiling=null;exports.unstable_UserBlockingPriority=2;exports.unstable_cancelCallback=function(a){a.callback=null};exports.unstable_continueExecution=function(){A||z||(A=!0,H(I))};exports.unstable_forceFrameRate=function(a){0>a||125<a?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<a?Math.floor(1E3/a):5};exports.unstable_getCurrentPriorityLevel=function(){return y}; | ||
exports.unstable_getFirstCallbackNode=function(){return h(u)};exports.unstable_next=function(a){switch(y){case 1:case 2:case 3:var b=3;break;default:b=y}var c=y;y=b;try{return a()}finally{y=c}};exports.unstable_pauseExecution=function(){};exports.unstable_requestPaint=function(){};exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=y;y=a;try{return b()}finally{y=c}}; | ||
exports.unstable_scheduleCallback=function(a,b,c){var d=exports.unstable_now();"object"===typeof c&&null!==c?(c=c.delay,c="number"===typeof c&&0<c?d+c:d):c=d;switch(a){case 1:var e=-1;break;case 2:e=250;break;case 5:e=1073741823;break;case 4:e=1E4;break;default:e=5E3}e=c+e;a={id:w++,callback:b,priorityLevel:a,startTime:c,expirationTime:e,sortIndex:-1};c>d?(a.sortIndex=c,f(v,a),null===h(u)&&a===h(v)&&(B?(D(K),K=-1):B=!0,J(G,c-d))):(a.sortIndex=e,f(u,a),A||z||(A=!0,H(I)));return a}; | ||
exports.unstable_shouldYield=L;exports.unstable_wrapCallback=function(a){var b=y;return function(){var c=y;y=b;try{return a.apply(this,arguments)}finally{y=c}}}; |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
if (typeof window === 'undefined' || typeof MessageChannel !== 'function') { | ||
module.exports = require('./unstable_no_dom'); | ||
} else if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/scheduler.production.min.js'); | ||
@@ -5,0 +7,0 @@ } else { |
{ | ||
"name": "scheduler", | ||
"version": "0.0.0-50b50c26f", | ||
"version": "0.0.0-553440bd1", | ||
"description": "Cooperative scheduler for the browser environment.", | ||
@@ -31,2 +31,4 @@ "main": "index.js", | ||
"unstable_mock.js", | ||
"unstable_no_dom.js", | ||
"unstable_post_task.js", | ||
"cjs/", | ||
@@ -40,2 +42,2 @@ "umd/" | ||
} | ||
} | ||
} |
@@ -17,4 +17,4 @@ /** | ||
: typeof define === 'function' && define.amd // eslint-disable-line no-undef | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.SchedulerTracing = factory(global)); | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.SchedulerTracing = factory(global)); | ||
})(this, function(global) { | ||
@@ -21,0 +21,0 @@ function unstable_clear() { |
@@ -17,4 +17,4 @@ /** | ||
: typeof define === 'function' && define.amd // eslint-disable-line no-undef | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.SchedulerTracing = factory(global)); | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.SchedulerTracing = factory(global)); | ||
})(this, function(global) { | ||
@@ -21,0 +21,0 @@ function unstable_clear() { |
@@ -17,4 +17,4 @@ /** | ||
: typeof define === 'function' && define.amd // eslint-disable-line no-undef | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.SchedulerTracing = factory(global)); | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.SchedulerTracing = factory(global)); | ||
})(this, function(global) { | ||
@@ -21,0 +21,0 @@ function unstable_clear() { |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-50b50c26f | ||
/** @license React vundefined | ||
* scheduler-unstable_mock.development.js | ||
@@ -9,567 +9,686 @@ * | ||
*/ | ||
'use strict'; | ||
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(factory((global.SchedulerMock = {}))); | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = global || self, factory(global.SchedulerMock = {})); | ||
}(this, (function (exports) { 'use strict'; | ||
var enableSchedulerDebugging = false; | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = false; // TODO: enable to fix https://github.com/facebook/react/issues/20756. | ||
var currentTime = 0; | ||
var scheduledCallback = null; | ||
var scheduledCallbackExpiration = -1; | ||
var yieldedValues = null; | ||
var expectedNumberOfYields = -1; | ||
var didStop = false; | ||
var isFlushing = false; | ||
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]; | ||
function requestHostCallback(callback, expiration) { | ||
scheduledCallback = callback; | ||
scheduledCallbackExpiration = expiration; | ||
} | ||
if (first !== undefined) { | ||
var last = heap.pop(); | ||
function cancelHostCallback() { | ||
scheduledCallback = null; | ||
scheduledCallbackExpiration = -1; | ||
} | ||
if (last !== first) { | ||
heap[0] = last; | ||
siftDown(heap, last, 0); | ||
} | ||
function shouldYieldToHost() { | ||
if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) { | ||
// We yielded at least as many values as expected. Stop flushing. | ||
didStop = true; | ||
return true; | ||
return first; | ||
} else { | ||
return null; | ||
} | ||
} | ||
return false; | ||
} | ||
function getCurrentTime() { | ||
return currentTime; | ||
} | ||
function siftUp(heap, node, i) { | ||
var index = i; | ||
function forceFrameRate() { | ||
// No-op | ||
} | ||
while (true) { | ||
var parentIndex = index - 1 >>> 1; | ||
var parent = heap[parentIndex]; | ||
// Should only be used via an assertion helper that inspects the yielded values. | ||
function unstable_flushNumberOfYields(count) { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
expectedNumberOfYields = count; | ||
isFlushing = true; | ||
try { | ||
while (scheduledCallback !== null && !didStop) { | ||
var cb = scheduledCallback; | ||
scheduledCallback = null; | ||
var didTimeout = scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime; | ||
cb(didTimeout); | ||
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; | ||
} | ||
} | ||
} finally { | ||
expectedNumberOfYields = -1; | ||
didStop = false; | ||
isFlushing = false; | ||
} | ||
} | ||
function unstable_flushExpired() { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
if (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
scheduledCallback = null; | ||
isFlushing = true; | ||
try { | ||
cb(true); | ||
} finally { | ||
isFlushing = false; | ||
} | ||
} | ||
} | ||
function siftDown(heap, node, i) { | ||
var index = i; | ||
var length = heap.length; | ||
function unstable_flushWithoutYielding() { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
isFlushing = true; | ||
try { | ||
if (scheduledCallback === null) { | ||
return false; | ||
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; | ||
} | ||
} | ||
while (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
scheduledCallback = null; | ||
var didTimeout = scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime; | ||
cb(didTimeout); | ||
} | ||
return true; | ||
} finally { | ||
expectedNumberOfYields = -1; | ||
didStop = false; | ||
isFlushing = false; | ||
} | ||
} | ||
function unstable_clearYields() { | ||
if (yieldedValues === null) { | ||
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; | ||
} | ||
var values = yieldedValues; | ||
yieldedValues = null; | ||
return values; | ||
} | ||
function flushAll() { | ||
if (yieldedValues !== null) { | ||
throw new Error('Log is not empty. Assert on the log of yielded values before ' + 'flushing additional work.'); | ||
} | ||
unstable_flushWithoutYielding(); | ||
if (yieldedValues !== null) { | ||
throw new Error('While flushing work, something yielded a value. Use an ' + 'assertion helper to assert on the log of yielded values, e.g. ' + 'expect(Scheduler).toFlushAndYield([...])'); | ||
} | ||
} | ||
// TODO: Use symbols? | ||
var ImmediatePriority = 1; | ||
var UserBlockingPriority = 2; | ||
var NormalPriority = 3; | ||
var LowPriority = 4; | ||
var IdlePriority = 5; | ||
function yieldValue(value) { | ||
if (yieldedValues === null) { | ||
yieldedValues = [value]; | ||
} else { | ||
yieldedValues.push(value); | ||
function markTaskErrored(task, ms) { | ||
} | ||
} | ||
function advanceTime(ms) { | ||
currentTime += ms; | ||
// If the host callback timed out, flush the expired work. | ||
if (!isFlushing && scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) { | ||
unstable_flushExpired(); | ||
} | ||
} | ||
/* eslint-disable no-var */ | ||
// Math.pow(2, 30) - 1 | ||
// 0b111111111111111111111111111111 | ||
/* eslint-disable no-var */ | ||
var maxSigned31BitInt = 1073741823; // Times out immediately | ||
// TODO: Use symbols? | ||
var ImmediatePriority = 1; | ||
var UserBlockingPriority = 2; | ||
var NormalPriority = 3; | ||
var LowPriority = 4; | ||
var IdlePriority = 5; | ||
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out | ||
// Max 31 bit integer. The max integer size in V8 for 32-bit systems. | ||
// Math.pow(2, 30) - 1 | ||
// 0b111111111111111111111111111111 | ||
var maxSigned31BitInt = 1073741823; | ||
var USER_BLOCKING_PRIORITY_TIMEOUT = 250; | ||
var NORMAL_PRIORITY_TIMEOUT = 5000; | ||
var LOW_PRIORITY_TIMEOUT = 10000; // Never times out | ||
// 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 IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap | ||
// Callbacks are stored as a circular, doubly linked list. | ||
var firstCallbackNode = null; | ||
var taskQueue = []; | ||
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. | ||
var currentHostCallbackDidTimeout = false; | ||
// Pausing the scheduler is useful for debugging. | ||
var isSchedulerPaused = false; | ||
var taskIdCounter = 1; // Pausing the scheduler is useful for debugging. | ||
var currentTask = null; | ||
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. | ||
var currentPriorityLevel = NormalPriority; | ||
var currentEventStartTime = -1; | ||
var currentExpirationTime = -1; | ||
var isPerformingWork = false; | ||
var isHostCallbackScheduled = false; | ||
var isHostTimeoutScheduled = false; | ||
var currentMockTime = 0; | ||
var scheduledCallback = null; | ||
var scheduledTimeout = null; | ||
var timeoutTime = -1; | ||
var yieldedValues = null; | ||
var expectedNumberOfYields = -1; | ||
var didStop = false; | ||
var isFlushing = false; | ||
var needsPaint = false; | ||
var shouldYieldForPaint = false; | ||
// This is set while performing work, to prevent re-entrancy. | ||
var isPerformingWork = false; | ||
function advanceTimers(currentTime) { | ||
// Check for tasks that are no longer delayed and add them to the queue. | ||
var timer = peek(timerQueue); | ||
var isHostCallbackScheduled = false; | ||
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 { | ||
// Remaining timers are pending. | ||
return; | ||
} | ||
function scheduleHostCallbackIfNeeded() { | ||
if (isPerformingWork) { | ||
// Don't schedule work yet; wait until the next time we yield. | ||
return; | ||
} | ||
if (firstCallbackNode !== null) { | ||
// Schedule the host callback using the earliest expiration in the list. | ||
var expirationTime = firstCallbackNode.expirationTime; | ||
if (isHostCallbackScheduled) { | ||
// Cancel the existing host callback. | ||
cancelHostCallback(); | ||
} else { | ||
isHostCallbackScheduled = true; | ||
timer = peek(timerQueue); | ||
} | ||
requestHostCallback(flushWork, expirationTime); | ||
} | ||
} | ||
function flushFirstCallback() { | ||
var currentlyFlushingCallback = firstCallbackNode; | ||
function handleTimeout(currentTime) { | ||
isHostTimeoutScheduled = false; | ||
advanceTimers(currentTime); | ||
// 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; | ||
if (!isHostCallbackScheduled) { | ||
if (peek(taskQueue) !== null) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} else { | ||
var firstTimer = peek(timerQueue); | ||
if (firstTimer !== null) { | ||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); | ||
} | ||
} | ||
} | ||
} | ||
currentlyFlushingCallback.next = currentlyFlushingCallback.previous = null; | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
// Now it's safe to call the callback. | ||
var callback = currentlyFlushingCallback.callback; | ||
var expirationTime = currentlyFlushingCallback.expirationTime; | ||
var priorityLevel = currentlyFlushingCallback.priorityLevel; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousExpirationTime = currentExpirationTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentExpirationTime = expirationTime; | ||
var continuationCallback; | ||
try { | ||
var didUserCallbackTimeout = currentHostCallbackDidTimeout || | ||
// Immediate priority callbacks are always called as if they timed out | ||
priorityLevel === ImmediatePriority; | ||
continuationCallback = callback(didUserCallbackTimeout); | ||
} catch (error) { | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentExpirationTime = previousExpirationTime; | ||
} | ||
// 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 | ||
}; | ||
isHostCallbackScheduled = false; | ||
// 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; | ||
} 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; | ||
if (isHostTimeoutScheduled) { | ||
// We scheduled a timeout but it's no longer needed. Cancel it. | ||
isHostTimeoutScheduled = false; | ||
cancelHostTimeout(); | ||
} | ||
isPerformingWork = true; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
try { | ||
if (enableProfiling) { | ||
try { | ||
return workLoop(hasTimeRemaining, initialTime); | ||
} catch (error) { | ||
if (currentTask !== null) { | ||
var currentTime = getCurrentTime(); | ||
markTaskErrored(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
throw error; | ||
} | ||
node = node.next; | ||
} while (node !== firstCallbackNode); | ||
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; | ||
scheduleHostCallbackIfNeeded(); | ||
} else { | ||
// No catch in prod code path. | ||
return workLoop(hasTimeRemaining, initialTime); | ||
} | ||
var previous = nextAfterContinuation.previous; | ||
previous.next = nextAfterContinuation.previous = continuationNode; | ||
continuationNode.next = nextAfterContinuation; | ||
continuationNode.previous = previous; | ||
} finally { | ||
currentTask = null; | ||
currentPriorityLevel = previousPriorityLevel; | ||
isPerformingWork = false; | ||
} | ||
} | ||
} | ||
function flushWork(didUserCallbackTimeout) { | ||
// Exit right away if we're currently paused | ||
if (enableSchedulerDebugging && isSchedulerPaused) { | ||
return; | ||
} | ||
function workLoop(hasTimeRemaining, initialTime) { | ||
var currentTime = initialTime; | ||
advanceTimers(currentTime); | ||
currentTask = peek(taskQueue); | ||
// We'll need a new host callback the next time work is scheduled. | ||
isHostCallbackScheduled = false; | ||
while (currentTask !== null && !(enableSchedulerDebugging )) { | ||
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { | ||
// This currentTask hasn't expired, and we've reached the deadline. | ||
break; | ||
} | ||
isPerformingWork = true; | ||
var previousDidTimeout = currentHostCallbackDidTimeout; | ||
currentHostCallbackDidTimeout = didUserCallbackTimeout; | ||
try { | ||
if (didUserCallbackTimeout) { | ||
// Flush all the expired callbacks without yielding. | ||
while (firstCallbackNode !== null && !(enableSchedulerDebugging && isSchedulerPaused)) { | ||
// TODO Wrap in feature flag | ||
// 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 = getCurrentTime(); | ||
if (firstCallbackNode.expirationTime <= currentTime) { | ||
do { | ||
flushFirstCallback(); | ||
} while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused)); | ||
continue; | ||
var callback = currentTask.callback; | ||
if (typeof callback === 'function') { | ||
currentTask.callback = null; | ||
currentPriorityLevel = currentTask.priorityLevel; | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
var continuationCallback = callback(didUserCallbackTimeout); | ||
currentTime = getCurrentTime(); | ||
if (typeof continuationCallback === 'function') { | ||
currentTask.callback = continuationCallback; | ||
} else { | ||
if (currentTask === peek(taskQueue)) { | ||
pop(taskQueue); | ||
} | ||
} | ||
break; | ||
advanceTimers(currentTime); | ||
} else { | ||
pop(taskQueue); | ||
} | ||
currentTask = peek(taskQueue); | ||
} // Return whether there's additional work | ||
if (currentTask !== null) { | ||
return true; | ||
} else { | ||
// Keep flushing callbacks until we run out of time in the frame. | ||
if (firstCallbackNode !== null) { | ||
do { | ||
if (enableSchedulerDebugging && isSchedulerPaused) { | ||
break; | ||
} | ||
flushFirstCallback(); | ||
} while (firstCallbackNode !== null && !shouldYieldToHost()); | ||
var firstTimer = peek(timerQueue); | ||
if (firstTimer !== null) { | ||
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime); | ||
} | ||
return false; | ||
} | ||
} finally { | ||
isPerformingWork = false; | ||
currentHostCallbackDidTimeout = previousDidTimeout; | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
} | ||
} | ||
function unstable_runWithPriority(priorityLevel, eventHandler) { | ||
switch (priorityLevel) { | ||
case ImmediatePriority: | ||
case UserBlockingPriority: | ||
case NormalPriority: | ||
case LowPriority: | ||
case IdlePriority: | ||
break; | ||
default: | ||
priorityLevel = NormalPriority; | ||
} | ||
function unstable_runWithPriority(priorityLevel, eventHandler) { | ||
switch (priorityLevel) { | ||
case ImmediatePriority: | ||
case UserBlockingPriority: | ||
case NormalPriority: | ||
case LowPriority: | ||
case IdlePriority: | ||
break; | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentEventStartTime = getCurrentTime(); | ||
default: | ||
priorityLevel = NormalPriority; | ||
} | ||
try { | ||
return eventHandler(); | ||
} catch (error) { | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
} | ||
var previousPriorityLevel = currentPriorityLevel; | ||
currentPriorityLevel = priorityLevel; | ||
function unstable_next(eventHandler) { | ||
var priorityLevel = void 0; | ||
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; | ||
try { | ||
return eventHandler(); | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
} | ||
} | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = priorityLevel; | ||
currentEventStartTime = getCurrentTime(); | ||
function unstable_next(eventHandler) { | ||
var priorityLevel; | ||
try { | ||
return eventHandler(); | ||
} catch (error) { | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
} | ||
switch (currentPriorityLevel) { | ||
case ImmediatePriority: | ||
case UserBlockingPriority: | ||
case NormalPriority: | ||
// Shift down to normal priority | ||
priorityLevel = NormalPriority; | ||
break; | ||
function unstable_wrapCallback(callback) { | ||
var parentPriorityLevel = currentPriorityLevel; | ||
return function () { | ||
// This is a fork of runWithPriority, inlined for performance. | ||
default: | ||
// Anything lower than normal priority should remain at the current level. | ||
priorityLevel = currentPriorityLevel; | ||
break; | ||
} | ||
var previousPriorityLevel = currentPriorityLevel; | ||
var previousEventStartTime = currentEventStartTime; | ||
currentPriorityLevel = parentPriorityLevel; | ||
currentEventStartTime = getCurrentTime(); | ||
currentPriorityLevel = priorityLevel; | ||
try { | ||
return callback.apply(this, arguments); | ||
} catch (error) { | ||
// There's still work remaining. Request another callback. | ||
scheduleHostCallbackIfNeeded(); | ||
throw error; | ||
return eventHandler(); | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
currentEventStartTime = previousEventStartTime; | ||
} | ||
}; | ||
} | ||
} | ||
function unstable_scheduleCallback(priorityLevel, callback, deprecated_options) { | ||
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime(); | ||
function unstable_wrapCallback(callback) { | ||
var parentPriorityLevel = currentPriorityLevel; | ||
return function () { | ||
// This is a fork of runWithPriority, inlined for performance. | ||
var previousPriorityLevel = currentPriorityLevel; | ||
currentPriorityLevel = parentPriorityLevel; | ||
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 { | ||
try { | ||
return callback.apply(this, arguments); | ||
} finally { | ||
currentPriorityLevel = previousPriorityLevel; | ||
} | ||
}; | ||
} | ||
function unstable_scheduleCallback(priorityLevel, callback, options) { | ||
var currentTime = getCurrentTime(); | ||
var startTime; | ||
if (typeof options === 'object' && options !== null) { | ||
var delay = options.delay; | ||
if (typeof delay === 'number' && delay > 0) { | ||
startTime = currentTime + delay; | ||
} else { | ||
startTime = currentTime; | ||
} | ||
} else { | ||
startTime = currentTime; | ||
} | ||
var timeout; | ||
switch (priorityLevel) { | ||
case ImmediatePriority: | ||
expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT; | ||
timeout = IMMEDIATE_PRIORITY_TIMEOUT; | ||
break; | ||
case UserBlockingPriority: | ||
expirationTime = startTime + USER_BLOCKING_PRIORITY; | ||
timeout = USER_BLOCKING_PRIORITY_TIMEOUT; | ||
break; | ||
case IdlePriority: | ||
expirationTime = startTime + IDLE_PRIORITY; | ||
timeout = IDLE_PRIORITY_TIMEOUT; | ||
break; | ||
case LowPriority: | ||
expirationTime = startTime + LOW_PRIORITY_TIMEOUT; | ||
timeout = LOW_PRIORITY_TIMEOUT; | ||
break; | ||
case NormalPriority: | ||
default: | ||
expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT; | ||
timeout = NORMAL_PRIORITY_TIMEOUT; | ||
break; | ||
} | ||
var expirationTime = startTime + timeout; | ||
var newTask = { | ||
id: taskIdCounter++, | ||
callback: callback, | ||
priorityLevel: priorityLevel, | ||
startTime: startTime, | ||
expirationTime: expirationTime, | ||
sortIndex: -1 | ||
}; | ||
if (startTime > currentTime) { | ||
// This is a delayed task. | ||
newTask.sortIndex = startTime; | ||
push(timerQueue, newTask); | ||
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. | ||
requestHostTimeout(handleTimeout, startTime - currentTime); | ||
} | ||
} else { | ||
newTask.sortIndex = expirationTime; | ||
push(taskQueue, newTask); | ||
// wait until the next time we yield. | ||
if (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
} | ||
return newTask; | ||
} | ||
var newNode = { | ||
callback: callback, | ||
priorityLevel: priorityLevel, | ||
expirationTime: expirationTime, | ||
next: null, | ||
previous: null | ||
}; | ||
function unstable_pauseExecution() { | ||
} | ||
// Insert the new callback into the list, ordered first by expiration, then | ||
// by insertion. So the new callback is inserted after any other callback | ||
// with equal expiration. | ||
if (firstCallbackNode === null) { | ||
// This is the first callback in the list. | ||
firstCallbackNode = newNode.next = newNode.previous = newNode; | ||
scheduleHostCallbackIfNeeded(); | ||
} else { | ||
var next = null; | ||
var node = firstCallbackNode; | ||
do { | ||
if (node.expirationTime > expirationTime) { | ||
// The new callback expires before this one. | ||
next = node; | ||
break; | ||
function unstable_continueExecution() { | ||
if (!isHostCallbackScheduled && !isPerformingWork) { | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
} | ||
} | ||
function unstable_getFirstCallbackNode() { | ||
return peek(taskQueue); | ||
} | ||
function unstable_cancelCallback(task) { | ||
// remove from the queue because you can't remove arbitrary nodes from an | ||
// array based heap, only the first one.) | ||
task.callback = null; | ||
} | ||
function unstable_getCurrentPriorityLevel() { | ||
return currentPriorityLevel; | ||
} | ||
function requestHostCallback(callback) { | ||
scheduledCallback = callback; | ||
} | ||
function requestHostTimeout(callback, ms) { | ||
scheduledTimeout = callback; | ||
timeoutTime = currentMockTime + ms; | ||
} | ||
function cancelHostTimeout() { | ||
scheduledTimeout = null; | ||
timeoutTime = -1; | ||
} | ||
function shouldYieldToHost() { | ||
if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || shouldYieldForPaint && needsPaint) { | ||
// We yielded at least as many values as expected. Stop flushing. | ||
didStop = true; | ||
return true; | ||
} | ||
return false; | ||
} | ||
function getCurrentTime() { | ||
return currentMockTime; | ||
} | ||
function forceFrameRate() {// No-op | ||
} | ||
function reset() { | ||
if (isFlushing) { | ||
throw new Error('Cannot reset while already flushing work.'); | ||
} | ||
currentMockTime = 0; | ||
scheduledCallback = null; | ||
scheduledTimeout = null; | ||
timeoutTime = -1; | ||
yieldedValues = null; | ||
expectedNumberOfYields = -1; | ||
didStop = false; | ||
isFlushing = false; | ||
needsPaint = false; | ||
} // Should only be used via an assertion helper that inspects the yielded values. | ||
function unstable_flushNumberOfYields(count) { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
if (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
expectedNumberOfYields = count; | ||
isFlushing = true; | ||
try { | ||
var hasMoreWork = true; | ||
do { | ||
hasMoreWork = cb(true, currentMockTime); | ||
} while (hasMoreWork && !didStop); | ||
if (!hasMoreWork) { | ||
scheduledCallback = null; | ||
} | ||
} finally { | ||
expectedNumberOfYields = -1; | ||
didStop = false; | ||
isFlushing = false; | ||
} | ||
node = node.next; | ||
} while (node !== firstCallbackNode); | ||
} | ||
} | ||
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; | ||
scheduleHostCallbackIfNeeded(); | ||
function unstable_flushUntilNextPaint() { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
var previous = next.previous; | ||
previous.next = next.previous = newNode; | ||
newNode.next = next; | ||
newNode.previous = previous; | ||
if (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
shouldYieldForPaint = true; | ||
needsPaint = false; | ||
isFlushing = true; | ||
try { | ||
var hasMoreWork = true; | ||
do { | ||
hasMoreWork = cb(true, currentMockTime); | ||
} while (hasMoreWork && !didStop); | ||
if (!hasMoreWork) { | ||
scheduledCallback = null; | ||
} | ||
} finally { | ||
shouldYieldForPaint = false; | ||
didStop = false; | ||
isFlushing = false; | ||
} | ||
} | ||
} | ||
return newNode; | ||
} | ||
function unstable_flushExpired() { | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
function unstable_pauseExecution() { | ||
isSchedulerPaused = true; | ||
} | ||
if (scheduledCallback !== null) { | ||
isFlushing = true; | ||
function unstable_continueExecution() { | ||
isSchedulerPaused = false; | ||
if (firstCallbackNode !== null) { | ||
scheduleHostCallbackIfNeeded(); | ||
try { | ||
var hasMoreWork = scheduledCallback(false, currentMockTime); | ||
if (!hasMoreWork) { | ||
scheduledCallback = null; | ||
} | ||
} finally { | ||
isFlushing = false; | ||
} | ||
} | ||
} | ||
} | ||
function unstable_getFirstCallbackNode() { | ||
return firstCallbackNode; | ||
} | ||
function unstable_flushAllWithoutAsserting() { | ||
// Returns false if no work was flushed. | ||
if (isFlushing) { | ||
throw new Error('Already flushing work.'); | ||
} | ||
function unstable_cancelCallback(callbackNode) { | ||
var next = callbackNode.next; | ||
if (next === null) { | ||
// Already cancelled. | ||
return; | ||
if (scheduledCallback !== null) { | ||
var cb = scheduledCallback; | ||
isFlushing = true; | ||
try { | ||
var hasMoreWork = true; | ||
do { | ||
hasMoreWork = cb(true, currentMockTime); | ||
} while (hasMoreWork); | ||
if (!hasMoreWork) { | ||
scheduledCallback = null; | ||
} | ||
return true; | ||
} finally { | ||
isFlushing = false; | ||
} | ||
} else { | ||
return false; | ||
} | ||
} | ||
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; | ||
function unstable_clearYields() { | ||
if (yieldedValues === null) { | ||
return []; | ||
} | ||
var previous = callbackNode.previous; | ||
previous.next = next; | ||
next.previous = previous; | ||
var values = yieldedValues; | ||
yieldedValues = null; | ||
return values; | ||
} | ||
callbackNode.next = callbackNode.previous = null; | ||
} | ||
function unstable_flushAll() { | ||
if (yieldedValues !== null) { | ||
throw new Error('Log is not empty. Assert on the log of yielded values before ' + 'flushing additional work.'); | ||
} | ||
function unstable_getCurrentPriorityLevel() { | ||
return currentPriorityLevel; | ||
} | ||
unstable_flushAllWithoutAsserting(); | ||
function unstable_shouldYield() { | ||
return !currentHostCallbackDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost()); | ||
} | ||
if (yieldedValues !== null) { | ||
throw new Error('While flushing work, something yielded a value. Use an ' + 'assertion helper to assert on the log of yielded values, e.g. ' + 'expect(Scheduler).toFlushAndYield([...])'); | ||
} | ||
} | ||
exports.unstable_flushWithoutYielding = unstable_flushWithoutYielding; | ||
exports.unstable_flushNumberOfYields = unstable_flushNumberOfYields; | ||
exports.unstable_flushExpired = unstable_flushExpired; | ||
exports.unstable_clearYields = unstable_clearYields; | ||
exports.flushAll = flushAll; | ||
exports.yieldValue = yieldValue; | ||
exports.advanceTime = advanceTime; | ||
exports.unstable_ImmediatePriority = ImmediatePriority; | ||
exports.unstable_UserBlockingPriority = UserBlockingPriority; | ||
exports.unstable_NormalPriority = NormalPriority; | ||
exports.unstable_IdlePriority = IdlePriority; | ||
exports.unstable_LowPriority = LowPriority; | ||
exports.unstable_runWithPriority = unstable_runWithPriority; | ||
exports.unstable_next = unstable_next; | ||
exports.unstable_scheduleCallback = unstable_scheduleCallback; | ||
exports.unstable_cancelCallback = unstable_cancelCallback; | ||
exports.unstable_wrapCallback = unstable_wrapCallback; | ||
exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; | ||
exports.unstable_shouldYield = unstable_shouldYield; | ||
exports.unstable_continueExecution = unstable_continueExecution; | ||
exports.unstable_pauseExecution = unstable_pauseExecution; | ||
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; | ||
exports.unstable_now = getCurrentTime; | ||
exports.unstable_forceFrameRate = forceFrameRate; | ||
function unstable_yieldValue(value) { | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
if (console.log.name === 'disabledLog') { | ||
// If console.log has been patched, we assume we're in render | ||
// replaying and we ignore any values yielding in the second pass. | ||
return; | ||
} | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
if (yieldedValues === null) { | ||
yieldedValues = [value]; | ||
} else { | ||
yieldedValues.push(value); | ||
} | ||
} | ||
function unstable_advanceTime(ms) { | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
if (console.log.name === 'disabledLog') { | ||
// If console.log has been patched, we assume we're in render | ||
// replaying and we ignore any time advancing in the second pass. | ||
return; | ||
} | ||
currentMockTime += ms; | ||
if (scheduledTimeout !== null && timeoutTime <= currentMockTime) { | ||
scheduledTimeout(currentMockTime); | ||
timeoutTime = -1; | ||
scheduledTimeout = null; | ||
} | ||
} | ||
function requestPaint() { | ||
needsPaint = true; | ||
} | ||
var unstable_Profiling = null; | ||
exports.reset = reset; | ||
exports.unstable_IdlePriority = IdlePriority; | ||
exports.unstable_ImmediatePriority = ImmediatePriority; | ||
exports.unstable_LowPriority = LowPriority; | ||
exports.unstable_NormalPriority = NormalPriority; | ||
exports.unstable_Profiling = unstable_Profiling; | ||
exports.unstable_UserBlockingPriority = UserBlockingPriority; | ||
exports.unstable_advanceTime = unstable_advanceTime; | ||
exports.unstable_cancelCallback = unstable_cancelCallback; | ||
exports.unstable_clearYields = unstable_clearYields; | ||
exports.unstable_continueExecution = unstable_continueExecution; | ||
exports.unstable_flushAll = unstable_flushAll; | ||
exports.unstable_flushAllWithoutAsserting = unstable_flushAllWithoutAsserting; | ||
exports.unstable_flushExpired = unstable_flushExpired; | ||
exports.unstable_flushNumberOfYields = unstable_flushNumberOfYields; | ||
exports.unstable_flushUntilNextPaint = unstable_flushUntilNextPaint; | ||
exports.unstable_forceFrameRate = forceFrameRate; | ||
exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel; | ||
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; | ||
exports.unstable_next = unstable_next; | ||
exports.unstable_now = getCurrentTime; | ||
exports.unstable_pauseExecution = unstable_pauseExecution; | ||
exports.unstable_requestPaint = requestPaint; | ||
exports.unstable_runWithPriority = unstable_runWithPriority; | ||
exports.unstable_scheduleCallback = unstable_scheduleCallback; | ||
exports.unstable_shouldYield = shouldYieldToHost; | ||
exports.unstable_wrapCallback = unstable_wrapCallback; | ||
exports.unstable_yieldValue = unstable_yieldValue; | ||
}))); |
@@ -1,2 +0,2 @@ | ||
/** @license React v0.0.0-50b50c26f | ||
/** @license React vundefined | ||
* scheduler-unstable_mock.production.min.js | ||
@@ -9,9 +9,11 @@ * | ||
*/ | ||
'use strict';(function(b,q){"object"===typeof exports&&"undefined"!==typeof module?q(exports):"function"===typeof define&&define.amd?define(["exports"],q):q(b.SchedulerMock={})})(this,function(b){function q(){return-1!==r&&null!==l&&l.length>=r||-1!==m&&m<=f?v=!0:!1}function z(){if(n)throw Error("Already flushing work.");if(null!==h){var a=h;h=null;n=!0;try{a(!0)}finally{n=!1}}}function A(){if(n)throw Error("Already flushing work.");n=!0;try{if(null===h)return!1;for(;null!==h;){var a=h;h=null;a(-1!== | ||
m&&m<=f)}return!0}finally{r=-1,n=v=!1}}function p(){if(!x&&null!==c){var a=c.expirationTime;y?(h=null,m=-1):y=!0;h=C;m=a}}function B(){var a=c,e=c.next;if(c===e)c=null;else{var d=c.previous;c=d.next=e;e.previous=d}a.next=a.previous=null;d=a.callback;e=a.expirationTime;a=a.priorityLevel;var b=g,h=w;g=a;w=e;try{var f=d(u||1===a)}catch(D){throw D;}finally{g=b,w=h}if("function"===typeof f)if(f={callback:f,priorityLevel:a,expirationTime:e,next:null,previous:null},null===c)c=f.next=f.previous=f;else{d= | ||
null;a=c;do{if(a.expirationTime>=e){d=a;break}a=a.next}while(a!==c);null===d?d=c:d===c&&(c=f,p());e=d.previous;e.next=d.previous=f;f.next=d;f.previous=e}}function C(a){y=!1;x=!0;var e=u;u=a;try{if(a)for(;null!==c;)if(a=f,c.expirationTime<=a){do B();while(null!==c&&c.expirationTime<=a)}else break;else if(null!==c){do B();while(null!==c&&!q())}}finally{x=!1,u=e,p()}}var f=0,h=null,m=-1,l=null,r=-1,v=!1,n=!1,c=null,u=!1,g=3,k=-1,w=-1,x=!1,y=!1;b.unstable_flushWithoutYielding=A;b.unstable_flushNumberOfYields= | ||
function(a){if(n)throw Error("Already flushing work.");r=a;n=!0;try{for(;null!==h&&!v;)a=h,h=null,a(-1!==m&&m<=f)}finally{r=-1,n=v=!1}};b.unstable_flushExpired=z;b.unstable_clearYields=function(){if(null===l)return[];var a=l;l=null;return a};b.flushAll=function(){if(null!==l)throw Error("Log is not empty. Assert on the log of yielded values before flushing additional work.");A();if(null!==l)throw Error("While flushing work, something yielded a value. Use an assertion helper to assert on the log of yielded values, e.g. expect(Scheduler).toFlushAndYield([...])"); | ||
};b.yieldValue=function(a){null===l?l=[a]:l.push(a)};b.advanceTime=function(a){f+=a;!n&&-1!==m&&m<=f&&z()};b.unstable_ImmediatePriority=1;b.unstable_UserBlockingPriority=2;b.unstable_NormalPriority=3;b.unstable_IdlePriority=5;b.unstable_LowPriority=4;b.unstable_runWithPriority=function(a,c){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var d=g,e=k;g=a;k=f;try{return c()}catch(t){throw p(),t;}finally{g=d,k=e}};b.unstable_next=function(a){switch(g){case 1:case 2:case 3:var c=3;break; | ||
default:c=g}var d=g,b=k;g=c;k=f;try{return a()}catch(t){throw p(),t;}finally{g=d,k=b}};b.unstable_scheduleCallback=function(a,e,d){var b=-1!==k?k:f;if("object"===typeof d&&null!==d&&"number"===typeof d.timeout)d=b+d.timeout;else switch(a){case 1:d=b+-1;break;case 2:d=b+250;break;case 5:d=b+1073741823;break;case 4:d=b+1E4;break;default:d=b+5E3}a={callback:e,priorityLevel:a,expirationTime:d,next:null,previous:null};if(null===c)c=a.next=a.previous=a,p();else{e=null;b=c;do{if(b.expirationTime>d){e=b; | ||
break}b=b.next}while(b!==c);null===e?e=c:e===c&&(c=a,p());d=e.previous;d.next=e.previous=a;a.next=e;a.previous=d}return a};b.unstable_cancelCallback=function(a){var b=a.next;if(null!==b){if(b===a)c=null;else{a===c&&(c=b);var d=a.previous;d.next=b;b.previous=d}a.next=a.previous=null}};b.unstable_wrapCallback=function(a){var b=g;return function(){var c=g,e=k;g=b;k=f;try{return a.apply(this,arguments)}catch(t){throw p(),t;}finally{g=c,k=e}}};b.unstable_getCurrentPriorityLevel=function(){return g};b.unstable_shouldYield= | ||
function(){return!u&&(null!==c&&c.expirationTime<w||q())};b.unstable_continueExecution=function(){null!==c&&p()};b.unstable_pauseExecution=function(){};b.unstable_getFirstCallbackNode=function(){return c};b.unstable_now=function(){return f};b.unstable_forceFrameRate=function(){};Object.defineProperty(b,"__esModule",{value:!0})}); | ||
(function(){'use strict';(function(a,p){"object"===typeof exports&&"undefined"!==typeof module?p(exports):"function"===typeof define&&define.amd?define(["exports"],p):(a=a||self,p(a.SchedulerMock={}))})(this,function(a){function p(b,h){var c=b.length;b.push(h);a:for(;;){var a=c-1>>>1,w=b[a];if(void 0!==w&&0<z(w,h))b[a]=h,b[c]=w,c=a;else break a}}function m(b){b=b[0];return void 0===b?null:b}function A(b){var h=b[0];if(void 0!==h){var c=b.pop();if(c!==h){b[0]=c;a:for(var a=0,w=b.length;a<w;){var e=2*(a+1)-1,d= | ||
b[e],g=e+1,f=b[g];if(void 0!==d&&0>z(d,c))void 0!==f&&0>z(f,d)?(b[a]=f,b[g]=c,a=g):(b[a]=d,b[e]=c,a=e);else if(void 0!==f&&0>z(f,c))b[a]=f,b[g]=c,a=g;else break a}}return h}return null}function z(b,h){var a=b.sortIndex-h.sortIndex;return 0!==a?a:b.id-h.id}function D(b){for(var a=m(r);null!==a;){if(null===a.callback)A(r);else if(a.startTime<=b)A(r),a.sortIndex=a.expirationTime,p(n,a);else break;a=m(r)}}function E(b){x=!1;D(b);if(!u)if(null!==m(n))u=!0,e=F;else{var a=m(r);null!==a&&(b=a.startTime-b, | ||
q=E,t=g+b)}}function F(b,a){u=!1;x&&(x=!1,q=null,t=-1);B=!0;var c=d;try{D(a);for(l=m(n);null!==l&&(!(l.expirationTime>a)||b&&!H());){var h=l.callback;if("function"===typeof h){l.callback=null;d=l.priorityLevel;var e=h(l.expirationTime<=a);a=g;"function"===typeof e?l.callback=e:l===m(n)&&A(n);D(a)}else A(n);l=m(n)}if(null!==l)var f=!0;else{var k=m(r);if(null!==k){var p=k.startTime-a;q=E;t=g+p}f=!1}return f}finally{l=null,d=c,B=!1}}function H(){return-1!==y&&null!==k&&k.length>=y||G&&C?v=!0:!1}function I(){if(f)throw Error("Already flushing work."); | ||
if(null!==e){var b=e;f=!0;try{var a=!0;do a=b(!0,g);while(a);a||(e=null);return!0}finally{f=!1}}else return!1}var n=[],r=[],J=1,l=null,d=3,B=!1,u=!1,x=!1,g=0,e=null,q=null,t=-1,k=null,y=-1,v=!1,f=!1,C=!1,G=!1;a.reset=function(){if(f)throw Error("Cannot reset while already flushing work.");g=0;q=e=null;t=-1;k=null;y=-1;C=f=v=!1};a.unstable_IdlePriority=5;a.unstable_ImmediatePriority=1;a.unstable_LowPriority=4;a.unstable_NormalPriority=3;a.unstable_Profiling=null;a.unstable_UserBlockingPriority=2;a.unstable_advanceTime= | ||
function(b){"disabledLog"!==console.log.name&&(g+=b,null!==q&&t<=g&&(q(g),t=-1,q=null))};a.unstable_cancelCallback=function(b){b.callback=null};a.unstable_clearYields=function(){if(null===k)return[];var b=k;k=null;return b};a.unstable_continueExecution=function(){u||B||(u=!0,e=F)};a.unstable_flushAll=function(){if(null!==k)throw Error("Log is not empty. Assert on the log of yielded values before flushing additional work.");I();if(null!==k)throw Error("While flushing work, something yielded a value. Use an assertion helper to assert on the log of yielded values, e.g. expect(Scheduler).toFlushAndYield([...])"); | ||
};a.unstable_flushAllWithoutAsserting=I;a.unstable_flushExpired=function(){if(f)throw Error("Already flushing work.");if(null!==e){f=!0;try{e(!1,g)||(e=null)}finally{f=!1}}};a.unstable_flushNumberOfYields=function(b){if(f)throw Error("Already flushing work.");if(null!==e){var a=e;y=b;f=!0;try{b=!0;do b=a(!0,g);while(b&&!v);b||(e=null)}finally{y=-1,f=v=!1}}};a.unstable_flushUntilNextPaint=function(){if(f)throw Error("Already flushing work.");if(null!==e){var a=e;G=!0;C=!1;f=!0;try{var h=!0;do h=a(!0, | ||
g);while(h&&!v);h||(e=null)}finally{f=v=G=!1}}};a.unstable_forceFrameRate=function(){};a.unstable_getCurrentPriorityLevel=function(){return d};a.unstable_getFirstCallbackNode=function(){return m(n)};a.unstable_next=function(a){switch(d){case 1:case 2:case 3:var b=3;break;default:b=d}var c=d;d=b;try{return a()}finally{d=c}};a.unstable_now=function(){return g};a.unstable_pauseExecution=function(){};a.unstable_requestPaint=function(){C=!0};a.unstable_runWithPriority=function(a,e){switch(a){case 1:case 2:case 3:case 4:case 5:break; | ||
default:a=3}var b=d;d=a;try{return e()}finally{d=b}};a.unstable_scheduleCallback=function(a,f,c){var b=g;"object"===typeof c&&null!==c?(c=c.delay,c="number"===typeof c&&0<c?b+c:b):c=b;switch(a){case 1:var d=-1;break;case 2:d=250;break;case 5:d=1073741823;break;case 4:d=1E4;break;default:d=5E3}d=c+d;a={id:J++,callback:f,priorityLevel:a,startTime:c,expirationTime:d,sortIndex:-1};c>b?(a.sortIndex=c,p(r,a),null===m(n)&&a===m(r)&&(x?(q=null,t=-1):x=!0,q=E,t=g+(c-b))):(a.sortIndex=d,p(n,a),u||B||(u=!0, | ||
e=F));return a};a.unstable_shouldYield=H;a.unstable_wrapCallback=function(a){var b=d;return function(){var c=d;d=b;try{return a.apply(this,arguments)}finally{d=c}}};a.unstable_yieldValue=function(a){"disabledLog"!==console.log.name&&(null===k?k=[a]:k.push(a))}}); | ||
})(); |
@@ -19,4 +19,4 @@ /** | ||
: typeof define === 'function' && define.amd // eslint-disable-line no-undef | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.Scheduler = factory(global)); | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.Scheduler = factory(global)); | ||
})(this, function(global) { | ||
@@ -51,2 +51,9 @@ function unstable_now() { | ||
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() { | ||
@@ -113,2 +120,3 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_runWithPriority.apply( | ||
unstable_shouldYield: unstable_shouldYield, | ||
unstable_requestPaint: unstable_requestPaint, | ||
unstable_runWithPriority: unstable_runWithPriority, | ||
@@ -142,3 +150,7 @@ unstable_next: unstable_next, | ||
}, | ||
get unstable_Profiling() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_Profiling; | ||
}, | ||
}); | ||
}); |
@@ -19,4 +19,4 @@ /** | ||
: typeof define === 'function' && define.amd // eslint-disable-line no-undef | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.Scheduler = factory(global)); | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.Scheduler = factory(global)); | ||
})(this, function(global) { | ||
@@ -51,2 +51,9 @@ function unstable_now() { | ||
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() { | ||
@@ -107,2 +114,3 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_runWithPriority.apply( | ||
unstable_shouldYield: unstable_shouldYield, | ||
unstable_requestPaint: unstable_requestPaint, | ||
unstable_runWithPriority: unstable_runWithPriority, | ||
@@ -136,3 +144,7 @@ unstable_next: unstable_next, | ||
}, | ||
get unstable_Profiling() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_Profiling; | ||
}, | ||
}); | ||
}); |
@@ -19,4 +19,4 @@ /** | ||
: typeof define === 'function' && define.amd // eslint-disable-line no-undef | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.Scheduler = factory(global)); | ||
? define(['react'], factory) // eslint-disable-line no-undef | ||
: (global.Scheduler = factory(global)); | ||
})(this, function(global) { | ||
@@ -51,2 +51,9 @@ function unstable_now() { | ||
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() { | ||
@@ -107,2 +114,3 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_runWithPriority.apply( | ||
unstable_shouldYield: unstable_shouldYield, | ||
unstable_requestPaint: unstable_requestPaint, | ||
unstable_runWithPriority: unstable_runWithPriority, | ||
@@ -136,3 +144,7 @@ unstable_next: unstable_next, | ||
}, | ||
get unstable_Profiling() { | ||
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED | ||
.Scheduler.unstable_Profiling; | ||
}, | ||
}); | ||
}); |
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
149849
30
3828
6
1