Socket
Socket
Sign inDemoInstall

scheduler

Package Overview
Dependencies
Maintainers
8
Versions
1794
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-f9e41e3a5 to 0.0.0-fa1e8df11

cjs/scheduler-unstable_mock.development.js

10

build-info.json
{
"branch": "pull/15192",
"buildNumber": "14024",
"checksum": "24ccd39",
"commit": "f9e41e3a5",
"branch": "master",
"buildNumber": "18068",
"checksum": "486c52d",
"commit": "fa1e8df11",
"environment": "ci",
"reactVersion": "16.8.4-canary-f9e41e3a5"
"reactVersion": "16.8.6-canary-fa1e8df11"
}

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

/** @license React v0.0.0-f9e41e3a5
/** @license React v0.0.0-fa1e8df11
* 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,20 @@ // 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.
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
// We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
// Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
// Temporary flag to revert the fix in #15650
var DEFAULT_THREAD_ID = 0;

@@ -61,0 +85,0 @@

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

/** @license React v0.0.0-f9e41e3a5
/** @license React v0.0.0-fa1e8df11
* scheduler-tracing.production.min.js

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

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

/** @license React v0.0.0-f9e41e3a5
/** @license React v0.0.0-fa1e8df11
* scheduler-tracing.profiling.min.js

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

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

/** @license React v0.0.0-f9e41e3a5
/** @license React v0.0.0-fa1e8df11
* scheduler.development.js

@@ -22,2 +22,258 @@ *

// 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;
exports.unstable_forceFrameRate = 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;
};
exports.unstable_forceFrameRate = function () {};
} else {
if (typeof console !== 'undefined') {
// TODO: Remove fb.me link
if (typeof localRequestAnimationFrame !== 'function') {
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
}
if (typeof localCancelAnimationFrame !== 'function') {
console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
}
}
var scheduledHostCallback = null;
var isMessageEventScheduled = false;
var timeoutTime = -1;
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;
var fpsLocked = false;
shouldYieldToHost = function () {
return frameDeadline <= exports.unstable_now();
};
exports.unstable_forceFrameRate = function (fps) {
if (fps < 0 || fps > 125) {
console.error('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported');
return;
}
if (fps > 0) {
activeFrameTime = Math.floor(1000 / fps);
fpsLocked = true;
} else {
// reset the framerate
activeFrameTime = 33;
fpsLocked = false;
}
};
// We use the postMessage trick to defer idle work until after the repaint.
var channel = new MessageChannel();
var port = channel.port2;
channel.port1.onmessage = function (event) {
isMessageEventScheduled = false;
var prevScheduledCallback = scheduledHostCallback;
var prevTimeoutTime = timeoutTime;
scheduledHostCallback = null;
timeoutTime = -1;
var currentTime = exports.unstable_now();
var didTimeout = false;
if (frameDeadline - currentTime <= 0) {
// There's no time left in this idle period. Check if the callback has
// a timeout and whether it's been exceeded.
if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
// Exceeded the timeout. Invoke the callback even though there's no
// time left.
didTimeout = true;
} 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 && !fpsLocked) {
if (nextFrameTime < 8) {
// Defensive coding. We don't support higher frame rates than 120hz.
// If the calculated frame time gets lower than 8, it is probably a bug.
nextFrameTime = 8;
}
// If one frame goes long, then the next one can be short to catch up.
// If two frames are short in a row, then that's an indication that we
// actually have a higher frame rate than what we're currently optimizing.
// We adjust our heuristic dynamically accordingly. For example, if we're
// running on 120hz display or 90hz VR display.
// Take the max of the two in case one of them was an anomaly due to
// missed frame deadlines.
activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
} else {
previousFrameTime = nextFrameTime;
}
frameDeadline = rafTime + activeFrameTime;
if (!isMessageEventScheduled) {
isMessageEventScheduled = true;
port.postMessage(undefined);
}
};
requestHostCallback = function (callback, absoluteTimeout) {
scheduledHostCallback = callback;
timeoutTime = absoluteTimeout;
if (isFlushingHostCallback || absoluteTimeout < 0) {
// Don't wait for the next frame. Continue working ASAP, in a new event.
port.postMessage(undefined);
} else if (!isAnimationFrameScheduled) {
// If rAF didn't already schedule one, we need to schedule a frame.
// TODO: If this rAF doesn't materialize because the browser throttles, we
// might want to still have setTimeout trigger rIC as a backup to ensure
// that we keep performing work.
isAnimationFrameScheduled = true;
requestAnimationFrameWithTimeout(animationTick);
}
};
cancelHostCallback = function () {
scheduledHostCallback = null;
isMessageEventScheduled = false;
timeoutTime = -1;
};
}
/* eslint-disable no-var */

@@ -49,3 +305,3 @@

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

@@ -58,27 +314,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 +354,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 +367,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 +417,3 @@ currentPriorityLevel = previousPriorityLevel;

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

@@ -168,28 +429,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 +436,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 +472,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 +499,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 +532,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 +554,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 +566,3 @@ };

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

@@ -336,3 +575,3 @@

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

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

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

@@ -366,8 +605,8 @@ next: null,

// Insert the new callback into the list, ordered first by expiration, then
// by insertion. So the new callback is inserted any other callback with
// equal expiration.
// 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;
ensureHostCallbackIsScheduled();
scheduleHostCallbackIfNeeded();
} else {

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

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

@@ -412,3 +651,3 @@

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

@@ -449,254 +688,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 +693,0 @@ exports.unstable_UserBlockingPriority = UserBlockingPriority;

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

/** @license React v0.0.0-f9e41e3a5
/** @license React v0.0.0-fa1e8df11
* scheduler.production.min.js

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

'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;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};
{
"name": "scheduler",
"version": "0.0.0-f9e41e3a5",
"version": "0.0.0-fa1e8df11",
"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/"

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

function unstable_forceFrameRate() {
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_forceFrameRate.apply(
this,
arguments
);
}
return Object.freeze({

@@ -112,2 +119,3 @@ unstable_now: unstable_now,

unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
unstable_forceFrameRate: unstable_forceFrameRate,
get unstable_IdlePriority() {

@@ -114,0 +122,0 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED

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

function unstable_forceFrameRate() {
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_forceFrameRate.apply(
this,
arguments
);
}
return Object.freeze({

@@ -106,2 +113,3 @@ unstable_now: unstable_now,

unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
unstable_forceFrameRate: unstable_forceFrameRate,
get unstable_IdlePriority() {

@@ -108,0 +116,0 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED

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

function unstable_forceFrameRate() {
return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Scheduler.unstable_forceFrameRate.apply(
this,
arguments
);
}
return Object.freeze({

@@ -106,2 +113,3 @@ unstable_now: unstable_now,

unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
unstable_forceFrameRate: unstable_forceFrameRate,
get unstable_IdlePriority() {

@@ -108,0 +116,0 @@ return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc