Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

scheduler

Package Overview
Dependencies
Maintainers
9
Versions
1902
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scheduler - npm Package Compare versions

Comparing version 0.0.0-50b50c26f to 0.0.0-5faf377df

8

build-info.json
{
"branch": "master",
"buildNumber": "14970",
"checksum": "32f1c37",
"commit": "50b50c26f",
"buildNumber": "54423",
"checksum": "3b849cc",
"commit": "5faf377df",
"environment": "ci",
"reactVersion": "16.8.6-canary-50b50c26f"
"reactVersion": "16.10.2-5faf377df"
}

@@ -1,2 +0,2 @@

/** @license React v0.0.0-50b50c26f
/** @license React v0.0.0-5faf377df
* scheduler-tracing.development.js

@@ -22,4 +22,3 @@ *

// In some cases, StrictMode should also double-render lifecycles.
// In some cases, StrictMode should also double-render lifecycles.
// This can be confusing for tests though,

@@ -29,69 +28,61 @@ // And it can be bad for performance in production.

// To preserve the "Pause on caught exceptions" behavior of the debugger, we
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
// replay the begin phase of a failed component inside invokeGuardedCallback.
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
// Gather advanced timing metrics for Profiler subtrees.
// Trace which interactions trigger each commit.
// Gather advanced timing metrics for Profiler subtrees.
var enableSchedulerTracing = true; // SSR experiments
// Trace which interactions trigger each commit.
var enableSchedulerTracing = true;
// Only used in www builds.
// 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.
// 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
// 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,
// These APIs will no longer be "unstable" in the upcoming 16.7 release,
// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
// Experimental React Flare event system and event components support.
// Experimental Host Component support.
// 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 Scope support.
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
// Experimental React Events support. Only used in www builds for now.
// 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
// For tests, we flush suspense fallbacks in an act scope;
// *except* in some of our own tests, where we test incremental loading states.
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
// Add a callback property to suspense to notify which promises are currently
// in the update queue. This allows reporting and tracing of what is causing
// the user to see a loading state.
// Also allows hydration callbacks to fire when a dehydrated boundary gets
// hydrated or deleted.
// Part of the simplification of React.createElement so we can eventually move
// from React.createElement to React.jsx
// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
// 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
var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs.
// 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;

@@ -122,3 +113,2 @@

}
function unstable_getCurrent() {

@@ -131,7 +121,5 @@ if (!enableSchedulerTracing) {

}
function unstable_getThreadID() {
return ++threadIDCounter;
}
function unstable_trace(name, timestamp, callback) {

@@ -150,14 +138,11 @@ var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;

};
var prevInteractions = exports.__interactionsRef.current;
// Traced interactions should stack/accumulate.
var prevInteractions = exports.__interactionsRef.current; // Traced interactions should stack/accumulate.
// To do that, clone the current interactions.
// The previous set will be restored upon completion.
var interactions = new Set(prevInteractions);
interactions.add(interaction);
exports.__interactionsRef.current = interactions;
var subscriber = exports.__subscriberRef.current;
var returnValue = void 0;
var returnValue;

@@ -184,6 +169,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,3 +183,2 @@ subscriber.onInteractionScheduledWorkCompleted(interaction);

}
function unstable_wrap(callback) {

@@ -209,14 +192,13 @@ var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;

var wrappedInteractions = exports.__interactionsRef.current;
var subscriber = exports.__subscriberRef.current;
var subscriber = exports.__subscriberRef.current;
if (subscriber !== null) {
subscriber.onWorkScheduled(wrappedInteractions, threadID);
}
} // Update the pending async work count for the current interactions.
// Update after calling subscribers in case of error.
// Update the pending async work count for the current interactions.
// Update after calling subscribers in case of error.
wrappedInteractions.forEach(function (interaction) {
interaction.__count++;
});
var hasRun = false;

@@ -227,7 +209,6 @@

exports.__interactionsRef.current = wrappedInteractions;
subscriber = exports.__subscriberRef.current;
try {
var returnValue = void 0;
var returnValue;

@@ -256,7 +237,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) {

@@ -298,2 +278,3 @@ interaction.__count--;

var subscribers = null;
if (enableSchedulerTracing) {

@@ -319,3 +300,2 @@ subscribers = new Set();

}
function unstable_unsubscribe(subscriber) {

@@ -334,3 +314,2 @@ if (enableSchedulerTracing) {

var caughtError = null;
subscribers.forEach(function (subscriber) {

@@ -355,3 +334,2 @@ try {

var caughtError = null;
subscribers.forEach(function (subscriber) {

@@ -376,3 +354,2 @@ try {

var caughtError = null;
subscribers.forEach(function (subscriber) {

@@ -397,3 +374,2 @@ try {

var caughtError = null;
subscribers.forEach(function (subscriber) {

@@ -418,3 +394,2 @@ try {

var caughtError = null;
subscribers.forEach(function (subscriber) {

@@ -439,3 +414,2 @@ try {

var caughtError = null;
subscribers.forEach(function (subscriber) {

@@ -442,0 +416,0 @@ try {

@@ -1,2 +0,2 @@

/** @license React v0.0.0-50b50c26f
/** @license React v0.0.0-5faf377df
* scheduler-tracing.production.min.js

@@ -3,0 +3,0 @@ *

@@ -1,2 +0,2 @@

/** @license React v0.0.0-50b50c26f
/** @license React v0.0.0-5faf377df
* scheduler-tracing.profiling.min.js

@@ -10,9 +10,8 @@ *

'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var g=0,m=0;exports.__interactionsRef=null;exports.__subscriberRef=null;exports.__interactionsRef={current:new Set};exports.__subscriberRef={current:null};var n=null;n=new Set;function p(e){var d=!1,a=null;n.forEach(function(c){try{c.onInteractionTraced(e)}catch(b){d||(d=!0,a=b)}});if(d)throw a;}
function q(e){var d=!1,a=null;n.forEach(function(c){try{c.onInteractionScheduledWorkCompleted(e)}catch(b){d||(d=!0,a=b)}});if(d)throw a;}function r(e,d){var a=!1,c=null;n.forEach(function(b){try{b.onWorkScheduled(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}function t(e,d){var a=!1,c=null;n.forEach(function(b){try{b.onWorkStarted(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}function u(e,d){var a=!1,c=null;n.forEach(function(b){try{b.onWorkStopped(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}
function v(e,d){var a=!1,c=null;n.forEach(function(b){try{b.onWorkCanceled(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}exports.unstable_clear=function(e){var d=exports.__interactionsRef.current;exports.__interactionsRef.current=new Set;try{return e()}finally{exports.__interactionsRef.current=d}};exports.unstable_getCurrent=function(){return exports.__interactionsRef.current};exports.unstable_getThreadID=function(){return++m};
exports.unstable_trace=function(e,d,a){var c=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,b={__count:1,id:g++,name:e,timestamp:d},f=exports.__interactionsRef.current,k=new Set(f);k.add(b);exports.__interactionsRef.current=k;var h=exports.__subscriberRef.current,l=void 0;try{if(null!==h)h.onInteractionTraced(b)}finally{try{if(null!==h)h.onWorkStarted(k,c)}finally{try{l=a()}finally{exports.__interactionsRef.current=f;try{if(null!==h)h.onWorkStopped(k,c)}finally{if(b.__count--,null!==h&&
0===b.__count)h.onInteractionScheduledWorkCompleted(b)}}}}return l};
exports.unstable_wrap=function(e){function d(){var d=exports.__interactionsRef.current;exports.__interactionsRef.current=c;b=exports.__subscriberRef.current;try{var h=void 0;try{if(null!==b)b.onWorkStarted(c,a)}finally{try{h=e.apply(void 0,arguments)}finally{if(exports.__interactionsRef.current=d,null!==b)b.onWorkStopped(c,a)}}return h}finally{f||(f=!0,c.forEach(function(a){a.__count--;if(null!==b&&0===a.__count)b.onInteractionScheduledWorkCompleted(a)}))}}var a=1<arguments.length&&void 0!==arguments[1]?
arguments[1]:0,c=exports.__interactionsRef.current,b=exports.__subscriberRef.current;if(null!==b)b.onWorkScheduled(c,a);c.forEach(function(a){a.__count++});var f=!1;d.cancel=function(){b=exports.__subscriberRef.current;try{if(null!==b)b.onWorkCanceled(c,a)}finally{c.forEach(function(a){a.__count--;if(b&&0===a.__count)b.onInteractionScheduledWorkCompleted(a)})}};return d};
exports.unstable_subscribe=function(e){n.add(e);1===n.size&&(exports.__subscriberRef.current={onInteractionScheduledWorkCompleted:q,onInteractionTraced:p,onWorkCanceled:v,onWorkScheduled:r,onWorkStarted:t,onWorkStopped:u})};exports.unstable_unsubscribe=function(e){n.delete(e);0===n.size&&(exports.__subscriberRef.current=null)};
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var g=0,l=0;exports.__interactionsRef=null;exports.__subscriberRef=null;exports.__interactionsRef={current:new Set};exports.__subscriberRef={current:null};var m=null;m=new Set;function n(e){var d=!1,a=null;m.forEach(function(c){try{c.onInteractionTraced(e)}catch(b){d||(d=!0,a=b)}});if(d)throw a;}
function p(e){var d=!1,a=null;m.forEach(function(c){try{c.onInteractionScheduledWorkCompleted(e)}catch(b){d||(d=!0,a=b)}});if(d)throw a;}function q(e,d){var a=!1,c=null;m.forEach(function(b){try{b.onWorkScheduled(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}function r(e,d){var a=!1,c=null;m.forEach(function(b){try{b.onWorkStarted(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}function t(e,d){var a=!1,c=null;m.forEach(function(b){try{b.onWorkStopped(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}
function u(e,d){var a=!1,c=null;m.forEach(function(b){try{b.onWorkCanceled(e,d)}catch(f){a||(a=!0,c=f)}});if(a)throw c;}exports.unstable_clear=function(e){var d=exports.__interactionsRef.current;exports.__interactionsRef.current=new Set;try{return e()}finally{exports.__interactionsRef.current=d}};exports.unstable_getCurrent=function(){return exports.__interactionsRef.current};exports.unstable_getThreadID=function(){return++l};
exports.unstable_trace=function(e,d,a){var c=3<arguments.length&&void 0!==arguments[3]?arguments[3]:0,b={__count:1,id:g++,name:e,timestamp:d},f=exports.__interactionsRef.current,k=new Set(f);k.add(b);exports.__interactionsRef.current=k;var h=exports.__subscriberRef.current;try{if(null!==h)h.onInteractionTraced(b)}finally{try{if(null!==h)h.onWorkStarted(k,c)}finally{try{var v=a()}finally{exports.__interactionsRef.current=f;try{if(null!==h)h.onWorkStopped(k,c)}finally{if(b.__count--,null!==h&&0===b.__count)h.onInteractionScheduledWorkCompleted(b)}}}}return v};
exports.unstable_wrap=function(e){function d(){var d=exports.__interactionsRef.current;exports.__interactionsRef.current=c;b=exports.__subscriberRef.current;try{try{if(null!==b)b.onWorkStarted(c,a)}finally{try{var h=e.apply(void 0,arguments)}finally{if(exports.__interactionsRef.current=d,null!==b)b.onWorkStopped(c,a)}}return h}finally{f||(f=!0,c.forEach(function(a){a.__count--;if(null!==b&&0===a.__count)b.onInteractionScheduledWorkCompleted(a)}))}}var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:
0,c=exports.__interactionsRef.current,b=exports.__subscriberRef.current;if(null!==b)b.onWorkScheduled(c,a);c.forEach(function(a){a.__count++});var f=!1;d.cancel=function(){b=exports.__subscriberRef.current;try{if(null!==b)b.onWorkCanceled(c,a)}finally{c.forEach(function(a){a.__count--;if(b&&0===a.__count)b.onInteractionScheduledWorkCompleted(a)})}};return d};
exports.unstable_subscribe=function(e){m.add(e);1===m.size&&(exports.__subscriberRef.current={onInteractionScheduledWorkCompleted:p,onInteractionTraced:n,onWorkCanceled:u,onWorkScheduled:q,onWorkStarted:r,onWorkStopped:t})};exports.unstable_unsubscribe=function(e){m.delete(e);0===m.size&&(exports.__subscriberRef.current=null)};

@@ -1,2 +0,2 @@

/** @license React v0.0.0-50b50c26f
/** @license React v0.0.0-5faf377df
* scheduler-unstable_mock.development.js

@@ -22,5 +22,9 @@ *

var enableProfiling = true;
var currentTime = 0;
var scheduledCallback = null;
var scheduledCallbackExpiration = -1;
var scheduledTimeout = null;
var timeoutTime = -1;
var yieldedValues = null;

@@ -30,15 +34,18 @@ var expectedNumberOfYields = -1;

var isFlushing = false;
function requestHostCallback(callback, expiration) {
var needsPaint = false;
var shouldYieldForPaint = false;
function requestHostCallback(callback) {
scheduledCallback = callback;
scheduledCallbackExpiration = expiration;
}
function cancelHostCallback() {
scheduledCallback = null;
scheduledCallbackExpiration = -1;
function requestHostTimeout(callback, ms) {
scheduledTimeout = callback;
timeoutTime = currentTime + ms;
}
function cancelHostTimeout() {
scheduledTimeout = null;
timeoutTime = -1;
}
function shouldYieldToHost() {
if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) {
if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || shouldYieldForPaint && needsPaint) {
// We yielded at least as many values as expected. Stop flushing.

@@ -48,36 +55,67 @@ didStop = true;

}
return false;
}
function getCurrentTime() {
return currentTime;
}
function forceFrameRate() {
// No-op
function forceFrameRate() {// No-op
}
// 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;
// Should only be used via an assertion helper that inspects the yielded values.
function unstable_flushNumberOfYields(count) {
try {
var hasMoreWork = true;
do {
hasMoreWork = cb(true, currentTime);
} while (hasMoreWork && !didStop);
if (!hasMoreWork) {
scheduledCallback = null;
}
} finally {
expectedNumberOfYields = -1;
didStop = false;
isFlushing = false;
}
}
}
function unstable_flushUntilNextPaint() {
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 (scheduledCallback !== null) {
var cb = scheduledCallback;
shouldYieldForPaint = true;
needsPaint = false;
isFlushing = true;
try {
var hasMoreWork = true;
do {
hasMoreWork = cb(true, currentTime);
} while (hasMoreWork && !didStop);
if (!hasMoreWork) {
scheduledCallback = null;
}
} finally {
shouldYieldForPaint = false;
didStop = false;
isFlushing = false;
}
} finally {
expectedNumberOfYields = -1;
didStop = false;
isFlushing = false;
}
}
function unstable_flushExpired() {

@@ -87,8 +125,12 @@ if (isFlushing) {

}
if (scheduledCallback !== null) {
var cb = scheduledCallback;
scheduledCallback = null;
isFlushing = true;
try {
cb(true);
var hasMoreWork = scheduledCallback(false, currentTime);
if (!hasMoreWork) {
scheduledCallback = null;
}
} finally {

@@ -99,26 +141,31 @@ isFlushing = false;

}
function unstable_flushWithoutYielding() {
function unstable_flushAllWithoutAsserting() {
// Returns false if no work was flushed.
if (isFlushing) {
throw new Error('Already flushing work.');
}
isFlushing = true;
try {
if (scheduledCallback === null) {
return false;
if (scheduledCallback !== null) {
var cb = scheduledCallback;
isFlushing = true;
try {
var hasMoreWork = true;
do {
hasMoreWork = cb(true, currentTime);
} while (hasMoreWork);
if (!hasMoreWork) {
scheduledCallback = null;
}
return true;
} finally {
isFlushing = false;
}
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;
} else {
return false;
}
}
function unstable_clearYields() {

@@ -128,2 +175,3 @@ if (yieldedValues === null) {

}
var values = yieldedValues;

@@ -133,8 +181,9 @@ yieldedValues = null;

}
function flushAll() {
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_flushWithoutYielding();
unstable_flushAllWithoutAsserting();
if (yieldedValues !== null) {

@@ -144,4 +193,3 @@ 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) {
function unstable_yieldValue(value) {
if (yieldedValues === null) {

@@ -153,14 +201,103 @@ yieldedValues = [value];

}
function unstable_advanceTime(ms) {
currentTime += ms;
function advanceTime(ms) {
currentTime += ms;
// If the host callback timed out, flush the expired work.
if (!isFlushing && scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) {
if (!isFlushing) {
if (scheduledTimeout !== null && timeoutTime <= currentTime) {
scheduledTimeout(currentTime);
timeoutTime = -1;
scheduledTimeout = null;
}
unstable_flushExpired();
}
}
function requestPaint() {
needsPaint = true;
}
/* eslint-disable no-var */
function push(heap, node) {
var index = heap.length;
heap.push(node);
siftUp(heap, node, index);
}
function peek(heap) {
var first = heap[0];
return first === undefined ? null : first;
}
function pop(heap) {
var first = heap[0];
if (first !== undefined) {
var last = heap.pop();
if (last !== first) {
heap[0] = last;
siftDown(heap, last, 0);
}
return first;
} else {
return null;
}
}
function siftUp(heap, node, i) {
var index = i;
while (true) {
var parentIndex = Math.floor((index - 1) / 2);
var parent = heap[parentIndex];
if (parent !== undefined && compare(parent, node) > 0) {
// The parent is larger. Swap positions.
heap[parentIndex] = node;
heap[index] = parent;
index = parentIndex;
} else {
// The parent is smaller. Exit.
return;
}
}
}
function siftDown(heap, node, i) {
var index = i;
var length = heap.length;
while (index < length) {
var leftIndex = (index + 1) * 2 - 1;
var left = heap[leftIndex];
var rightIndex = leftIndex + 1;
var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
if (left !== undefined && compare(left, node) < 0) {
if (right !== undefined && compare(right, left) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
heap[index] = left;
heap[leftIndex] = node;
index = leftIndex;
}
} else if (right !== undefined && compare(right, node) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
// Neither child is smaller. Exit.
return;
}
}
}
function compare(a, b) {
// Compare sort index first, then task id.
var diff = a.sortIndex - b.sortIndex;
return diff !== 0 ? diff : a.id - b.id;
}
// TODO: Use symbols?
var NoPriority = 0;
var ImmediatePriority = 1;

@@ -172,134 +309,277 @@ var UserBlockingPriority = 2;

// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
var runIdCounter = 0;
var mainThreadIdCounter = 0;
var profilingStateSize = 4;
var sharedProfilingBuffer = enableProfiling ? // $FlowFixMe Flow doesn't know about SharedArrayBuffer
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
: null;
var profilingState = enableProfiling && sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
var PRIORITY = 0;
var CURRENT_TASK_ID = 1;
var CURRENT_RUN_ID = 2;
var QUEUE_SIZE = 3;
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
// array might include canceled tasks.
profilingState[QUEUE_SIZE] = 0;
profilingState[CURRENT_TASK_ID] = 0;
} // Bytes per element is 4
var INITIAL_EVENT_LOG_SIZE = 131072;
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
var eventLogSize = 0;
var eventLogBuffer = null;
var eventLog = null;
var eventLogIndex = 0;
var TaskStartEvent = 1;
var TaskCompleteEvent = 2;
var TaskErrorEvent = 3;
var TaskCancelEvent = 4;
var TaskRunEvent = 5;
var TaskYieldEvent = 6;
var SchedulerSuspendEvent = 7;
var SchedulerResumeEvent = 8;
function logEvent(entries) {
if (eventLog !== null) {
var offset = eventLogIndex;
eventLogIndex += entries.length;
if (eventLogIndex + 1 > eventLogSize) {
eventLogSize *= 2;
if (eventLogSize > MAX_EVENT_LOG_SIZE) {
console.error("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
stopLoggingProfilingEvents();
return;
}
var newEventLog = new Int32Array(eventLogSize * 4);
newEventLog.set(eventLog);
eventLogBuffer = newEventLog.buffer;
eventLog = newEventLog;
}
eventLog.set(entries, offset);
}
}
function startLoggingProfilingEvents() {
eventLogSize = INITIAL_EVENT_LOG_SIZE;
eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
eventLog = new Int32Array(eventLogBuffer);
eventLogIndex = 0;
}
function stopLoggingProfilingEvents() {
var buffer = eventLogBuffer;
eventLogSize = 0;
eventLogBuffer = null;
eventLog = null;
eventLogIndex = 0;
return buffer;
}
function markTaskStart(task, ms) {
if (enableProfiling) {
profilingState[QUEUE_SIZE]++;
if (eventLog !== null) {
// performance.now returns a float, representing milliseconds. When the
// event is logged, it's coerced to an int. Convert to microseconds to
// maintain extra degrees of precision.
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
}
}
}
function markTaskCompleted(task, ms) {
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
}
}
}
function markTaskCanceled(task, ms) {
if (enableProfiling) {
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskCancelEvent, ms * 1000, task.id]);
}
}
}
function markTaskErrored(task, ms) {
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskErrorEvent, ms * 1000, task.id]);
}
}
}
function markTaskRun(task, ms) {
if (enableProfiling) {
runIdCounter++;
profilingState[PRIORITY] = task.priorityLevel;
profilingState[CURRENT_TASK_ID] = task.id;
profilingState[CURRENT_RUN_ID] = runIdCounter;
if (eventLog !== null) {
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
}
}
}
function markTaskYield(task, ms) {
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[CURRENT_RUN_ID] = 0;
if (eventLog !== null) {
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
}
}
}
function markSchedulerSuspended(ms) {
if (enableProfiling) {
mainThreadIdCounter++;
if (eventLog !== null) {
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
}
}
}
function markSchedulerUnsuspended(ms) {
if (enableProfiling) {
if (eventLog !== null) {
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
}
}
}
/* 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 maxSigned31BitInt = 1073741823; // Times out immediately
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
var USER_BLOCKING_PRIORITY = 250;
var NORMAL_PRIORITY_TIMEOUT = 5000;
var LOW_PRIORITY_TIMEOUT = 10000;
// Never times out
var IDLE_PRIORITY = maxSigned31BitInt;
var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
// Callbacks are stored as a circular, doubly linked list.
var firstCallbackNode = null;
var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap
var currentHostCallbackDidTimeout = false;
// Pausing the scheduler is useful for debugging.
var taskQueue = [];
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
var isSchedulerPaused = false;
var currentTask = null;
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy.
var currentPriorityLevel = NormalPriority;
var currentEventStartTime = -1;
var currentExpirationTime = -1;
// This is set while performing work, to prevent re-entrancy.
var isPerformingWork = false;
var isHostCallbackScheduled = false;
var isHostTimeoutScheduled = 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);
if (enableProfiling) {
markTaskStart(timer, currentTime);
timer.isQueued = true;
}
} 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) {
if (enableProfiling) {
markSchedulerUnsuspended(initialTime);
} // We'll need a host callback the next time work is scheduled.
// 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;
}
} else {
// No catch in prod codepath.
return workLoop(hasTimeRemaining, initialTime);
}
} finally {
currentTask = null;
currentPriorityLevel = previousPriorityLevel;
isPerformingWork = false;
var previous = nextAfterContinuation.previous;
previous.next = nextAfterContinuation.previous = continuationNode;
continuationNode.next = nextAfterContinuation;
continuationNode.previous = previous;
if (enableProfiling) {
var _currentTime = getCurrentTime();
markSchedulerSuspended(_currentTime);
}

@@ -309,47 +589,56 @@ }

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 && isSchedulerPaused)) {
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 (callback !== null) {
currentTask.callback = null;
currentPriorityLevel = currentTask.priorityLevel;
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
markTaskRun(currentTask, currentTime);
var continuationCallback = callback(didUserCallbackTimeout);
currentTime = getCurrentTime();
if (typeof continuationCallback === 'function') {
currentTask.callback = continuationCallback;
markTaskYield(currentTask, currentTime);
} else {
if (enableProfiling) {
markTaskCompleted(currentTask, currentTime);
currentTask.isQueued = false;
}
break;
if (currentTask === peek(taskQueue)) {
pop(taskQueue);
}
}
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;
}

@@ -366,2 +655,3 @@ }

break;
default:

@@ -372,15 +662,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;
}

@@ -390,3 +673,4 @@ }

function unstable_next(eventHandler) {
var priorityLevel = void 0;
var priorityLevel;
switch (currentPriorityLevel) {

@@ -399,2 +683,3 @@ case ImmediatePriority:

break;
default:

@@ -407,15 +692,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;
}

@@ -429,15 +707,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;
}

@@ -447,73 +718,91 @@ };

function unstable_scheduleCallback(priorityLevel, callback, deprecated_options) {
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
function timeoutForPriorityLevel(priorityLevel) {
switch (priorityLevel) {
case ImmediatePriority:
return IMMEDIATE_PRIORITY_TIMEOUT;
var expirationTime;
if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
// FIXME: Remove this branch once we lift expiration times out of React.
expirationTime = startTime + deprecated_options.timeout;
case UserBlockingPriority:
return USER_BLOCKING_PRIORITY;
case IdlePriority:
return IDLE_PRIORITY;
case LowPriority:
return LOW_PRIORITY_TIMEOUT;
case NormalPriority:
default:
return NORMAL_PRIORITY_TIMEOUT;
}
}
function unstable_scheduleCallback(priorityLevel, callback, options) {
var currentTime = getCurrentTime();
var startTime;
var timeout;
if (typeof options === 'object' && options !== null) {
var delay = options.delay;
if (typeof delay === 'number' && delay > 0) {
startTime = currentTime + delay;
} else {
startTime = currentTime;
}
timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
} else {
switch (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;
}
timeout = timeoutForPriorityLevel(priorityLevel);
startTime = currentTime;
}
var newNode = {
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 (enableProfiling) {
newTask.isQueued = false;
}
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);
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 (enableProfiling) {
markTaskStart(newTask, currentTime);
newTask.isQueued = true;
} // Schedule a host callback, if needed. If we're already performing work,
// wait until the next time we yield.
if (!isHostCallbackScheduled && !isPerformingWork) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
}
var previous = next.previous;
previous.next = next.previous = newNode;
newNode.next = next;
newNode.previous = previous;
}
return newNode;
return newTask;
}

@@ -527,4 +816,6 @@

isSchedulerPaused = false;
if (firstCallbackNode !== null) {
scheduleHostCallbackIfNeeded();
if (!isHostCallbackScheduled && !isPerformingWork) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
}

@@ -534,26 +825,18 @@ }

function unstable_getFirstCallbackNode() {
return firstCallbackNode;
return peek(taskQueue);
}
function unstable_cancelCallback(callbackNode) {
var next = callbackNode.next;
if (next === null) {
// Already cancelled.
return;
}
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_cancelCallback(task) {
if (enableProfiling) {
if (task.isQueued) {
var currentTime = getCurrentTime();
markTaskCanceled(task, currentTime);
task.isQueued = false;
}
var previous = callbackNode.previous;
previous.next = next;
next.previous = previous;
}
} // Null out the callback to indicate the task has been canceled. (Can't
// remove from the queue because you can't remove arbitrary nodes from an
// array based heap, only the first one.)
callbackNode.next = callbackNode.previous = null;
task.callback = null;
}

@@ -566,12 +849,23 @@

function unstable_shouldYield() {
return !currentHostCallbackDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
var currentTime = getCurrentTime();
advanceTimers(currentTime);
var firstTask = peek(taskQueue);
return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost();
}
exports.unstable_flushWithoutYielding = unstable_flushWithoutYielding;
var unstable_requestPaint = requestPaint;
var unstable_Profiling = enableProfiling ? {
startLoggingProfilingEvents: startLoggingProfilingEvents,
stopLoggingProfilingEvents: stopLoggingProfilingEvents,
sharedProfilingBuffer: sharedProfilingBuffer
} : null;
exports.unstable_flushAllWithoutAsserting = unstable_flushAllWithoutAsserting;
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_flushUntilNextPaint = unstable_flushUntilNextPaint;
exports.unstable_flushAll = unstable_flushAll;
exports.unstable_yieldValue = unstable_yieldValue;
exports.unstable_advanceTime = unstable_advanceTime;
exports.unstable_ImmediatePriority = ImmediatePriority;

@@ -589,2 +883,3 @@ exports.unstable_UserBlockingPriority = UserBlockingPriority;

exports.unstable_shouldYield = unstable_shouldYield;
exports.unstable_requestPaint = unstable_requestPaint;
exports.unstable_continueExecution = unstable_continueExecution;

@@ -595,3 +890,4 @@ exports.unstable_pauseExecution = unstable_pauseExecution;

exports.unstable_forceFrameRate = forceFrameRate;
exports.unstable_Profiling = unstable_Profiling;
})();
}

@@ -1,2 +0,2 @@

/** @license React v0.0.0-50b50c26f
/** @license React v0.0.0-5faf377df
* scheduler-unstable_mock.production.min.js

@@ -10,11 +10,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';Object.defineProperty(exports,"__esModule",{value:!0});var f=0,g=null,h=null,k=-1,l=null,m=-1,n=!1,p=!1,q=!1,r=!1;function t(){return-1!==m&&null!==l&&l.length>=m||r&&q?n=!0:!1}function x(){if(p)throw Error("Already flushing work.");if(null!==g){p=!0;try{g(!1,f)||(g=null)}finally{p=!1}}}function z(){if(p)throw Error("Already flushing work.");if(null!==g){var a=g;p=!0;try{var b=!0;do b=a(!0,f);while(b);b||(g=null);return!0}finally{p=!1}}else return!1}
function A(a,b){var c=a.length;a.push(b);a:for(;;){var d=Math.floor((c-1)/2),e=a[d];if(void 0!==e&&0<B(e,b))a[d]=b,a[c]=e,c=d;else break a}}function C(a){a=a[0];return void 0===a?null:a}function D(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>B(v,c))void 0!==y&&0>B(y,v)?(a[d]=y,a[w]=c,d=w):(a[d]=v,a[u]=c,d=u);else if(void 0!==y&&0>B(y,c))a[d]=y,a[w]=c,d=w;else break a}}return b}return null}
function B(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}var E=[],F=[],G=1,H=null,I=3,J=!1,K=!1,L=!1;function M(a){for(var b=C(F);null!==b;){if(null===b.callback)D(F);else if(b.startTime<=a)D(F),b.sortIndex=b.expirationTime,A(E,b);else break;b=C(F)}}function N(a){L=!1;M(a);if(!K)if(null!==C(E))K=!0,g=O;else{var b=C(F);null!==b&&(a=b.startTime-a,h=N,k=f+a)}}
function O(a,b){K=!1;L&&(L=!1,h=null,k=-1);J=!0;var c=I;try{M(b);for(H=C(E);null!==H&&(!(H.expirationTime>b)||a&&!t());){var d=H.callback;if(null!==d){H.callback=null;I=H.priorityLevel;var e=d(H.expirationTime<=b);b=f;"function"===typeof e?H.callback=e:H===C(E)&&D(E);M(b)}else D(E);H=C(E)}if(null!==H)var u=!0;else{var v=C(F);if(null!==v){var w=v.startTime-b;h=N;k=f+w}u=!1}return u}finally{H=null,I=c,J=!1}}
function P(a){switch(a){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4;default:return 5E3}}exports.unstable_flushAllWithoutAsserting=z;exports.unstable_flushNumberOfYields=function(a){if(p)throw Error("Already flushing work.");if(null!==g){var b=g;m=a;p=!0;try{a=!0;do a=b(!0,f);while(a&&!n);a||(g=null)}finally{m=-1,p=n=!1}}};exports.unstable_flushExpired=x;exports.unstable_clearYields=function(){if(null===l)return[];var a=l;l=null;return a};
exports.unstable_flushUntilNextPaint=function(){if(p)throw Error("Already flushing work.");if(null!==g){var a=g;r=!0;q=!1;p=!0;try{var b=!0;do b=a(!0,f);while(b&&!n);b||(g=null)}finally{p=n=r=!1}}};
exports.unstable_flushAll=function(){if(null!==l)throw Error("Log is not empty. Assert on the log of yielded values before flushing additional work.");z();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([...])");};exports.unstable_yieldValue=function(a){null===l?l=[a]:l.push(a)};exports.unstable_advanceTime=function(a){f+=a;p||(null!==h&&k<=f&&(h(f),k=-1,h=null),x())};
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=I;I=a;try{return b()}finally{I=c}};exports.unstable_next=function(a){switch(I){case 1:case 2:case 3:var b=3;break;default:b=I}var c=I;I=b;try{return a()}finally{I=c}};
exports.unstable_scheduleCallback=function(a,b,c){var d=f;if("object"===typeof c&&null!==c){var e=c.delay;e="number"===typeof e&&0<e?d+e:d;c="number"===typeof c.timeout?c.timeout:P(a)}else c=P(a),e=d;c=e+c;a={id:G++,callback:b,priorityLevel:a,startTime:e,expirationTime:c,sortIndex:-1};e>d?(a.sortIndex=e,A(F,a),null===C(E)&&a===C(F)&&(L?(h=null,k=-1):L=!0,h=N,k=f+(e-d))):(a.sortIndex=c,A(E,a),K||J||(K=!0,g=O));return a};exports.unstable_cancelCallback=function(a){a.callback=null};
exports.unstable_wrapCallback=function(a){var b=I;return function(){var c=I;I=b;try{return a.apply(this,arguments)}finally{I=c}}};exports.unstable_getCurrentPriorityLevel=function(){return I};exports.unstable_shouldYield=function(){var a=f;M(a);var b=C(E);return b!==H&&null!==H&&null!==b&&null!==b.callback&&b.startTime<=a&&b.expirationTime<H.expirationTime||t()};exports.unstable_requestPaint=function(){q=!0};exports.unstable_continueExecution=function(){K||J||(K=!0,g=O)};
exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return C(E)};exports.unstable_now=function(){return f};exports.unstable_forceFrameRate=function(){};exports.unstable_Profiling=null;

@@ -1,2 +0,2 @@

/** @license React v0.0.0-50b50c26f
/** @license React v0.0.0-5faf377df
* scheduler.development.js

@@ -21,4 +21,6 @@ *

var enableSchedulerDebugging = false;
var enableIsInputPending = false;
var enableMessageLoopImplementation = true;
var enableProfiling = true;
// The DOM Scheduler implementation is similar to requestIdleCallback. It
// works by scheduling a requestAnimationFrame, storing the time for the start

@@ -31,65 +33,14 @@ // of the frame, then scheduling a postMessage which gets scheduled after paint.

var requestHostCallback = void 0;
var cancelHostCallback = void 0;
var shouldYieldToHost = void 0;
exports.unstable_now = void 0;
exports.unstable_forceFrameRate = void 0;
var requestHostCallback;
var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
var requestHostTimeout;
var cancelHostTimeout;
var shouldYieldToHost;
var requestPaint;
// We capture a local reference to any global, in case it gets polyfilled after
// this module is initially evaluated. We want to be using a
// consistent implementation.
var localDate = Date;
// This initialization code may run even on server environments if a component
// just imports ReactDOM (e.g. for findDOMNode). Some environments might not
// have setTimeout or clearTimeout. However, we always expect them to be defined
// on the client. https://github.com/facebook/react/pull/13088
var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
// We don't expect either of these to necessarily be defined, but we will error
// later if they are missing on the client.
var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
// requestAnimationFrame does not run when the tab is in the background. If
// we're backgrounded we prefer for that work to happen so that the page
// continues to load in the background. So we also schedule a 'setTimeout' as
// a fallback.
// TODO: Need a better heuristic for backgrounded work.
var ANIMATION_FRAME_TIMEOUT = 100;
var rAFID = 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
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 window === 'undefined' || // Check if MessageChannel is supported, too.
typeof MessageChannel !== 'function') {

@@ -99,12 +50,27 @@ // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,

var _callback = null;
var _flushCallback = function (didTimeout) {
var _timeoutID = null;
var _flushCallback = function () {
if (_callback !== null) {
try {
_callback(didTimeout);
} finally {
var currentTime = exports.unstable_now();
var hasRemainingTime = true;
_callback(hasRemainingTime, currentTime);
_callback = null;
} catch (e) {
setTimeout(_flushCallback, 0);
throw e;
}
}
};
requestHostCallback = function (cb, ms) {
var initialTime = Date.now();
exports.unstable_now = function () {
return Date.now() - initialTime;
};
requestHostCallback = function (cb) {
if (_callback !== null) {

@@ -115,19 +81,35 @@ // Protect against re-entrancy.

_callback = cb;
setTimeout(_flushCallback, 0, false);
setTimeout(_flushCallback, 0);
}
};
cancelHostCallback = function () {
_callback = null;
requestHostTimeout = function (cb, ms) {
_timeoutID = setTimeout(cb, ms);
};
cancelHostTimeout = function () {
clearTimeout(_timeoutID);
};
shouldYieldToHost = function () {
return false;
};
exports.unstable_forceFrameRate = function () {};
requestPaint = exports.unstable_forceFrameRate = function () {};
} else {
// Capture local references to native APIs, in case a polyfill overrides them.
var performance = window.performance;
var _Date = window.Date;
var _setTimeout = window.setTimeout;
var _clearTimeout = window.clearTimeout;
var requestAnimationFrame = window.requestAnimationFrame;
var cancelAnimationFrame = window.cancelAnimationFrame;
if (typeof console !== 'undefined') {
// TODO: Remove fb.me link
if (typeof localRequestAnimationFrame !== 'function') {
if (typeof requestAnimationFrame !== 'function') {
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
}
if (typeof localCancelAnimationFrame !== 'function') {
if (typeof cancelAnimationFrame !== 'function') {
console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');

@@ -137,22 +119,79 @@ }

if (typeof performance === 'object' && typeof performance.now === 'function') {
exports.unstable_now = function () {
return performance.now();
};
} else {
var _initialTime = _Date.now();
exports.unstable_now = function () {
return _Date.now() - _initialTime;
};
}
var isRAFLoopRunning = false;
var isMessageLoopRunning = false;
var scheduledHostCallback = null;
var isMessageEventScheduled = false;
var timeoutTime = -1;
var rAFTimeoutID = -1;
var taskTimeoutID = -1;
var frameLength = enableMessageLoopImplementation ? // We won't attempt to align with the vsync. Instead we'll yield multiple
// times per frame, often enough to keep it responsive even at really
// high frame rates > 120.
5 : // Use a heuristic to measure the frame rate and yield at the end of the
// frame. We start out assuming that we run at 30fps but then the
// heuristic tracking will adjust this value to a faster fps if we get
// more frequent animation frames.
33.33;
var prevRAFTime = -1;
var prevRAFInterval = -1;
var frameDeadline = 0;
var fpsLocked = false; // TODO: Make this configurable
// TODO: Adjust this based on priority?
var isAnimationFrameScheduled = false;
var maxFrameLength = 300;
var needsPaint = false;
var isFlushingHostCallback = false;
if (enableIsInputPending && navigator !== undefined && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined) {
var scheduling = navigator.scheduling;
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 () {
var currentTime = exports.unstable_now();
shouldYieldToHost = function () {
return frameDeadline <= exports.unstable_now();
};
if (currentTime >= frameDeadline) {
// There's no time left in the frame. We may want to yield control of
// the main thread, so the browser can perform high priority tasks. The
// main ones are painting and user input. If there's a pending paint or
// a pending input, then we should yield. But if there's neither, then
// we can yield less often while remaining responsive. We'll eventually
// yield regardless, since there could be a pending paint that wasn't
// accompanied by a call to `requestPaint`, or other main thread tasks
// like network events.
if (needsPaint || scheduling.isInputPending()) {
// There is either a pending paint or a pending input.
return true;
} // There's no pending input. Only yield if we've reached the max
// frame length.
return currentTime >= frameDeadline + maxFrameLength;
} else {
// There's still time left in the frame.
return false;
}
};
requestPaint = function () {
needsPaint = true;
};
} else {
// `isInputPending` is not available. Since we have no way of knowing if
// there's pending input, always yield at the end of the frame.
shouldYieldToHost = function () {
return exports.unstable_now() >= frameDeadline;
}; // Since we yield every frame regardless, `requestPaint` has no effect.
requestPaint = function () {};
}
exports.unstable_forceFrameRate = function (fps) {

@@ -163,8 +202,9 @@ if (fps < 0 || fps > 125) {

}
if (fps > 0) {
activeFrameTime = Math.floor(1000 / fps);
frameLength = Math.floor(1000 / fps);
fpsLocked = true;
} else {
// reset the framerate
activeFrameTime = 33;
frameLength = 33.33;
fpsLocked = false;

@@ -174,115 +214,253 @@ }

// We use the postMessage trick to defer idle work until after the repaint.
var performWorkUntilDeadline = function () {
if (enableMessageLoopImplementation) {
if (scheduledHostCallback !== null) {
var currentTime = exports.unstable_now(); // Yield after `frameLength` ms, regardless of where we are in the vsync
// cycle. This means there's always time remaining at the beginning of
// the message event.
frameDeadline = currentTime + frameLength;
var hasTimeRemaining = true;
try {
var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
if (!hasMoreWork) {
isMessageLoopRunning = false;
scheduledHostCallback = null;
} else {
// If there's more work, schedule the next message event at the end
// of the preceding one.
port.postMessage(null);
}
} catch (error) {
// If a scheduler task throws, exit the current browser task so the
// error can be observed.
port.postMessage(null);
throw error;
}
} else {
isMessageLoopRunning = false;
} // Yielding to the browser will give it a chance to paint, so we can
// reset this.
needsPaint = false;
} else {
if (scheduledHostCallback !== null) {
var _currentTime = exports.unstable_now();
var _hasTimeRemaining = frameDeadline - _currentTime > 0;
try {
var _hasMoreWork = scheduledHostCallback(_hasTimeRemaining, _currentTime);
if (!_hasMoreWork) {
scheduledHostCallback = null;
}
} catch (error) {
// If a scheduler task throws, exit the current browser task so the
// error can be observed, and post a new task as soon as possible
// so we can continue where we left off.
port.postMessage(null);
throw error;
}
} // Yielding to the browser will give it a chance to paint, so we can
// reset this.
needsPaint = false;
}
};
var channel = new MessageChannel();
var port = channel.port2;
channel.port1.onmessage = function (event) {
isMessageEventScheduled = false;
channel.port1.onmessage = performWorkUntilDeadline;
var prevScheduledCallback = scheduledHostCallback;
var prevTimeoutTime = timeoutTime;
scheduledHostCallback = null;
timeoutTime = -1;
var onAnimationFrame = function (rAFTime) {
if (scheduledHostCallback === null) {
// No scheduled work. Exit.
prevRAFTime = -1;
prevRAFInterval = -1;
isRAFLoopRunning = false;
return;
} // Eagerly schedule the next animation callback at the beginning of the
// frame. If the scheduler queue is not empty at the end of the frame, it
// will continue flushing inside that callback. If the queue *is* empty,
// then it will exit immediately. Posting the callback at the start of the
// frame ensures it's fired within the earliest possible frame. If we
// waited until the end of the frame to post the callback, we risk the
// browser skipping a frame and not firing the callback until the frame
// after that.
var currentTime = exports.unstable_now();
var didTimeout = false;
if (frameDeadline - currentTime <= 0) {
// There's no time left in this idle period. Check if the callback has
// a timeout and whether it's been exceeded.
if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
// Exceeded the timeout. Invoke the callback even though there's no
// time left.
didTimeout = true;
} else {
// No timeout.
if (!isAnimationFrameScheduled) {
// Schedule another animation callback so we retry later.
isAnimationFrameScheduled = true;
requestAnimationFrameWithTimeout(animationTick);
isRAFLoopRunning = true;
requestAnimationFrame(function (nextRAFTime) {
_clearTimeout(rAFTimeoutID);
onAnimationFrame(nextRAFTime);
}); // requestAnimationFrame is throttled when the tab is backgrounded. We
// don't want to stop working entirely. So we'll fallback to a timeout loop.
// TODO: Need a better heuristic for backgrounded work.
var onTimeout = function () {
frameDeadline = exports.unstable_now() + frameLength / 2;
performWorkUntilDeadline();
rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
};
rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
if (prevRAFTime !== -1 && // Make sure this rAF time is different from the previous one. This check
// could fail if two rAFs fire in the same frame.
rAFTime - prevRAFTime > 0.1) {
var rAFInterval = rAFTime - prevRAFTime;
if (!fpsLocked && prevRAFInterval !== -1) {
// We've observed two consecutive frame intervals. We'll use this to
// dynamically adjust the frame rate.
//
// If one frame goes long, then the next one can be short to catch up.
// If two frames are short in a row, then that's an indication that we
// actually have a higher frame rate than what we're currently
// optimizing. For example, if we're running on 120hz display or 90hz VR
// display. Take the max of the two in case one of them was an anomaly
// due to missed frame deadlines.
if (rAFInterval < frameLength && prevRAFInterval < frameLength) {
frameLength = rAFInterval < prevRAFInterval ? prevRAFInterval : rAFInterval;
if (frameLength < 8.33) {
// Defensive coding. We don't support higher frame rates than 120hz.
// If the calculated frame length gets lower than 8, it is probably
// a bug.
frameLength = 8.33;
}
}
// Exit without invoking the callback.
scheduledHostCallback = prevScheduledCallback;
timeoutTime = prevTimeoutTime;
return;
}
prevRAFInterval = rAFInterval;
}
if (prevScheduledCallback !== null) {
isFlushingHostCallback = true;
try {
prevScheduledCallback(didTimeout);
} finally {
isFlushingHostCallback = false;
prevRAFTime = rAFTime;
frameDeadline = rAFTime + frameLength; // We use the postMessage trick to defer idle work until after the repaint.
port.postMessage(null);
};
requestHostCallback = function (callback) {
scheduledHostCallback = callback;
if (enableMessageLoopImplementation) {
if (!isMessageLoopRunning) {
isMessageLoopRunning = true;
port.postMessage(null);
}
} else {
if (!isRAFLoopRunning) {
// Start a rAF loop.
isRAFLoopRunning = true;
requestAnimationFrame(function (rAFTime) {
onAnimationFrame(rAFTime);
});
}
}
};
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);
requestHostTimeout = function (callback, ms) {
taskTimeoutID = _setTimeout(function () {
callback(exports.unstable_now());
}, ms);
};
cancelHostTimeout = function () {
_clearTimeout(taskTimeoutID);
taskTimeoutID = -1;
};
}
function push(heap, node) {
var index = heap.length;
heap.push(node);
siftUp(heap, node, index);
}
function peek(heap) {
var first = heap[0];
return first === undefined ? null : first;
}
function pop(heap) {
var first = heap[0];
if (first !== undefined) {
var last = heap.pop();
if (last !== first) {
heap[0] = last;
siftDown(heap, last, 0);
}
return first;
} else {
return null;
}
}
function siftUp(heap, node, i) {
var index = i;
while (true) {
var parentIndex = Math.floor((index - 1) / 2);
var parent = heap[parentIndex];
if (parent !== undefined && compare(parent, node) > 0) {
// The parent is larger. Swap positions.
heap[parentIndex] = node;
heap[index] = parent;
index = parentIndex;
} else {
// No pending work. Exit.
isAnimationFrameScheduled = false;
// The parent 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;
function siftDown(heap, node, i) {
var index = i;
var length = heap.length;
while (index < length) {
var leftIndex = (index + 1) * 2 - 1;
var left = heap[leftIndex];
var rightIndex = leftIndex + 1;
var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
if (left !== undefined && compare(left, node) < 0) {
if (right !== undefined && compare(right, left) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
heap[index] = left;
heap[leftIndex] = node;
index = leftIndex;
}
// 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 if (right !== undefined && compare(right, node) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
previousFrameTime = nextFrameTime;
// Neither child is smaller. Exit.
return;
}
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?
var NoPriority = 0;
var ImmediatePriority = 1;

@@ -294,134 +472,277 @@ var UserBlockingPriority = 2;

// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
var runIdCounter = 0;
var mainThreadIdCounter = 0;
var profilingStateSize = 4;
var sharedProfilingBuffer = enableProfiling ? // $FlowFixMe Flow doesn't know about SharedArrayBuffer
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
: null;
var profilingState = enableProfiling && sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
var PRIORITY = 0;
var CURRENT_TASK_ID = 1;
var CURRENT_RUN_ID = 2;
var QUEUE_SIZE = 3;
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
// array might include canceled tasks.
profilingState[QUEUE_SIZE] = 0;
profilingState[CURRENT_TASK_ID] = 0;
} // Bytes per element is 4
var INITIAL_EVENT_LOG_SIZE = 131072;
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
var eventLogSize = 0;
var eventLogBuffer = null;
var eventLog = null;
var eventLogIndex = 0;
var TaskStartEvent = 1;
var TaskCompleteEvent = 2;
var TaskErrorEvent = 3;
var TaskCancelEvent = 4;
var TaskRunEvent = 5;
var TaskYieldEvent = 6;
var SchedulerSuspendEvent = 7;
var SchedulerResumeEvent = 8;
function logEvent(entries) {
if (eventLog !== null) {
var offset = eventLogIndex;
eventLogIndex += entries.length;
if (eventLogIndex + 1 > eventLogSize) {
eventLogSize *= 2;
if (eventLogSize > MAX_EVENT_LOG_SIZE) {
console.error("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
stopLoggingProfilingEvents();
return;
}
var newEventLog = new Int32Array(eventLogSize * 4);
newEventLog.set(eventLog);
eventLogBuffer = newEventLog.buffer;
eventLog = newEventLog;
}
eventLog.set(entries, offset);
}
}
function startLoggingProfilingEvents() {
eventLogSize = INITIAL_EVENT_LOG_SIZE;
eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
eventLog = new Int32Array(eventLogBuffer);
eventLogIndex = 0;
}
function stopLoggingProfilingEvents() {
var buffer = eventLogBuffer;
eventLogSize = 0;
eventLogBuffer = null;
eventLog = null;
eventLogIndex = 0;
return buffer;
}
function markTaskStart(task, ms) {
if (enableProfiling) {
profilingState[QUEUE_SIZE]++;
if (eventLog !== null) {
// performance.now returns a float, representing milliseconds. When the
// event is logged, it's coerced to an int. Convert to microseconds to
// maintain extra degrees of precision.
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
}
}
}
function markTaskCompleted(task, ms) {
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
}
}
}
function markTaskCanceled(task, ms) {
if (enableProfiling) {
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskCancelEvent, ms * 1000, task.id]);
}
}
}
function markTaskErrored(task, ms) {
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskErrorEvent, ms * 1000, task.id]);
}
}
}
function markTaskRun(task, ms) {
if (enableProfiling) {
runIdCounter++;
profilingState[PRIORITY] = task.priorityLevel;
profilingState[CURRENT_TASK_ID] = task.id;
profilingState[CURRENT_RUN_ID] = runIdCounter;
if (eventLog !== null) {
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
}
}
}
function markTaskYield(task, ms) {
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[CURRENT_RUN_ID] = 0;
if (eventLog !== null) {
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
}
}
}
function markSchedulerSuspended(ms) {
if (enableProfiling) {
mainThreadIdCounter++;
if (eventLog !== null) {
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
}
}
}
function markSchedulerUnsuspended(ms) {
if (enableProfiling) {
if (eventLog !== null) {
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
}
}
}
/* 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 maxSigned31BitInt = 1073741823; // Times out immediately
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
var USER_BLOCKING_PRIORITY = 250;
var NORMAL_PRIORITY_TIMEOUT = 5000;
var LOW_PRIORITY_TIMEOUT = 10000;
// Never times out
var IDLE_PRIORITY = maxSigned31BitInt;
var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
// Callbacks are stored as a circular, doubly linked list.
var firstCallbackNode = null;
var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap
var currentHostCallbackDidTimeout = false;
// Pausing the scheduler is useful for debugging.
var taskQueue = [];
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
var isSchedulerPaused = false;
var currentTask = null;
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy.
var currentPriorityLevel = NormalPriority;
var currentEventStartTime = -1;
var currentExpirationTime = -1;
// This is set while performing work, to prevent re-entrancy.
var isPerformingWork = false;
var isHostCallbackScheduled = false;
var isHostTimeoutScheduled = 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);
if (enableProfiling) {
markTaskStart(timer, currentTime);
timer.isQueued = true;
}
} 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) {
if (enableProfiling) {
markSchedulerUnsuspended(initialTime);
} // We'll need a host callback the next time work is scheduled.
// 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 = exports.unstable_now();
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;
}
} else {
// No catch in prod codepath.
return workLoop(hasTimeRemaining, initialTime);
}
} finally {
currentTask = null;
currentPriorityLevel = previousPriorityLevel;
isPerformingWork = false;
var previous = nextAfterContinuation.previous;
previous.next = nextAfterContinuation.previous = continuationNode;
continuationNode.next = nextAfterContinuation;
continuationNode.previous = previous;
if (enableProfiling) {
var _currentTime = exports.unstable_now();
markSchedulerSuspended(_currentTime);
}

@@ -431,47 +752,56 @@ }

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 && isSchedulerPaused)) {
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 = exports.unstable_now();
if (firstCallbackNode.expirationTime <= currentTime) {
do {
flushFirstCallback();
} while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime && !(enableSchedulerDebugging && isSchedulerPaused));
continue;
var callback = currentTask.callback;
if (callback !== null) {
currentTask.callback = null;
currentPriorityLevel = currentTask.priorityLevel;
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
markTaskRun(currentTask, currentTime);
var continuationCallback = callback(didUserCallbackTimeout);
currentTime = exports.unstable_now();
if (typeof continuationCallback === 'function') {
currentTask.callback = continuationCallback;
markTaskYield(currentTask, currentTime);
} else {
if (enableProfiling) {
markTaskCompleted(currentTask, currentTime);
currentTask.isQueued = false;
}
break;
if (currentTask === peek(taskQueue)) {
pop(taskQueue);
}
}
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;
}

@@ -488,2 +818,3 @@ }

break;
default:

@@ -494,15 +825,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;
}

@@ -512,3 +836,4 @@ }

function unstable_next(eventHandler) {
var priorityLevel = void 0;
var priorityLevel;
switch (currentPriorityLevel) {

@@ -521,2 +846,3 @@ case ImmediatePriority:

break;
default:

@@ -529,15 +855,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;
}

@@ -551,15 +870,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;
}

@@ -569,73 +881,91 @@ };

function unstable_scheduleCallback(priorityLevel, callback, deprecated_options) {
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : exports.unstable_now();
function timeoutForPriorityLevel(priorityLevel) {
switch (priorityLevel) {
case ImmediatePriority:
return IMMEDIATE_PRIORITY_TIMEOUT;
var expirationTime;
if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
// FIXME: Remove this branch once we lift expiration times out of React.
expirationTime = startTime + deprecated_options.timeout;
case UserBlockingPriority:
return USER_BLOCKING_PRIORITY;
case IdlePriority:
return IDLE_PRIORITY;
case LowPriority:
return LOW_PRIORITY_TIMEOUT;
case NormalPriority:
default:
return NORMAL_PRIORITY_TIMEOUT;
}
}
function unstable_scheduleCallback(priorityLevel, callback, options) {
var currentTime = exports.unstable_now();
var startTime;
var timeout;
if (typeof options === 'object' && options !== null) {
var delay = options.delay;
if (typeof delay === 'number' && delay > 0) {
startTime = currentTime + delay;
} else {
startTime = currentTime;
}
timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
} else {
switch (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;
}
timeout = timeoutForPriorityLevel(priorityLevel);
startTime = currentTime;
}
var newNode = {
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 (enableProfiling) {
newTask.isQueued = false;
}
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);
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 (enableProfiling) {
markTaskStart(newTask, currentTime);
newTask.isQueued = true;
} // Schedule a host callback, if needed. If we're already performing work,
// wait until the next time we yield.
if (!isHostCallbackScheduled && !isPerformingWork) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
}
var previous = next.previous;
previous.next = next.previous = newNode;
newNode.next = next;
newNode.previous = previous;
}
return newNode;
return newTask;
}

@@ -649,4 +979,6 @@

isSchedulerPaused = false;
if (firstCallbackNode !== null) {
scheduleHostCallbackIfNeeded();
if (!isHostCallbackScheduled && !isPerformingWork) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
}

@@ -656,26 +988,18 @@ }

function unstable_getFirstCallbackNode() {
return firstCallbackNode;
return peek(taskQueue);
}
function unstable_cancelCallback(callbackNode) {
var next = callbackNode.next;
if (next === null) {
// Already cancelled.
return;
}
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_cancelCallback(task) {
if (enableProfiling) {
if (task.isQueued) {
var currentTime = exports.unstable_now();
markTaskCanceled(task, currentTime);
task.isQueued = false;
}
var previous = callbackNode.previous;
previous.next = next;
next.previous = previous;
}
} // Null out the callback to indicate the task has been canceled. (Can't
// remove from the queue because you can't remove arbitrary nodes from an
// array based heap, only the first one.)
callbackNode.next = callbackNode.previous = null;
task.callback = null;
}

@@ -688,5 +1012,15 @@

function unstable_shouldYield() {
return !currentHostCallbackDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
var currentTime = exports.unstable_now();
advanceTimers(currentTime);
var firstTask = peek(taskQueue);
return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost();
}
var unstable_requestPaint = requestPaint;
var unstable_Profiling = enableProfiling ? {
startLoggingProfilingEvents: startLoggingProfilingEvents,
stopLoggingProfilingEvents: stopLoggingProfilingEvents,
sharedProfilingBuffer: sharedProfilingBuffer
} : null;
exports.unstable_ImmediatePriority = ImmediatePriority;

@@ -704,6 +1038,8 @@ exports.unstable_UserBlockingPriority = UserBlockingPriority;

exports.unstable_shouldYield = unstable_shouldYield;
exports.unstable_requestPaint = unstable_requestPaint;
exports.unstable_continueExecution = unstable_continueExecution;
exports.unstable_pauseExecution = unstable_pauseExecution;
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;
exports.unstable_Profiling = unstable_Profiling;
})();
}

@@ -1,2 +0,2 @@

/** @license React v0.0.0-50b50c26f
/** @license React v0.0.0-5faf377df
* scheduler.production.min.js

@@ -10,13 +10,14 @@ *

'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';Object.defineProperty(exports,"__esModule",{value:!0});var f,g,h,k,l;
if("undefined"===typeof window||"function"!==typeof MessageChannel){var p=null,q=null,t=function(){if(null!==p)try{var a=exports.unstable_now();p(!0,a);p=null}catch(b){throw setTimeout(t,0),b;}},u=Date.now();exports.unstable_now=function(){return Date.now()-u};f=function(a){null!==p?setTimeout(f,0,a):(p=a,setTimeout(t,0))};g=function(a,b){q=setTimeout(a,b)};h=function(){clearTimeout(q)};k=function(){return!1};l=exports.unstable_forceFrameRate=function(){}}else{var w=window.performance,x=window.Date,
y=window.setTimeout,z=window.clearTimeout,A=window.requestAnimationFrame,B=window.cancelAnimationFrame;"undefined"!==typeof console&&("function"!==typeof A&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),"function"!==typeof B&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"));if("object"===typeof w&&
"function"===typeof w.now)exports.unstable_now=function(){return w.now()};else{var C=x.now();exports.unstable_now=function(){return x.now()-C}}var D=!1,E=null,F=-1,G=5,H=0;k=function(){return exports.unstable_now()>=H};l=function(){};exports.unstable_forceFrameRate=function(a){0>a||125<a?console.error("forceFrameRate takes a positive int between 0 and 125, forcing framerates higher than 125 fps is not unsupported"):G=0<a?Math.floor(1E3/a):33.33};var I=new MessageChannel,J=I.port2;I.port1.onmessage=
function(){if(null!==E){var a=exports.unstable_now();H=a+G;try{E(!0,a)?J.postMessage(null):(D=!1,E=null)}catch(b){throw J.postMessage(null),b;}}else D=!1};f=function(a){E=a;D||(D=!0,J.postMessage(null))};g=function(a,b){F=y(function(){a(exports.unstable_now())},b)};h=function(){z(F);F=-1}}function K(a,b){var c=a.length;a.push(b);a:for(;;){var d=Math.floor((c-1)/2),e=a[d];if(void 0!==e&&0<L(e,b))a[d]=b,a[c]=e,c=d;else break a}}function M(a){a=a[0];return void 0===a?null:a}
function N(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],v=m+1,r=a[v];if(void 0!==n&&0>L(n,c))void 0!==r&&0>L(r,n)?(a[d]=r,a[v]=c,d=v):(a[d]=n,a[m]=c,d=m);else if(void 0!==r&&0>L(r,c))a[d]=r,a[v]=c,d=v;else break a}}return b}return null}function L(a,b){var c=a.sortIndex-b.sortIndex;return 0!==c?c:a.id-b.id}var O=[],P=[],Q=1,R=null,S=3,T=!1,U=!1,V=!1;
function W(a){for(var b=M(P);null!==b;){if(null===b.callback)N(P);else if(b.startTime<=a)N(P),b.sortIndex=b.expirationTime,K(O,b);else break;b=M(P)}}function X(a){V=!1;W(a);if(!U)if(null!==M(O))U=!0,f(Y);else{var b=M(P);null!==b&&g(X,b.startTime-a)}}
function Y(a,b){U=!1;V&&(V=!1,h());T=!0;var c=S;try{W(b);for(R=M(O);null!==R&&(!(R.expirationTime>b)||a&&!k());){var d=R.callback;if(null!==d){R.callback=null;S=R.priorityLevel;var e=d(R.expirationTime<=b);b=exports.unstable_now();"function"===typeof e?R.callback=e:R===M(O)&&N(O);W(b)}else N(O);R=M(O)}if(null!==R)var m=!0;else{var n=M(P);null!==n&&g(X,n.startTime-b);m=!1}return m}finally{R=null,S=c,T=!1}}
function Z(a){switch(a){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4;default:return 5E3}}var aa=l;exports.unstable_ImmediatePriority=1;exports.unstable_UserBlockingPriority=2;exports.unstable_NormalPriority=3;exports.unstable_IdlePriority=5;exports.unstable_LowPriority=4;exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=S;S=a;try{return b()}finally{S=c}};
exports.unstable_next=function(a){switch(S){case 1:case 2:case 3:var b=3;break;default:b=S}var c=S;S=b;try{return a()}finally{S=c}};
exports.unstable_scheduleCallback=function(a,b,c){var d=exports.unstable_now();if("object"===typeof c&&null!==c){var e=c.delay;e="number"===typeof e&&0<e?d+e:d;c="number"===typeof c.timeout?c.timeout:Z(a)}else c=Z(a),e=d;c=e+c;a={id:Q++,callback:b,priorityLevel:a,startTime:e,expirationTime:c,sortIndex:-1};e>d?(a.sortIndex=e,K(P,a),null===M(O)&&a===M(P)&&(V?h():V=!0,g(X,e-d))):(a.sortIndex=c,K(O,a),U||T||(U=!0,f(Y)));return a};exports.unstable_cancelCallback=function(a){a.callback=null};
exports.unstable_wrapCallback=function(a){var b=S;return function(){var c=S;S=b;try{return a.apply(this,arguments)}finally{S=c}}};exports.unstable_getCurrentPriorityLevel=function(){return S};exports.unstable_shouldYield=function(){var a=exports.unstable_now();W(a);var b=M(O);return b!==R&&null!==R&&null!==b&&null!==b.callback&&b.startTime<=a&&b.expirationTime<R.expirationTime||k()};exports.unstable_requestPaint=aa;exports.unstable_continueExecution=function(){U||T||(U=!0,f(Y))};
exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return M(O)};exports.unstable_Profiling=null;
{
"name": "scheduler",
"version": "0.0.0-50b50c26f",
"version": "0.0.0-5faf377df",
"description": "Cooperative scheduler for the browser environment.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -1,2 +0,2 @@

/** @license React v0.0.0-50b50c26f
/** @license React v0.0.0-5faf377df
* scheduler-unstable_mock.development.js

@@ -20,5 +20,9 @@ *

var enableProfiling = true;
var currentTime = 0;
var scheduledCallback = null;
var scheduledCallbackExpiration = -1;
var scheduledTimeout = null;
var timeoutTime = -1;
var yieldedValues = null;

@@ -28,15 +32,18 @@ var expectedNumberOfYields = -1;

var isFlushing = false;
function requestHostCallback(callback, expiration) {
var needsPaint = false;
var shouldYieldForPaint = false;
function requestHostCallback(callback) {
scheduledCallback = callback;
scheduledCallbackExpiration = expiration;
}
function cancelHostCallback() {
scheduledCallback = null;
scheduledCallbackExpiration = -1;
function requestHostTimeout(callback, ms) {
scheduledTimeout = callback;
timeoutTime = currentTime + ms;
}
function cancelHostTimeout() {
scheduledTimeout = null;
timeoutTime = -1;
}
function shouldYieldToHost() {
if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) {
if (expectedNumberOfYields !== -1 && yieldedValues !== null && yieldedValues.length >= expectedNumberOfYields || shouldYieldForPaint && needsPaint) {
// We yielded at least as many values as expected. Stop flushing.

@@ -46,36 +53,67 @@ didStop = true;

}
return false;
}
function getCurrentTime() {
return currentTime;
}
function forceFrameRate() {
// No-op
function forceFrameRate() {// No-op
}
// 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;
// Should only be used via an assertion helper that inspects the yielded values.
function unstable_flushNumberOfYields(count) {
try {
var hasMoreWork = true;
do {
hasMoreWork = cb(true, currentTime);
} while (hasMoreWork && !didStop);
if (!hasMoreWork) {
scheduledCallback = null;
}
} finally {
expectedNumberOfYields = -1;
didStop = false;
isFlushing = false;
}
}
}
function unstable_flushUntilNextPaint() {
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 (scheduledCallback !== null) {
var cb = scheduledCallback;
shouldYieldForPaint = true;
needsPaint = false;
isFlushing = true;
try {
var hasMoreWork = true;
do {
hasMoreWork = cb(true, currentTime);
} while (hasMoreWork && !didStop);
if (!hasMoreWork) {
scheduledCallback = null;
}
} finally {
shouldYieldForPaint = false;
didStop = false;
isFlushing = false;
}
} finally {
expectedNumberOfYields = -1;
didStop = false;
isFlushing = false;
}
}
function unstable_flushExpired() {

@@ -85,8 +123,12 @@ if (isFlushing) {

}
if (scheduledCallback !== null) {
var cb = scheduledCallback;
scheduledCallback = null;
isFlushing = true;
try {
cb(true);
var hasMoreWork = scheduledCallback(false, currentTime);
if (!hasMoreWork) {
scheduledCallback = null;
}
} finally {

@@ -97,26 +139,31 @@ isFlushing = false;

}
function unstable_flushWithoutYielding() {
function unstable_flushAllWithoutAsserting() {
// Returns false if no work was flushed.
if (isFlushing) {
throw new Error('Already flushing work.');
}
isFlushing = true;
try {
if (scheduledCallback === null) {
return false;
if (scheduledCallback !== null) {
var cb = scheduledCallback;
isFlushing = true;
try {
var hasMoreWork = true;
do {
hasMoreWork = cb(true, currentTime);
} while (hasMoreWork);
if (!hasMoreWork) {
scheduledCallback = null;
}
return true;
} finally {
isFlushing = false;
}
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;
} else {
return false;
}
}
function unstable_clearYields() {

@@ -126,2 +173,3 @@ if (yieldedValues === null) {

}
var values = yieldedValues;

@@ -131,8 +179,9 @@ yieldedValues = null;

}
function flushAll() {
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_flushWithoutYielding();
unstable_flushAllWithoutAsserting();
if (yieldedValues !== null) {

@@ -142,4 +191,3 @@ 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) {
function unstable_yieldValue(value) {
if (yieldedValues === null) {

@@ -151,14 +199,103 @@ yieldedValues = [value];

}
function unstable_advanceTime(ms) {
currentTime += ms;
function advanceTime(ms) {
currentTime += ms;
// If the host callback timed out, flush the expired work.
if (!isFlushing && scheduledCallbackExpiration !== -1 && scheduledCallbackExpiration <= currentTime) {
if (!isFlushing) {
if (scheduledTimeout !== null && timeoutTime <= currentTime) {
scheduledTimeout(currentTime);
timeoutTime = -1;
scheduledTimeout = null;
}
unstable_flushExpired();
}
}
function requestPaint() {
needsPaint = true;
}
/* eslint-disable no-var */
function push(heap, node) {
var index = heap.length;
heap.push(node);
siftUp(heap, node, index);
}
function peek(heap) {
var first = heap[0];
return first === undefined ? null : first;
}
function pop(heap) {
var first = heap[0];
if (first !== undefined) {
var last = heap.pop();
if (last !== first) {
heap[0] = last;
siftDown(heap, last, 0);
}
return first;
} else {
return null;
}
}
function siftUp(heap, node, i) {
var index = i;
while (true) {
var parentIndex = Math.floor((index - 1) / 2);
var parent = heap[parentIndex];
if (parent !== undefined && compare(parent, node) > 0) {
// The parent is larger. Swap positions.
heap[parentIndex] = node;
heap[index] = parent;
index = parentIndex;
} else {
// The parent is smaller. Exit.
return;
}
}
}
function siftDown(heap, node, i) {
var index = i;
var length = heap.length;
while (index < length) {
var leftIndex = (index + 1) * 2 - 1;
var left = heap[leftIndex];
var rightIndex = leftIndex + 1;
var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
if (left !== undefined && compare(left, node) < 0) {
if (right !== undefined && compare(right, left) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
heap[index] = left;
heap[leftIndex] = node;
index = leftIndex;
}
} else if (right !== undefined && compare(right, node) < 0) {
heap[index] = right;
heap[rightIndex] = node;
index = rightIndex;
} else {
// Neither child is smaller. Exit.
return;
}
}
}
function compare(a, b) {
// Compare sort index first, then task id.
var diff = a.sortIndex - b.sortIndex;
return diff !== 0 ? diff : a.id - b.id;
}
// TODO: Use symbols?
var NoPriority = 0;
var ImmediatePriority = 1;

@@ -170,134 +307,277 @@ var UserBlockingPriority = 2;

// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
var runIdCounter = 0;
var mainThreadIdCounter = 0;
var profilingStateSize = 4;
var sharedProfilingBuffer = enableProfiling ? // $FlowFixMe Flow doesn't know about SharedArrayBuffer
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
: null;
var profilingState = enableProfiling && sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
var PRIORITY = 0;
var CURRENT_TASK_ID = 1;
var CURRENT_RUN_ID = 2;
var QUEUE_SIZE = 3;
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
// array might include canceled tasks.
profilingState[QUEUE_SIZE] = 0;
profilingState[CURRENT_TASK_ID] = 0;
} // Bytes per element is 4
var INITIAL_EVENT_LOG_SIZE = 131072;
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
var eventLogSize = 0;
var eventLogBuffer = null;
var eventLog = null;
var eventLogIndex = 0;
var TaskStartEvent = 1;
var TaskCompleteEvent = 2;
var TaskErrorEvent = 3;
var TaskCancelEvent = 4;
var TaskRunEvent = 5;
var TaskYieldEvent = 6;
var SchedulerSuspendEvent = 7;
var SchedulerResumeEvent = 8;
function logEvent(entries) {
if (eventLog !== null) {
var offset = eventLogIndex;
eventLogIndex += entries.length;
if (eventLogIndex + 1 > eventLogSize) {
eventLogSize *= 2;
if (eventLogSize > MAX_EVENT_LOG_SIZE) {
console.error("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
stopLoggingProfilingEvents();
return;
}
var newEventLog = new Int32Array(eventLogSize * 4);
newEventLog.set(eventLog);
eventLogBuffer = newEventLog.buffer;
eventLog = newEventLog;
}
eventLog.set(entries, offset);
}
}
function startLoggingProfilingEvents() {
eventLogSize = INITIAL_EVENT_LOG_SIZE;
eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
eventLog = new Int32Array(eventLogBuffer);
eventLogIndex = 0;
}
function stopLoggingProfilingEvents() {
var buffer = eventLogBuffer;
eventLogSize = 0;
eventLogBuffer = null;
eventLog = null;
eventLogIndex = 0;
return buffer;
}
function markTaskStart(task, ms) {
if (enableProfiling) {
profilingState[QUEUE_SIZE]++;
if (eventLog !== null) {
// performance.now returns a float, representing milliseconds. When the
// event is logged, it's coerced to an int. Convert to microseconds to
// maintain extra degrees of precision.
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
}
}
}
function markTaskCompleted(task, ms) {
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
}
}
}
function markTaskCanceled(task, ms) {
if (enableProfiling) {
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskCancelEvent, ms * 1000, task.id]);
}
}
}
function markTaskErrored(task, ms) {
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[QUEUE_SIZE]--;
if (eventLog !== null) {
logEvent([TaskErrorEvent, ms * 1000, task.id]);
}
}
}
function markTaskRun(task, ms) {
if (enableProfiling) {
runIdCounter++;
profilingState[PRIORITY] = task.priorityLevel;
profilingState[CURRENT_TASK_ID] = task.id;
profilingState[CURRENT_RUN_ID] = runIdCounter;
if (eventLog !== null) {
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
}
}
}
function markTaskYield(task, ms) {
if (enableProfiling) {
profilingState[PRIORITY] = NoPriority;
profilingState[CURRENT_TASK_ID] = 0;
profilingState[CURRENT_RUN_ID] = 0;
if (eventLog !== null) {
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
}
}
}
function markSchedulerSuspended(ms) {
if (enableProfiling) {
mainThreadIdCounter++;
if (eventLog !== null) {
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
}
}
}
function markSchedulerUnsuspended(ms) {
if (enableProfiling) {
if (eventLog !== null) {
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
}
}
}
/* 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 maxSigned31BitInt = 1073741823; // Times out immediately
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
var USER_BLOCKING_PRIORITY = 250;
var NORMAL_PRIORITY_TIMEOUT = 5000;
var LOW_PRIORITY_TIMEOUT = 10000;
// Never times out
var IDLE_PRIORITY = maxSigned31BitInt;
var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
// Callbacks are stored as a circular, doubly linked list.
var firstCallbackNode = null;
var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap
var currentHostCallbackDidTimeout = false;
// Pausing the scheduler is useful for debugging.
var taskQueue = [];
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
var isSchedulerPaused = false;
var currentTask = null;
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy.
var currentPriorityLevel = NormalPriority;
var currentEventStartTime = -1;
var currentExpirationTime = -1;
// This is set while performing work, to prevent re-entrancy.
var isPerformingWork = false;
var isHostCallbackScheduled = false;
var isHostTimeoutScheduled = 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);
if (enableProfiling) {
markTaskStart(timer, currentTime);
timer.isQueued = true;
}
} 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) {
if (enableProfiling) {
markSchedulerUnsuspended(initialTime);
} // We'll need a host callback the next time work is scheduled.
// 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;
}
} else {
// No catch in prod codepath.
return workLoop(hasTimeRemaining, initialTime);
}
} finally {
currentTask = null;
currentPriorityLevel = previousPriorityLevel;
isPerformingWork = false;
var previous = nextAfterContinuation.previous;
previous.next = nextAfterContinuation.previous = continuationNode;
continuationNode.next = nextAfterContinuation;
continuationNode.previous = previous;
if (enableProfiling) {
var _currentTime = getCurrentTime();
markSchedulerSuspended(_currentTime);
}

@@ -307,47 +587,56 @@ }

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 && isSchedulerPaused)) {
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 (callback !== null) {
currentTask.callback = null;
currentPriorityLevel = currentTask.priorityLevel;
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
markTaskRun(currentTask, currentTime);
var continuationCallback = callback(didUserCallbackTimeout);
currentTime = getCurrentTime();
if (typeof continuationCallback === 'function') {
currentTask.callback = continuationCallback;
markTaskYield(currentTask, currentTime);
} else {
if (enableProfiling) {
markTaskCompleted(currentTask, currentTime);
currentTask.isQueued = false;
}
break;
if (currentTask === peek(taskQueue)) {
pop(taskQueue);
}
}
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;
}

@@ -364,2 +653,3 @@ }

break;
default:

@@ -370,15 +660,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;
}

@@ -388,3 +671,4 @@ }

function unstable_next(eventHandler) {
var priorityLevel = void 0;
var priorityLevel;
switch (currentPriorityLevel) {

@@ -397,2 +681,3 @@ case ImmediatePriority:

break;
default:

@@ -405,15 +690,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;
}

@@ -427,15 +705,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;
}

@@ -445,73 +716,91 @@ };

function unstable_scheduleCallback(priorityLevel, callback, deprecated_options) {
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
function timeoutForPriorityLevel(priorityLevel) {
switch (priorityLevel) {
case ImmediatePriority:
return IMMEDIATE_PRIORITY_TIMEOUT;
var expirationTime;
if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
// FIXME: Remove this branch once we lift expiration times out of React.
expirationTime = startTime + deprecated_options.timeout;
case UserBlockingPriority:
return USER_BLOCKING_PRIORITY;
case IdlePriority:
return IDLE_PRIORITY;
case LowPriority:
return LOW_PRIORITY_TIMEOUT;
case NormalPriority:
default:
return NORMAL_PRIORITY_TIMEOUT;
}
}
function unstable_scheduleCallback(priorityLevel, callback, options) {
var currentTime = getCurrentTime();
var startTime;
var timeout;
if (typeof options === 'object' && options !== null) {
var delay = options.delay;
if (typeof delay === 'number' && delay > 0) {
startTime = currentTime + delay;
} else {
startTime = currentTime;
}
timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
} else {
switch (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;
}
timeout = timeoutForPriorityLevel(priorityLevel);
startTime = currentTime;
}
var newNode = {
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 (enableProfiling) {
newTask.isQueued = false;
}
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);
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 (enableProfiling) {
markTaskStart(newTask, currentTime);
newTask.isQueued = true;
} // Schedule a host callback, if needed. If we're already performing work,
// wait until the next time we yield.
if (!isHostCallbackScheduled && !isPerformingWork) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
}
var previous = next.previous;
previous.next = next.previous = newNode;
newNode.next = next;
newNode.previous = previous;
}
return newNode;
return newTask;
}

@@ -525,4 +814,6 @@

isSchedulerPaused = false;
if (firstCallbackNode !== null) {
scheduleHostCallbackIfNeeded();
if (!isHostCallbackScheduled && !isPerformingWork) {
isHostCallbackScheduled = true;
requestHostCallback(flushWork);
}

@@ -532,26 +823,18 @@ }

function unstable_getFirstCallbackNode() {
return firstCallbackNode;
return peek(taskQueue);
}
function unstable_cancelCallback(callbackNode) {
var next = callbackNode.next;
if (next === null) {
// Already cancelled.
return;
}
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_cancelCallback(task) {
if (enableProfiling) {
if (task.isQueued) {
var currentTime = getCurrentTime();
markTaskCanceled(task, currentTime);
task.isQueued = false;
}
var previous = callbackNode.previous;
previous.next = next;
next.previous = previous;
}
} // Null out the callback to indicate the task has been canceled. (Can't
// remove from the queue because you can't remove arbitrary nodes from an
// array based heap, only the first one.)
callbackNode.next = callbackNode.previous = null;
task.callback = null;
}

@@ -564,12 +847,23 @@

function unstable_shouldYield() {
return !currentHostCallbackDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
var currentTime = getCurrentTime();
advanceTimers(currentTime);
var firstTask = peek(taskQueue);
return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost();
}
exports.unstable_flushWithoutYielding = unstable_flushWithoutYielding;
var unstable_requestPaint = requestPaint;
var unstable_Profiling = enableProfiling ? {
startLoggingProfilingEvents: startLoggingProfilingEvents,
stopLoggingProfilingEvents: stopLoggingProfilingEvents,
sharedProfilingBuffer: sharedProfilingBuffer
} : null;
exports.unstable_flushAllWithoutAsserting = unstable_flushAllWithoutAsserting;
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_flushUntilNextPaint = unstable_flushUntilNextPaint;
exports.unstable_flushAll = unstable_flushAll;
exports.unstable_yieldValue = unstable_yieldValue;
exports.unstable_advanceTime = unstable_advanceTime;
exports.unstable_ImmediatePriority = ImmediatePriority;

@@ -587,2 +881,3 @@ exports.unstable_UserBlockingPriority = UserBlockingPriority;

exports.unstable_shouldYield = unstable_shouldYield;
exports.unstable_requestPaint = unstable_requestPaint;
exports.unstable_continueExecution = unstable_continueExecution;

@@ -593,2 +888,3 @@ exports.unstable_pauseExecution = unstable_pauseExecution;

exports.unstable_forceFrameRate = forceFrameRate;
exports.unstable_Profiling = unstable_Profiling;

@@ -595,0 +891,0 @@ Object.defineProperty(exports, '__esModule', { value: true });

@@ -1,2 +0,2 @@

/** @license React v0.0.0-50b50c26f
/** @license React v0.0.0-5faf377df
* scheduler-unstable_mock.production.min.js

@@ -9,9 +9,10 @@ *

*/
'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})});
'use strict';(function(b,w){"object"===typeof exports&&"undefined"!==typeof module?w(exports):"function"===typeof define&&define.amd?define(["exports"],w):w(b.SchedulerMock={})})(this,function(b){function w(){return-1!==y&&null!==k&&k.length>=y||D&&E?t=!0:!1}function J(){if(h)throw Error("Already flushing work.");if(null!==f){h=!0;try{f(!1,g)||(f=null)}finally{h=!1}}}function K(){if(h)throw Error("Already flushing work.");if(null!==f){var a=f;h=!0;try{var c=!0;do c=a(!0,g);while(c);c||(f=null);return!0}finally{h=
!1}}else return!1}function F(a,c){var G=a.length;a.push(c);a:for(;;){var b=Math.floor((G-1)/2),p=a[b];if(void 0!==p&&0<z(p,c))a[b]=c,a[G]=p,G=b;else break a}}function l(a){a=a[0];return void 0===a?null:a}function A(a){var c=a[0];if(void 0!==c){var b=a.pop();if(b!==c){a[0]=b;a:for(var n=0,p=a.length;n<p;){var e=2*(n+1)-1,f=a[e],d=e+1,g=a[d];if(void 0!==f&&0>z(f,b))void 0!==g&&0>z(g,f)?(a[n]=g,a[d]=b,n=d):(a[n]=f,a[e]=b,n=e);else if(void 0!==g&&0>z(g,b))a[n]=g,a[d]=b,n=d;else break a}}return c}return null}
function z(a,c){var b=a.sortIndex-c.sortIndex;return 0!==b?b:a.id-c.id}function B(a){for(var c=l(q);null!==c;){if(null===c.callback)A(q);else if(c.startTime<=a)A(q),c.sortIndex=c.expirationTime,F(m,c);else break;c=l(q)}}function H(a){x=!1;B(a);if(!u)if(null!==l(m))u=!0,f=I;else{var c=l(q);null!==c&&(a=c.startTime-a,r=H,v=g+a)}}function I(a,c){u=!1;x&&(x=!1,r=null,v=-1);C=!0;var b=e;try{B(c);for(d=l(m);null!==d&&(!(d.expirationTime>c)||a&&!w());){var f=d.callback;if(null!==f){d.callback=null;e=d.priorityLevel;
var p=f(d.expirationTime<=c);c=g;"function"===typeof p?d.callback=p:d===l(m)&&A(m);B(c)}else A(m);d=l(m)}if(null!==d)var h=!0;else{var k=l(q);if(null!==k){var t=k.startTime-c;r=H;v=g+t}h=!1}return h}finally{d=null,e=b,C=!1}}function L(a){switch(a){case 1:return-1;case 2:return 250;case 5:return 1073741823;case 4:return 1E4;default:return 5E3}}var g=0,f=null,r=null,v=-1,k=null,y=-1,t=!1,h=!1,E=!1,D=!1,m=[],q=[],M=1,d=null,e=3,C=!1,u=!1,x=!1;b.unstable_flushAllWithoutAsserting=K;b.unstable_flushNumberOfYields=
function(a){if(h)throw Error("Already flushing work.");if(null!==f){var c=f;y=a;h=!0;try{a=!0;do a=c(!0,g);while(a&&!t);a||(f=null)}finally{y=-1,h=t=!1}}};b.unstable_flushExpired=J;b.unstable_clearYields=function(){if(null===k)return[];var a=k;k=null;return a};b.unstable_flushUntilNextPaint=function(){if(h)throw Error("Already flushing work.");if(null!==f){var a=f;D=!0;E=!1;h=!0;try{var c=!0;do c=a(!0,g);while(c&&!t);c||(f=null)}finally{h=t=D=!1}}};b.unstable_flushAll=function(){if(null!==k)throw Error("Log is not empty. Assert on the log of yielded values before flushing additional work.");
K();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([...])");};b.unstable_yieldValue=function(a){null===k?k=[a]:k.push(a)};b.unstable_advanceTime=function(a){g+=a;h||(null!==r&&v<=g&&(r(g),v=-1,r=null),J())};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 b=e;e=a;try{return c()}finally{e=b}};b.unstable_next=function(a){switch(e){case 1:case 2:case 3:var c=3;break;default:c=e}var b=e;e=c;try{return a()}finally{e=b}};b.unstable_scheduleCallback=function(a,c,b){var e=g;if("object"===typeof b&&null!==b){var d=b.delay;d="number"===typeof d&&0<d?e+d:e;b="number"===typeof b.timeout?b.timeout:L(a)}else b=L(a),d=e;b=d+b;a={id:M++,callback:c,priorityLevel:a,startTime:d,expirationTime:b,
sortIndex:-1};d>e?(a.sortIndex=d,F(q,a),null===l(m)&&a===l(q)&&(x?(r=null,v=-1):x=!0,r=H,v=g+(d-e))):(a.sortIndex=b,F(m,a),u||C||(u=!0,f=I));return a};b.unstable_cancelCallback=function(a){a.callback=null};b.unstable_wrapCallback=function(a){var b=e;return function(){var c=e;e=b;try{return a.apply(this,arguments)}finally{e=c}}};b.unstable_getCurrentPriorityLevel=function(){return e};b.unstable_shouldYield=function(){var a=g;B(a);var b=l(m);return b!==d&&null!==d&&null!==b&&null!==b.callback&&b.startTime<=
a&&b.expirationTime<d.expirationTime||w()};b.unstable_requestPaint=function(){E=!0};b.unstable_continueExecution=function(){u||C||(u=!0,f=I)};b.unstable_pauseExecution=function(){};b.unstable_getFirstCallbackNode=function(){return l(m)};b.unstable_now=function(){return g};b.unstable_forceFrameRate=function(){};b.unstable_Profiling=null;Object.defineProperty(b,"__esModule",{value:!0})});

@@ -50,2 +50,9 @@ /**

function unstable_requestPaint() {
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_requestPaint.apply(
this,
arguments
);
}
function unstable_runWithPriority() {

@@ -112,2 +119,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,

@@ -141,3 +149,7 @@ unstable_next: unstable_next,

},
get unstable_Profiling() {
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
.Scheduler.unstable_Profiling;
},
});
});

@@ -50,2 +50,9 @@ /**

function unstable_requestPaint() {
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_requestPaint.apply(
this,
arguments
);
}
function unstable_runWithPriority() {

@@ -106,2 +113,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,

@@ -135,3 +143,7 @@ unstable_next: unstable_next,

},
get unstable_Profiling() {
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
.Scheduler.unstable_Profiling;
},
});
});

@@ -50,2 +50,9 @@ /**

function unstable_requestPaint() {
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_requestPaint.apply(
this,
arguments
);
}
function unstable_runWithPriority() {

@@ -106,2 +113,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,

@@ -135,3 +143,7 @@ unstable_next: unstable_next,

},
get unstable_Profiling() {
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED
.Scheduler.unstable_Profiling;
},
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc