Socket
Socket
Sign inDemoInstall

scheduler

Package Overview
Dependencies
Maintainers
8
Versions
1872
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.13.6 to 0.14.0-alpha.0

cjs/scheduler-unstable_mock.development.js

10

build-info.json
{
"branch": "pull/15226",
"buildNumber": "14079",
"checksum": "4a4c239",
"commit": "297165f1e",
"branch": "pull/15307",
"buildNumber": "14231",
"checksum": "0f531f7",
"commit": "c35e37aab",
"environment": "ci",
"reactVersion": "16.8.5-canary-297165f1e"
"reactVersion": "16.8.6-canary-c35e37aab"
}

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

/** @license React v0.13.6
/** @license React v0.14.0-alpha.0
* scheduler-tracing.development.js

@@ -51,2 +51,8 @@ *

// 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

@@ -59,2 +65,15 @@ // with their related DOM properties

// See https://github.com/react-native-community/discussions-and-proposals/issues/72 for more information
// This is a flag so we can fix warnings in RN core before turning it on
// Experimental React Events support. Only used in www builds for now.
// Enables rewritten version of ReactFiberScheduler. Added in case we need to
// quickly revert it.
var DEFAULT_THREAD_ID = 0;

@@ -61,0 +80,0 @@

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

/** @license React v0.13.6
/** @license React v0.14.0-alpha.0
* scheduler-tracing.production.min.js

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

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

/** @license React v0.13.6
/** @license React v0.14.0-alpha.0
* scheduler-tracing.profiling.min.js

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

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

/** @license React v0.13.6
/** @license React v0.14.0-alpha.0
* scheduler.development.js

@@ -22,2 +22,240 @@ *

// The DOM Scheduler implementation is similar to requestIdleCallback. It
// works by scheduling a requestAnimationFrame, storing the time for the start
// of the frame, then scheduling a postMessage which gets scheduled after paint.
// Within the postMessage handler do as much work as possible until time + frame
// rate. By separating the idle call into a separate event tick we ensure that
// layout, paint and other browser work is counted against the available time.
// The frame rate is dynamically adjusted.
var requestHostCallback = void 0;
var cancelHostCallback = void 0;
var shouldYieldToHost = void 0;
exports.unstable_now = void 0;
var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
// 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
// implementation using setTimeout.
typeof window === 'undefined' ||
// Check if MessageChannel is supported, too.
typeof MessageChannel !== 'function') {
// If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
// fallback to a naive implementation.
var _callback = null;
var _flushCallback = function (didTimeout) {
if (_callback !== null) {
try {
_callback(didTimeout);
} finally {
_callback = null;
}
}
};
requestHostCallback = function (cb, ms) {
if (_callback !== null) {
// Protect against re-entrancy.
setTimeout(requestHostCallback, 0, cb);
} else {
_callback = cb;
setTimeout(_flushCallback, 0, false);
}
};
cancelHostCallback = function () {
_callback = null;
};
shouldYieldToHost = function () {
return false;
};
} else {
if (typeof console !== 'undefined') {
// TODO: Remove fb.me link
if (typeof localRequestAnimationFrame !== 'function') {
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
}
if (typeof localCancelAnimationFrame !== 'function') {
console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
}
}
var scheduledHostCallback = null;
var isMessageEventScheduled = false;
var timeoutTime = -1;
var isAnimationFrameScheduled = false;
var isFlushingHostCallback = false;
var frameDeadline = 0;
// We start out assuming that we run at 30fps but then the heuristic tracking
// will adjust this value to a faster fps if we get more frequent animation
// frames.
var previousFrameTime = 33;
var activeFrameTime = 33;
shouldYieldToHost = function () {
return frameDeadline <= exports.unstable_now();
};
// We use the postMessage trick to defer idle work until after the repaint.
var channel = new MessageChannel();
var port = channel.port2;
channel.port1.onmessage = function (event) {
isMessageEventScheduled = false;
var prevScheduledCallback = scheduledHostCallback;
var prevTimeoutTime = timeoutTime;
scheduledHostCallback = null;
timeoutTime = -1;
var currentTime = exports.unstable_now();
var didTimeout = false;
if (frameDeadline - currentTime <= 0) {
// There's no time left in this idle period. Check if the callback has
// a timeout and whether it's been exceeded.
if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
// Exceeded the timeout. Invoke the callback even though there's no
// time left.
didTimeout = true;
} else {
// No timeout.
if (!isAnimationFrameScheduled) {
// Schedule another animation callback so we retry later.
isAnimationFrameScheduled = true;
requestAnimationFrameWithTimeout(animationTick);
}
// Exit without invoking the callback.
scheduledHostCallback = prevScheduledCallback;
timeoutTime = prevTimeoutTime;
return;
}
}
if (prevScheduledCallback !== null) {
isFlushingHostCallback = true;
try {
prevScheduledCallback(didTimeout);
} finally {
isFlushingHostCallback = false;
}
}
};
var animationTick = function (rafTime) {
if (scheduledHostCallback !== null) {
// Eagerly schedule the next animation callback at the beginning of the
// frame. If the scheduler queue is not empty at the end of the frame, it
// will continue flushing inside that callback. If the queue *is* empty,
// then it will exit immediately. Posting the callback at the start of the
// frame ensures it's fired within the earliest possible frame. If we
// waited until the end of the frame to post the callback, we risk the
// browser skipping a frame and not firing the callback until the frame
// after that.
requestAnimationFrameWithTimeout(animationTick);
} else {
// No pending work. Exit.
isAnimationFrameScheduled = false;
return;
}
var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
if (nextFrameTime < 8) {
// Defensive coding. We don't support higher frame rates than 120hz.
// If the calculated frame time gets lower than 8, it is probably a bug.
nextFrameTime = 8;
}
// If one frame goes long, then the next one can be short to catch up.
// If two frames are short in a row, then that's an indication that we
// actually have a higher frame rate than what we're currently optimizing.
// We adjust our heuristic dynamically accordingly. For example, if we're
// running on 120hz display or 90hz VR display.
// Take the max of the two in case one of them was an anomaly due to
// missed frame deadlines.
activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
} else {
previousFrameTime = nextFrameTime;
}
frameDeadline = rafTime + activeFrameTime;
if (!isMessageEventScheduled) {
isMessageEventScheduled = true;
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;
};
}
/* eslint-disable no-var */

@@ -49,3 +287,3 @@

var currentDidTimeout = false;
var currentHostCallbackDidTimeout = false;
// Pausing the scheduler is useful for debugging.

@@ -58,27 +296,27 @@ var isSchedulerPaused = false;

// This is set when a callback is being executed, to prevent re-entrancy.
var isExecutingCallback = false;
// This is set while performing work, to prevent re-entrancy.
var isPerformingWork = false;
var isHostCallbackScheduled = false;
var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
function ensureHostCallbackIsScheduled() {
if (isExecutingCallback) {
function scheduleHostCallbackIfNeeded() {
if (isPerformingWork) {
// Don't schedule work yet; wait until the next time we yield.
return;
}
// Schedule the host callback using the earliest expiration in the list.
var expirationTime = firstCallbackNode.expirationTime;
if (!isHostCallbackScheduled) {
isHostCallbackScheduled = true;
} else {
// Cancel the existing host callback.
cancelHostCallback();
if (firstCallbackNode !== null) {
// Schedule the host callback using the earliest expiration in the list.
var expirationTime = firstCallbackNode.expirationTime;
if (isHostCallbackScheduled) {
// Cancel the existing host callback.
cancelHostCallback();
} else {
isHostCallbackScheduled = true;
}
requestHostCallback(flushWork, expirationTime);
}
requestHostCallback(flushWork, expirationTime);
}
function flushFirstCallback() {
var flushedNode = firstCallbackNode;
var currentlyFlushingCallback = firstCallbackNode;

@@ -98,8 +336,8 @@ // Remove the node from the list before calling the callback. That way the

flushedNode.next = flushedNode.previous = null;
currentlyFlushingCallback.next = currentlyFlushingCallback.previous = null;
// Now it's safe to call the callback.
var callback = flushedNode.callback;
var expirationTime = flushedNode.expirationTime;
var priorityLevel = flushedNode.priorityLevel;
var callback = currentlyFlushingCallback.callback;
var expirationTime = currentlyFlushingCallback.expirationTime;
var priorityLevel = currentlyFlushingCallback.priorityLevel;
var previousPriorityLevel = currentPriorityLevel;

@@ -111,3 +349,8 @@ var previousExpirationTime = currentExpirationTime;

try {
continuationCallback = callback();
var didUserCallbackTimeout = currentHostCallbackDidTimeout ||
// Immediate priority callbacks are always called as if they timed out
priorityLevel === ImmediatePriority;
continuationCallback = callback(didUserCallbackTimeout);
} catch (error) {
throw error;
} finally {

@@ -156,3 +399,3 @@ currentPriorityLevel = previousPriorityLevel;

firstCallbackNode = continuationNode;
ensureHostCallbackIsScheduled();
scheduleHostCallbackIfNeeded();
}

@@ -168,28 +411,4 @@

function flushImmediateWork() {
if (
// Confirm we've exited the outer most event handler
currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) {
isExecutingCallback = true;
try {
do {
flushFirstCallback();
} while (
// Keep flushing until there are no more immediate callbacks
firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority);
} finally {
isExecutingCallback = false;
if (firstCallbackNode !== null) {
// There's still work remaining. Request another callback.
ensureHostCallbackIsScheduled();
} else {
isHostCallbackScheduled = false;
}
}
}
}
function flushWork(didTimeout) {
function flushWork(didUserCallbackTimeout) {
// Exit right away if we're currently paused
if (enableSchedulerDebugging && isSchedulerPaused) {

@@ -199,7 +418,10 @@ return;

isExecutingCallback = true;
var previousDidTimeout = currentDidTimeout;
currentDidTimeout = didTimeout;
// We'll need a new host callback the next time work is scheduled.
isHostCallbackScheduled = false;
isPerformingWork = true;
var previousDidTimeout = currentHostCallbackDidTimeout;
currentHostCallbackDidTimeout = didUserCallbackTimeout;
try {
if (didTimeout) {
if (didUserCallbackTimeout) {
// Flush all the expired callbacks without yielding.

@@ -232,12 +454,6 @@ while (firstCallbackNode !== null && !(enableSchedulerDebugging && isSchedulerPaused)) {

} finally {
isExecutingCallback = false;
currentDidTimeout = previousDidTimeout;
if (firstCallbackNode !== null) {
// There's still work remaining. Request another callback.
ensureHostCallbackIsScheduled();
} else {
isHostCallbackScheduled = false;
}
// Before exiting, flush all the immediate work that was scheduled.
flushImmediateWork();
isPerformingWork = false;
currentHostCallbackDidTimeout = previousDidTimeout;
// There's still work remaining. Request another callback.
scheduleHostCallbackIfNeeded();
}

@@ -265,8 +481,9 @@ }

return eventHandler();
} catch (error) {
// There's still work remaining. Request another callback.
scheduleHostCallbackIfNeeded();
throw error;
} finally {
currentPriorityLevel = previousPriorityLevel;
currentEventStartTime = previousEventStartTime;
// Before exiting, flush all the immediate work that was scheduled.
flushImmediateWork();
}

@@ -297,8 +514,9 @@ }

return eventHandler();
} catch (error) {
// There's still work remaining. Request another callback.
scheduleHostCallbackIfNeeded();
throw error;
} finally {
currentPriorityLevel = previousPriorityLevel;
currentEventStartTime = previousEventStartTime;
// Before exiting, flush all the immediate work that was scheduled.
flushImmediateWork();
}

@@ -318,6 +536,9 @@ }

return callback.apply(this, arguments);
} catch (error) {
// There's still work remaining. Request another callback.
scheduleHostCallbackIfNeeded();
throw error;
} finally {
currentPriorityLevel = previousPriorityLevel;
currentEventStartTime = previousEventStartTime;
flushImmediateWork();
}

@@ -327,3 +548,3 @@ };

function unstable_scheduleCallback(callback, deprecated_options) {
function unstable_scheduleCallback(priorityLevel, callback, deprecated_options) {
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : exports.unstable_now();

@@ -336,3 +557,3 @@

} else {
switch (currentPriorityLevel) {
switch (priorityLevel) {
case ImmediatePriority:

@@ -358,3 +579,3 @@ expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;

callback: callback,
priorityLevel: currentPriorityLevel,
priorityLevel: priorityLevel,
expirationTime: expirationTime,

@@ -371,3 +592,3 @@ next: null,

firstCallbackNode = newNode.next = newNode.previous = newNode;
ensureHostCallbackIsScheduled();
scheduleHostCallbackIfNeeded();
} else {

@@ -392,3 +613,3 @@ var next = null;

firstCallbackNode = newNode;
ensureHostCallbackIsScheduled();
scheduleHostCallbackIfNeeded();
}

@@ -412,3 +633,3 @@

if (firstCallbackNode !== null) {
ensureHostCallbackIsScheduled();
scheduleHostCallbackIfNeeded();
}

@@ -449,254 +670,5 @@ }

function unstable_shouldYield() {
return !currentDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
return !currentHostCallbackDidTimeout && (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime || shouldYieldToHost());
}
// The remaining code is essentially a polyfill for requestIdleCallback. It
// works by scheduling a requestAnimationFrame, storing the time for the start
// of the frame, then scheduling a postMessage which gets scheduled after paint.
// Within the postMessage handler do as much work as possible until time + frame
// rate. By separating the idle call into a separate event tick we ensure that
// layout, paint and other browser work is counted against the available time.
// The frame rate is dynamically adjusted.
// We capture a local reference to any global, in case it gets polyfilled after
// this module is initially evaluated. We want to be using a
// consistent implementation.
var localDate = Date;
// This initialization code may run even on server environments if a component
// just imports ReactDOM (e.g. for findDOMNode). Some environments might not
// have setTimeout or clearTimeout. However, we always expect them to be defined
// on the client. https://github.com/facebook/react/pull/13088
var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
// We don't expect either of these to necessarily be defined, but we will error
// later if they are missing on the client.
var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
// requestAnimationFrame does not run when the tab is in the background. If
// we're backgrounded we prefer for that work to happen so that the page
// continues to load in the background. So we also schedule a 'setTimeout' as
// a fallback.
// TODO: Need a better heuristic for backgrounded work.
var ANIMATION_FRAME_TIMEOUT = 100;
var rAFID;
var rAFTimeoutID;
var requestAnimationFrameWithTimeout = function (callback) {
// schedule rAF and also a setTimeout
rAFID = localRequestAnimationFrame(function (timestamp) {
// cancel the setTimeout
localClearTimeout(rAFTimeoutID);
callback(timestamp);
});
rAFTimeoutID = localSetTimeout(function () {
// cancel the requestAnimationFrame
localCancelAnimationFrame(rAFID);
callback(exports.unstable_now());
}, ANIMATION_FRAME_TIMEOUT);
};
if (hasNativePerformanceNow) {
var Performance = performance;
exports.unstable_now = function () {
return Performance.now();
};
} else {
exports.unstable_now = function () {
return localDate.now();
};
}
var requestHostCallback;
var cancelHostCallback;
var shouldYieldToHost;
var globalValue = null;
if (typeof window !== 'undefined') {
globalValue = window;
} else if (typeof global !== 'undefined') {
globalValue = global;
}
if (globalValue && globalValue._schedMock) {
// Dynamic injection, only for testing purposes.
var globalImpl = globalValue._schedMock;
requestHostCallback = globalImpl[0];
cancelHostCallback = globalImpl[1];
shouldYieldToHost = globalImpl[2];
exports.unstable_now = globalImpl[3];
} else if (
// If Scheduler runs in a non-DOM environment, it falls back to a naive
// implementation using setTimeout.
typeof window === 'undefined' ||
// Check if MessageChannel is supported, too.
typeof MessageChannel !== 'function') {
// If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
// fallback to a naive implementation.
var _callback = null;
var _flushCallback = function (didTimeout) {
if (_callback !== null) {
try {
_callback(didTimeout);
} finally {
_callback = null;
}
}
};
requestHostCallback = function (cb, ms) {
if (_callback !== null) {
// Protect against re-entrancy.
setTimeout(requestHostCallback, 0, cb);
} else {
_callback = cb;
setTimeout(_flushCallback, 0, false);
}
};
cancelHostCallback = function () {
_callback = null;
};
shouldYieldToHost = function () {
return false;
};
} else {
if (typeof console !== 'undefined') {
// TODO: Remove fb.me link
if (typeof localRequestAnimationFrame !== 'function') {
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
}
if (typeof localCancelAnimationFrame !== 'function') {
console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
}
}
var scheduledHostCallback = null;
var isMessageEventScheduled = false;
var timeoutTime = -1;
var isAnimationFrameScheduled = false;
var isFlushingHostCallback = false;
var frameDeadline = 0;
// We start out assuming that we run at 30fps but then the heuristic tracking
// will adjust this value to a faster fps if we get more frequent animation
// frames.
var previousFrameTime = 33;
var activeFrameTime = 33;
shouldYieldToHost = function () {
return frameDeadline <= exports.unstable_now();
};
// We use the postMessage trick to defer idle work until after the repaint.
var channel = new MessageChannel();
var port = channel.port2;
channel.port1.onmessage = function (event) {
isMessageEventScheduled = false;
var prevScheduledCallback = scheduledHostCallback;
var prevTimeoutTime = timeoutTime;
scheduledHostCallback = null;
timeoutTime = -1;
var currentTime = exports.unstable_now();
var didTimeout = false;
if (frameDeadline - currentTime <= 0) {
// There's no time left in this idle period. Check if the callback has
// a timeout and whether it's been exceeded.
if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
// Exceeded the timeout. Invoke the callback even though there's no
// time left.
didTimeout = true;
} else {
// No timeout.
if (!isAnimationFrameScheduled) {
// Schedule another animation callback so we retry later.
isAnimationFrameScheduled = true;
requestAnimationFrameWithTimeout(animationTick);
}
// Exit without invoking the callback.
scheduledHostCallback = prevScheduledCallback;
timeoutTime = prevTimeoutTime;
return;
}
}
if (prevScheduledCallback !== null) {
isFlushingHostCallback = true;
try {
prevScheduledCallback(didTimeout);
} finally {
isFlushingHostCallback = false;
}
}
};
var animationTick = function (rafTime) {
if (scheduledHostCallback !== null) {
// Eagerly schedule the next animation callback at the beginning of the
// frame. If the scheduler queue is not empty at the end of the frame, it
// will continue flushing inside that callback. If the queue *is* empty,
// then it will exit immediately. Posting the callback at the start of the
// frame ensures it's fired within the earliest possible frame. If we
// waited until the end of the frame to post the callback, we risk the
// browser skipping a frame and not firing the callback until the frame
// after that.
requestAnimationFrameWithTimeout(animationTick);
} else {
// No pending work. Exit.
isAnimationFrameScheduled = false;
return;
}
var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
if (nextFrameTime < 8) {
// Defensive coding. We don't support higher frame rates than 120hz.
// If the calculated frame time gets lower than 8, it is probably a bug.
nextFrameTime = 8;
}
// If one frame goes long, then the next one can be short to catch up.
// If two frames are short in a row, then that's an indication that we
// actually have a higher frame rate than what we're currently optimizing.
// We adjust our heuristic dynamically accordingly. For example, if we're
// running on 120hz display or 90hz VR display.
// Take the max of the two in case one of them was an anomaly due to
// missed frame deadlines.
activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
} else {
previousFrameTime = nextFrameTime;
}
frameDeadline = rafTime + activeFrameTime;
if (!isMessageEventScheduled) {
isMessageEventScheduled = true;
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;
};
}
exports.unstable_ImmediatePriority = ImmediatePriority;

@@ -703,0 +675,0 @@ exports.unstable_UserBlockingPriority = UserBlockingPriority;

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

/** @license React v0.13.6
/** @license React v0.14.0-alpha.0
* scheduler.production.min.js

@@ -10,13 +10,12 @@ *

'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var d=null,e=!1,g=3,k=-1,l=-1,m=!1,n=!1;function p(){if(!m){var a=d.expirationTime;n?q():n=!0;r(t,a)}}
function u(){var a=d,b=d.next;if(d===b)d=null;else{var c=d.previous;d=c.next=b;b.previous=c}a.next=a.previous=null;c=a.callback;b=a.expirationTime;a=a.priorityLevel;var f=g,Q=l;g=a;l=b;try{var h=c()}finally{g=f,l=Q}if("function"===typeof h)if(h={callback:h,priorityLevel:a,expirationTime:b,next:null,previous:null},null===d)d=h.next=h.previous=h;else{c=null;a=d;do{if(a.expirationTime>=b){c=a;break}a=a.next}while(a!==d);null===c?c=d:c===d&&(d=h,p());b=c.previous;b.next=c.previous=h;h.next=c;h.previous=
b}}function v(){if(-1===k&&null!==d&&1===d.priorityLevel){m=!0;try{do u();while(null!==d&&1===d.priorityLevel)}finally{m=!1,null!==d?p():n=!1}}}function t(a){m=!0;var b=e;e=a;try{if(a)for(;null!==d;){var c=exports.unstable_now();if(d.expirationTime<=c){do u();while(null!==d&&d.expirationTime<=c)}else break}else if(null!==d){do u();while(null!==d&&!w())}}finally{m=!1,e=b,null!==d?p():n=!1,v()}}
var x=Date,y="function"===typeof setTimeout?setTimeout:void 0,z="function"===typeof clearTimeout?clearTimeout:void 0,A="function"===typeof requestAnimationFrame?requestAnimationFrame:void 0,B="function"===typeof cancelAnimationFrame?cancelAnimationFrame:void 0,C,D;function E(a){C=A(function(b){z(D);a(b)});D=y(function(){B(C);a(exports.unstable_now())},100)}
if("object"===typeof performance&&"function"===typeof performance.now){var F=performance;exports.unstable_now=function(){return F.now()}}else exports.unstable_now=function(){return x.now()};var r,q,w,G=null;"undefined"!==typeof window?G=window:"undefined"!==typeof global&&(G=global);
if(G&&G._schedMock){var H=G._schedMock;r=H[0];q=H[1];w=H[2];exports.unstable_now=H[3]}else if("undefined"===typeof window||"function"!==typeof MessageChannel){var I=null,J=function(a){if(null!==I)try{I(a)}finally{I=null}};r=function(a){null!==I?setTimeout(r,0,a):(I=a,setTimeout(J,0,!1))};q=function(){I=null};w=function(){return!1}}else{"undefined"!==typeof console&&("function"!==typeof A&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),
"function"!==typeof B&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"));var K=null,L=!1,M=-1,N=!1,O=!1,P=0,R=33,S=33;w=function(){return P<=exports.unstable_now()};var T=new MessageChannel,U=T.port2;T.port1.onmessage=function(){L=!1;var a=K,b=M;K=null;M=-1;var c=exports.unstable_now(),f=!1;if(0>=P-c)if(-1!==b&&b<=c)f=!0;else{N||(N=!0,E(V));K=a;M=b;return}if(null!==a){O=!0;try{a(f)}finally{O=!1}}};
var V=function(a){if(null!==K){E(V);var b=a-P+S;b<S&&R<S?(8>b&&(b=8),S=b<R?R:b):R=b;P=a+S;L||(L=!0,U.postMessage(void 0))}else N=!1};r=function(a,b){K=a;M=b;O||0>b?U.postMessage(void 0):N||(N=!0,E(V))};q=function(){K=null;L=!1;M=-1}}exports.unstable_ImmediatePriority=1;exports.unstable_UserBlockingPriority=2;exports.unstable_NormalPriority=3;exports.unstable_IdlePriority=5;exports.unstable_LowPriority=4;
exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=g,f=k;g=a;k=exports.unstable_now();try{return b()}finally{g=c,k=f,v()}};exports.unstable_next=function(a){switch(g){case 1:case 2:case 3:var b=3;break;default:b=g}var c=g,f=k;g=b;k=exports.unstable_now();try{return a()}finally{g=c,k=f,v()}};
exports.unstable_scheduleCallback=function(a,b){var c=-1!==k?k:exports.unstable_now();if("object"===typeof b&&null!==b&&"number"===typeof b.timeout)b=c+b.timeout;else switch(g){case 1:b=c+-1;break;case 2:b=c+250;break;case 5:b=c+1073741823;break;case 4:b=c+1E4;break;default:b=c+5E3}a={callback:a,priorityLevel:g,expirationTime:b,next:null,previous:null};if(null===d)d=a.next=a.previous=a,p();else{c=null;var f=d;do{if(f.expirationTime>b){c=f;break}f=f.next}while(f!==d);null===c?c=d:c===d&&(d=a,p());
b=c.previous;b.next=c.previous=a;a.next=c;a.previous=b}return a};exports.unstable_cancelCallback=function(a){var b=a.next;if(null!==b){if(b===a)d=null;else{a===d&&(d=b);var c=a.previous;c.next=b;b.previous=c}a.next=a.previous=null}};exports.unstable_wrapCallback=function(a){var b=g;return function(){var c=g,f=k;g=b;k=exports.unstable_now();try{return a.apply(this,arguments)}finally{g=c,k=f,v()}}};exports.unstable_getCurrentPriorityLevel=function(){return g};
exports.unstable_shouldYield=function(){return!e&&(null!==d&&d.expirationTime<l||w())};exports.unstable_continueExecution=function(){null!==d&&p()};exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return d};
'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var d=void 0,f=void 0,g=void 0;exports.unstable_now=void 0;var k=Date,m="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=m(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}}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=function(){return D<=exports.unstable_now()};var G=new MessageChannel,H=G.port2;G.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(I));y=a;A=b;return}if(null!==a){C=!0;try{a(e)}finally{C=!1}}};var I=function(a){if(null!==y){u(I);var b=a-D+F;b<F&&E<F?(8>b&&(b=8),F=b<E?E:b):E=b;D=a+F;z||(z=!0,H.postMessage(void 0))}else B=!1};d=function(a,b){y=a;A=b;C||0>b?H.postMessage(void 0):
B||(B=!0,u(I))};f=function(){y=null;z=!1;A=-1}}var J=null,K=!1,L=3,M=-1,N=-1,O=!1,P=!1;function Q(){if(!O&&null!==J){var a=J.expirationTime;P?f():P=!0;d(R,a)}}
function S(){var a=J,b=J.next;if(J===b)J=null;else{var c=J.previous;J=c.next=b;b.previous=c}a.next=a.previous=null;c=a.callback;b=a.expirationTime;a=a.priorityLevel;var e=L,l=N;L=a;N=b;try{var h=c(K||1===a)}catch(T){throw T;}finally{L=e,N=l}if("function"===typeof h)if(h={callback:h,priorityLevel:a,expirationTime:b,next:null,previous:null},null===J)J=h.next=h.previous=h;else{c=null;a=J;do{if(a.expirationTime>=b){c=a;break}a=a.next}while(a!==J);null===c?c=J:c===J&&(J=h,Q());b=c.previous;b.next=c.previous=
h;h.next=c;h.previous=b}}function R(a){P=!1;O=!0;var b=K;K=a;try{if(a)for(;null!==J;){var c=exports.unstable_now();if(J.expirationTime<=c){do S();while(null!==J&&J.expirationTime<=c)}else break}else if(null!==J){do S();while(null!==J&&!g())}}finally{O=!1,K=b,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,b){switch(a){case 1:case 2:case 3:case 4:case 5:break;default:a=3}var c=L,e=M;L=a;M=exports.unstable_now();try{return b()}catch(l){throw Q(),l;}finally{L=c,M=e}};exports.unstable_next=function(a){switch(L){case 1:case 2:case 3:var b=3;break;default:b=L}var c=L,e=M;L=b;M=exports.unstable_now();try{return a()}catch(l){throw Q(),l;}finally{L=c,M=e}};
exports.unstable_scheduleCallback=function(a,b,c){var e=-1!==M?M: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===J)J=a.next=a.previous=a,Q();else{b=null;e=J;do{if(e.expirationTime>c){b=e;break}e=e.next}while(e!==J);null===b?b=J:b===J&&(J=a,Q());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)J=null;else{a===J&&(J=b);var c=a.previous;c.next=b;b.previous=c}a.next=a.previous=null}};exports.unstable_wrapCallback=function(a){var b=L;return function(){var c=L,e=M;L=b;M=exports.unstable_now();try{return a.apply(this,arguments)}catch(l){throw Q(),l;}finally{L=c,M=e}}};exports.unstable_getCurrentPriorityLevel=function(){return L};
exports.unstable_shouldYield=function(){return!K&&(null!==J&&J.expirationTime<N||g())};exports.unstable_continueExecution=function(){null!==J&&Q()};exports.unstable_pauseExecution=function(){};exports.unstable_getFirstCallbackNode=function(){return J};
{
"name": "scheduler",
"version": "0.13.6",
"version": "0.14.0-alpha.0",
"description": "Cooperative scheduler for the browser environment.",

@@ -30,2 +30,3 @@ "main": "index.js",

"tracing-profiling.js",
"unstable_mock.js",
"cjs/",

@@ -32,0 +33,0 @@ "umd/"

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