scheduler
Advanced tools
Comparing version 0.0.0-experimental-b48b38af6 to 0.0.0-experimental-b498834eab-20240506
@@ -1,5 +0,6 @@ | ||
/** @license React vundefined | ||
/** | ||
* @license React | ||
* scheduler-unstable_mock.development.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
@@ -25,20 +26,18 @@ * This source code is licensed under the MIT license found in the | ||
function peek(heap) { | ||
var first = heap[0]; | ||
return first === undefined ? null : first; | ||
return heap.length === 0 ? null : heap[0]; | ||
} | ||
function pop(heap) { | ||
if (heap.length === 0) { | ||
return null; | ||
} | ||
var first = heap[0]; | ||
var last = heap.pop(); | ||
if (first !== undefined) { | ||
var last = heap.pop(); | ||
if (last !== first) { | ||
heap[0] = last; | ||
siftDown(heap, last, 0); | ||
} | ||
if (last !== first) { | ||
heap[0] = last; | ||
siftDown(heap, last, 0); | ||
} | ||
return first; | ||
} else { | ||
return null; | ||
} | ||
return first; | ||
} | ||
@@ -49,7 +48,7 @@ | ||
while (true) { | ||
while (index > 0) { | ||
var parentIndex = index - 1 >>> 1; | ||
var parent = heap[parentIndex]; | ||
if (parent !== undefined && compare(parent, node) > 0) { | ||
if (compare(parent, node) > 0) { | ||
// The parent is larger. Swap positions. | ||
@@ -69,4 +68,5 @@ heap[parentIndex] = node; | ||
var length = heap.length; | ||
var halfLength = length >>> 1; | ||
while (index < length) { | ||
while (index < halfLength) { | ||
var leftIndex = (index + 1) * 2 - 1; | ||
@@ -77,4 +77,4 @@ var left = heap[leftIndex]; | ||
if (left !== undefined && compare(left, node) < 0) { | ||
if (right !== undefined && compare(right, left) < 0) { | ||
if (compare(left, node) < 0) { | ||
if (rightIndex < length && compare(right, left) < 0) { | ||
heap[index] = right; | ||
@@ -88,3 +88,3 @@ heap[rightIndex] = node; | ||
} | ||
} else if (right !== undefined && compare(right, node) < 0) { | ||
} else if (rightIndex < length && compare(right, node) < 0) { | ||
heap[index] = right; | ||
@@ -135,3 +135,3 @@ heap[rightIndex] = node; | ||
var currentTask = null; | ||
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. | ||
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrance. | ||
@@ -151,3 +151,8 @@ var isPerformingWork = false; | ||
var shouldYieldForPaint = false; | ||
var disableYieldValue = false; | ||
function setDisableYieldValue(newValue) { | ||
disableYieldValue = newValue; | ||
} | ||
function advanceTimers(currentTime) { | ||
@@ -208,15 +213,3 @@ // Check for tasks that are no longer delayed and add them to the queue. | ||
try { | ||
if (enableProfiling) { | ||
try { | ||
return workLoop(hasTimeRemaining, initialTime); | ||
} catch (error) { | ||
if (currentTask !== null) { | ||
var currentTime = getCurrentTime(); | ||
markTaskErrored(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
throw error; | ||
} | ||
} else { | ||
var currentTime; if (enableProfiling) ; else { | ||
// No catch in prod code path. | ||
@@ -241,9 +234,13 @@ return workLoop(hasTimeRemaining, initialTime); | ||
break; | ||
} | ||
} // $FlowFixMe[incompatible-use] found when upgrading Flow | ||
var callback = currentTask.callback; | ||
if (typeof callback === 'function') { | ||
currentTask.callback = null; | ||
currentPriorityLevel = currentTask.priorityLevel; | ||
// $FlowFixMe[incompatible-use] found when upgrading Flow | ||
currentTask.callback = null; // $FlowFixMe[incompatible-use] found when upgrading Flow | ||
currentPriorityLevel = currentTask.priorityLevel; // $FlowFixMe[incompatible-use] found when upgrading Flow | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
@@ -255,3 +252,13 @@ | ||
if (typeof continuationCallback === 'function') { | ||
// If a continuation is returned, immediately yield to the main thread | ||
// regardless of how much time is left in the current time slice. | ||
// $FlowFixMe[incompatible-use] found when upgrading Flow | ||
currentTask.callback = continuationCallback; | ||
advanceTimers(currentTime); | ||
if (shouldYieldForPaint) { | ||
needsPaint = true; | ||
return true; | ||
} | ||
} else { | ||
@@ -262,5 +269,5 @@ | ||
} | ||
advanceTimers(currentTime); | ||
} | ||
advanceTimers(currentTime); | ||
} else { | ||
@@ -338,3 +345,5 @@ pop(taskQueue); | ||
function unstable_wrapCallback(callback) { | ||
var parentPriorityLevel = currentPriorityLevel; | ||
var parentPriorityLevel = currentPriorityLevel; // $FlowFixMe[incompatible-return] | ||
// $FlowFixMe[missing-this-annot] | ||
return function () { | ||
@@ -566,4 +575,10 @@ // This is a fork of runWithPriority, inlined for performance. | ||
} | ||
return false; | ||
} | ||
function unstable_hasPendingWork() { | ||
return scheduledCallback !== null; | ||
} | ||
function unstable_flushExpired() { | ||
@@ -619,3 +634,3 @@ if (isFlushing) { | ||
function unstable_clearYields() { | ||
function unstable_clearLog() { | ||
if (yieldedValues === null) { | ||
@@ -642,5 +657,5 @@ return []; | ||
function unstable_yieldValue(value) { | ||
function log(value) { | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
if (console.log.name === 'disabledLog') { | ||
if (console.log.name === 'disabledLog' || disableYieldValue) { | ||
// If console.log has been patched, we assume we're in render | ||
@@ -660,3 +675,3 @@ // replaying and we ignore any values yielding in the second pass. | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
if (console.log.name === 'disabledLog') { | ||
if (console.log.name === 'disabledLog' || disableYieldValue) { | ||
// If console.log has been patched, we assume we're in render | ||
@@ -679,4 +694,5 @@ // replaying and we ignore any time advancing in the second pass. | ||
} | ||
var unstable_Profiling = null; | ||
var unstable_Profiling = null; | ||
exports.log = log; | ||
exports.reset = reset; | ||
@@ -691,3 +707,3 @@ exports.unstable_IdlePriority = IdlePriority; | ||
exports.unstable_cancelCallback = unstable_cancelCallback; | ||
exports.unstable_clearYields = unstable_clearYields; | ||
exports.unstable_clearLog = unstable_clearLog; | ||
exports.unstable_continueExecution = unstable_continueExecution; | ||
@@ -702,2 +718,3 @@ exports.unstable_flushAll = unstable_flushAll; | ||
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode; | ||
exports.unstable_hasPendingWork = unstable_hasPendingWork; | ||
exports.unstable_next = unstable_next; | ||
@@ -709,6 +726,6 @@ exports.unstable_now = getCurrentTime; | ||
exports.unstable_scheduleCallback = unstable_scheduleCallback; | ||
exports.unstable_setDisableYieldValue = setDisableYieldValue; | ||
exports.unstable_shouldYield = shouldYieldToHost; | ||
exports.unstable_wrapCallback = unstable_wrapCallback; | ||
exports.unstable_yieldValue = unstable_yieldValue; | ||
})(); | ||
} |
@@ -1,5 +0,6 @@ | ||
/** @license React vundefined | ||
/** | ||
* @license React | ||
* scheduler-unstable_post_task.development.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
@@ -35,4 +36,3 @@ * This source code is licensed under the MIT license found in the | ||
var deadline = 0; | ||
var currentPriorityLevel_DEPRECATED = NormalPriority; // `isInputPending` is not available. Since we have no way of knowing if | ||
// there's pending input, always yield at the end of the frame. | ||
var currentPriorityLevel_DEPRECATED = NormalPriority; // Always yield at the end of the frame. | ||
@@ -67,5 +67,6 @@ function unstable_shouldYield() { | ||
var controller = new TaskController(); | ||
var controller = new TaskController({ | ||
priority: postTaskPriority | ||
}); | ||
var postTaskOptions = { | ||
priority: postTaskPriority, | ||
delay: typeof options === 'object' && options !== null ? options.delay : 0, | ||
@@ -86,4 +87,4 @@ signal: controller.signal | ||
currentPriorityLevel_DEPRECATED = priorityLevel; | ||
var _didTimeout_DEPRECATED = false; | ||
var result = callback(_didTimeout_DEPRECATED); | ||
var didTimeout_DEPRECATED = false; | ||
var result = callback(didTimeout_DEPRECATED); | ||
@@ -93,11 +94,12 @@ if (typeof result === 'function') { | ||
var continuation = result; | ||
var continuationController = new TaskController(); | ||
var continuationOptions = { | ||
priority: postTaskPriority, | ||
signal: continuationController.signal | ||
}; // Update the original callback node's controller, since even though we're | ||
// posting a new task, conceptually it's the same one. | ||
signal: node._controller.signal | ||
}; | ||
var nextTask = runTask.bind(null, priorityLevel, postTaskPriority, node, continuation); | ||
node._controller = continuationController; | ||
scheduler.postTask(runTask.bind(null, priorityLevel, postTaskPriority, node, continuation), continuationOptions).catch(handleAbortError); | ||
if (scheduler.yield !== undefined) { | ||
scheduler.yield(continuationOptions).then(nextTask).catch(handleAbortError); | ||
} else { | ||
scheduler.postTask(nextTask, continuationOptions).catch(handleAbortError); | ||
} | ||
} | ||
@@ -104,0 +106,0 @@ } catch (error) { |
@@ -1,5 +0,6 @@ | ||
/** @license React vundefined | ||
/** | ||
* @license React | ||
* scheduler.development.js | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
@@ -15,5 +16,15 @@ * This source code is licensed under the MIT license found in the | ||
'use strict'; | ||
if ( | ||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === | ||
'function' | ||
) { | ||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); | ||
} | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = false; | ||
var frameYieldMs = 5; | ||
var userBlockingPriorityTimeout = 250; | ||
var normalPriorityTimeout = 5000; | ||
var lowPriorityTimeout = 10000; | ||
@@ -26,20 +37,18 @@ function push(heap, node) { | ||
function peek(heap) { | ||
var first = heap[0]; | ||
return first === undefined ? null : first; | ||
return heap.length === 0 ? null : heap[0]; | ||
} | ||
function pop(heap) { | ||
if (heap.length === 0) { | ||
return null; | ||
} | ||
var first = heap[0]; | ||
var last = heap.pop(); | ||
if (first !== undefined) { | ||
var last = heap.pop(); | ||
if (last !== first) { | ||
heap[0] = last; | ||
siftDown(heap, last, 0); | ||
} | ||
if (last !== first) { | ||
heap[0] = last; | ||
siftDown(heap, last, 0); | ||
} | ||
return first; | ||
} else { | ||
return null; | ||
} | ||
return first; | ||
} | ||
@@ -50,7 +59,7 @@ | ||
while (true) { | ||
while (index > 0) { | ||
var parentIndex = index - 1 >>> 1; | ||
var parent = heap[parentIndex]; | ||
if (parent !== undefined && compare(parent, node) > 0) { | ||
if (compare(parent, node) > 0) { | ||
// The parent is larger. Swap positions. | ||
@@ -70,4 +79,5 @@ heap[parentIndex] = node; | ||
var length = heap.length; | ||
var halfLength = length >>> 1; | ||
while (index < length) { | ||
while (index < halfLength) { | ||
var leftIndex = (index + 1) * 2 - 1; | ||
@@ -78,4 +88,4 @@ var left = heap[leftIndex]; | ||
if (left !== undefined && compare(left, node) < 0) { | ||
if (right !== undefined && compare(right, left) < 0) { | ||
if (compare(left, node) < 0) { | ||
if (rightIndex < length && compare(right, left) < 0) { | ||
heap[index] = right; | ||
@@ -89,3 +99,3 @@ heap[rightIndex] = node; | ||
} | ||
} else if (right !== undefined && compare(right, node) < 0) { | ||
} else if (rightIndex < length && compare(right, node) < 0) { | ||
heap[index] = right; | ||
@@ -118,5 +128,6 @@ heap[rightIndex] = node; | ||
/* eslint-disable no-var */ | ||
exports.unstable_now = void 0; | ||
var hasPerformanceNow = // $FlowFixMe[method-unbinding] | ||
typeof performance === 'object' && typeof performance.now === 'function'; | ||
var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function'; | ||
if (hasPerformanceNow) { | ||
@@ -140,12 +151,4 @@ var localPerformance = performance; | ||
var maxSigned31BitInt = 1073741823; // Times out immediately | ||
var maxSigned31BitInt = 1073741823; // Tasks are stored on a min heap | ||
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out | ||
var USER_BLOCKING_PRIORITY_TIMEOUT = 250; | ||
var NORMAL_PRIORITY_TIMEOUT = 5000; | ||
var LOW_PRIORITY_TIMEOUT = 10000; // Never times out | ||
var IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt; // Tasks are stored on a min heap | ||
var taskQueue = []; | ||
@@ -156,3 +159,3 @@ var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. | ||
var currentTask = null; | ||
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy. | ||
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrance. | ||
@@ -163,24 +166,6 @@ var isPerformingWork = false; | ||
var setTimeout = window.setTimeout; | ||
var clearTimeout = window.clearTimeout; | ||
var setImmediate = window.setImmediate; // IE and Node.js + jsdom | ||
var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : null; | ||
var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : null; | ||
var localSetImmediate = typeof setImmediate !== 'undefined' ? setImmediate : null; // IE and Node.js + jsdom | ||
if (typeof console !== 'undefined') { | ||
// TODO: Scheduler no longer requires these methods to be polyfilled. But | ||
// maybe we want to continue warning if they don't exist, to preserve the | ||
// option to rely on it in the future? | ||
var requestAnimationFrame = window.requestAnimationFrame; | ||
var cancelAnimationFrame = window.cancelAnimationFrame; | ||
if (typeof requestAnimationFrame !== 'function') { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); | ||
} | ||
if (typeof cancelAnimationFrame !== 'function') { | ||
// Using console['error'] to evade Babel and ESLint | ||
console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills'); | ||
} | ||
} | ||
function advanceTimers(currentTime) { | ||
@@ -215,3 +200,3 @@ // Check for tasks that are no longer delayed and add them to the queue. | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
requestHostCallback(); | ||
} else { | ||
@@ -227,3 +212,3 @@ var firstTimer = peek(timerQueue); | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
function flushWork(initialTime) { | ||
@@ -243,17 +228,5 @@ | ||
try { | ||
if (enableProfiling) { | ||
try { | ||
return workLoop(hasTimeRemaining, initialTime); | ||
} catch (error) { | ||
if (currentTask !== null) { | ||
var currentTime = exports.unstable_now(); | ||
markTaskErrored(currentTask, currentTime); | ||
currentTask.isQueued = false; | ||
} | ||
throw error; | ||
} | ||
} else { | ||
var currentTime; if (enableProfiling) ; else { | ||
// No catch in prod code path. | ||
return workLoop(hasTimeRemaining, initialTime); | ||
return workLoop(initialTime); | ||
} | ||
@@ -267,3 +240,3 @@ } finally { | ||
function workLoop(hasTimeRemaining, initialTime) { | ||
function workLoop(initialTime) { | ||
var currentTime = initialTime; | ||
@@ -274,12 +247,16 @@ advanceTimers(currentTime); | ||
while (currentTask !== null && !(enableSchedulerDebugging )) { | ||
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) { | ||
if (currentTask.expirationTime > currentTime && shouldYieldToHost()) { | ||
// This currentTask hasn't expired, and we've reached the deadline. | ||
break; | ||
} | ||
} // $FlowFixMe[incompatible-use] found when upgrading Flow | ||
var callback = currentTask.callback; | ||
if (typeof callback === 'function') { | ||
currentTask.callback = null; | ||
currentPriorityLevel = currentTask.priorityLevel; | ||
// $FlowFixMe[incompatible-use] found when upgrading Flow | ||
currentTask.callback = null; // $FlowFixMe[incompatible-use] found when upgrading Flow | ||
currentPriorityLevel = currentTask.priorityLevel; // $FlowFixMe[incompatible-use] found when upgrading Flow | ||
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime; | ||
@@ -291,3 +268,9 @@ | ||
if (typeof continuationCallback === 'function') { | ||
// If a continuation is returned, immediately yield to the main thread | ||
// regardless of how much time is left in the current time slice. | ||
// $FlowFixMe[incompatible-use] found when upgrading Flow | ||
currentTask.callback = continuationCallback; | ||
advanceTimers(currentTime); | ||
return true; | ||
} else { | ||
@@ -298,5 +281,5 @@ | ||
} | ||
advanceTimers(currentTime); | ||
} | ||
advanceTimers(currentTime); | ||
} else { | ||
@@ -374,3 +357,5 @@ pop(taskQueue); | ||
function unstable_wrapCallback(callback) { | ||
var parentPriorityLevel = currentPriorityLevel; | ||
var parentPriorityLevel = currentPriorityLevel; // $FlowFixMe[incompatible-return] | ||
// $FlowFixMe[missing-this-annot] | ||
return function () { | ||
@@ -409,15 +394,19 @@ // This is a fork of runWithPriority, inlined for performance. | ||
case ImmediatePriority: | ||
timeout = IMMEDIATE_PRIORITY_TIMEOUT; | ||
// Times out immediately | ||
timeout = -1; | ||
break; | ||
case UserBlockingPriority: | ||
timeout = USER_BLOCKING_PRIORITY_TIMEOUT; | ||
// Eventually times out | ||
timeout = userBlockingPriorityTimeout; | ||
break; | ||
case IdlePriority: | ||
timeout = IDLE_PRIORITY_TIMEOUT; | ||
// Never times out | ||
timeout = maxSigned31BitInt; | ||
break; | ||
case LowPriority: | ||
timeout = LOW_PRIORITY_TIMEOUT; | ||
// Eventually times out | ||
timeout = lowPriorityTimeout; | ||
break; | ||
@@ -427,3 +416,4 @@ | ||
default: | ||
timeout = NORMAL_PRIORITY_TIMEOUT; | ||
// Eventually times out | ||
timeout = normalPriorityTimeout; | ||
break; | ||
@@ -467,3 +457,3 @@ } | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
requestHostCallback(); | ||
} | ||
@@ -482,3 +472,3 @@ } | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
requestHostCallback(); | ||
} | ||
@@ -504,3 +494,2 @@ } | ||
var isMessageLoopRunning = false; | ||
var scheduledHostCallback = null; | ||
var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main | ||
@@ -511,17 +500,20 @@ // thread, like user events. By default, it yields multiple times per frame. | ||
var yieldInterval = 5; | ||
var deadline = 0; // TODO: Make this configurable | ||
var frameInterval = frameYieldMs; | ||
var startTime = -1; | ||
function shouldYieldToHost() { | ||
{ | ||
// `isInputPending` is not available. Since we have no way of knowing if | ||
// there's pending input, always yield at the end of the frame. | ||
return exports.unstable_now() >= deadline; | ||
} | ||
} | ||
var timeElapsed = exports.unstable_now() - startTime; | ||
function requestPaint() { | ||
if (timeElapsed < frameInterval) { | ||
// The main thread has only been blocked for a really short amount of time; | ||
// smaller than a single frame. Don't yield yet. | ||
return false; | ||
} // Yield now. | ||
return true; | ||
} | ||
function requestPaint() {} | ||
function forceFrameRate(fps) { | ||
@@ -535,6 +527,6 @@ if (fps < 0 || fps > 125) { | ||
if (fps > 0) { | ||
yieldInterval = Math.floor(1000 / fps); | ||
frameInterval = Math.floor(1000 / fps); | ||
} else { | ||
// reset the framerate | ||
yieldInterval = 5; | ||
frameInterval = frameYieldMs; | ||
} | ||
@@ -544,14 +536,12 @@ } | ||
var performWorkUntilDeadline = function () { | ||
if (scheduledHostCallback !== null) { | ||
var currentTime = exports.unstable_now(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync | ||
// cycle. This means there's always time remaining at the beginning of | ||
// the message event. | ||
if (isMessageLoopRunning) { | ||
var currentTime = exports.unstable_now(); // Keep track of the start time so we can measure how long the main thread | ||
// has been blocked. | ||
deadline = currentTime + yieldInterval; | ||
var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the | ||
startTime = currentTime; // If a scheduler task throws, exit the current browser task so the | ||
// error can be observed. | ||
// | ||
// Intentionally not using a try-catch, since that makes some debugging | ||
// techniques harder. Instead, if `scheduledHostCallback` errors, then | ||
// `hasMoreWork` will remain true, and we'll continue the work loop. | ||
// techniques harder. Instead, if `flushWork` errors, then `hasMoreWork` will | ||
// remain true, and we'll continue the work loop. | ||
@@ -561,3 +551,3 @@ var hasMoreWork = true; | ||
try { | ||
hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime); | ||
hasMoreWork = flushWork(currentTime); | ||
} finally { | ||
@@ -570,8 +560,5 @@ if (hasMoreWork) { | ||
isMessageLoopRunning = false; | ||
scheduledHostCallback = null; | ||
} | ||
} | ||
} else { | ||
isMessageLoopRunning = false; | ||
} // Yielding to the browser will give it a chance to paint, so we can | ||
} | ||
}; | ||
@@ -581,3 +568,3 @@ | ||
if (typeof setImmediate === 'function') { | ||
if (typeof localSetImmediate === 'function') { | ||
// Node.js and old IE. | ||
@@ -595,5 +582,7 @@ // There's a few reasons for why we prefer setImmediate. | ||
schedulePerformWorkUntilDeadline = function () { | ||
setImmediate(performWorkUntilDeadline); | ||
localSetImmediate(performWorkUntilDeadline); | ||
}; | ||
} else { | ||
} else if (typeof MessageChannel !== 'undefined') { | ||
// DOM and Worker environments. | ||
// We prefer MessageChannel because of the 4ms setTimeout clamping. | ||
var channel = new MessageChannel(); | ||
@@ -606,7 +595,11 @@ var port = channel.port2; | ||
}; | ||
} else { | ||
// We should only fallback here in non-browser environments. | ||
schedulePerformWorkUntilDeadline = function () { | ||
// $FlowFixMe[not-a-function] nullable value | ||
localSetTimeout(performWorkUntilDeadline, 0); | ||
}; | ||
} | ||
function requestHostCallback(callback) { | ||
scheduledHostCallback = callback; | ||
function requestHostCallback() { | ||
if (!isMessageLoopRunning) { | ||
@@ -619,3 +612,4 @@ isMessageLoopRunning = true; | ||
function requestHostTimeout(callback, ms) { | ||
taskTimeoutID = setTimeout(function () { | ||
// $FlowFixMe[not-a-function] nullable value | ||
taskTimeoutID = localSetTimeout(function () { | ||
callback(exports.unstable_now()); | ||
@@ -626,9 +620,8 @@ }, ms); | ||
function cancelHostTimeout() { | ||
clearTimeout(taskTimeoutID); | ||
// $FlowFixMe[not-a-function] nullable value | ||
localClearTimeout(taskTimeoutID); | ||
taskTimeoutID = -1; | ||
} | ||
var unstable_Profiling = null; | ||
var unstable_requestPaint = requestPaint; | ||
var unstable_Profiling = null; | ||
exports.unstable_IdlePriority = IdlePriority; | ||
@@ -647,3 +640,3 @@ exports.unstable_ImmediatePriority = ImmediatePriority; | ||
exports.unstable_pauseExecution = unstable_pauseExecution; | ||
exports.unstable_requestPaint = unstable_requestPaint; | ||
exports.unstable_requestPaint = requestPaint; | ||
exports.unstable_runWithPriority = unstable_runWithPriority; | ||
@@ -653,3 +646,11 @@ exports.unstable_scheduleCallback = unstable_scheduleCallback; | ||
exports.unstable_wrapCallback = unstable_wrapCallback; | ||
if ( | ||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === | ||
'function' | ||
) { | ||
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); | ||
} | ||
})(); | ||
} |
'use strict'; | ||
if (typeof window === 'undefined' || typeof MessageChannel !== 'function') { | ||
module.exports = require('./unstable_no_dom'); | ||
} else if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/scheduler.production.min.js'); | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/scheduler.production.js'); | ||
} else { | ||
module.exports = require('./cjs/scheduler.development.js'); | ||
} |
{ | ||
"name": "scheduler", | ||
"version": "0.0.0-experimental-b48b38af6", | ||
"version": "0.0.0-experimental-b498834eab-20240506", | ||
"description": "Cooperative scheduler for the browser environment.", | ||
"main": "index.js", | ||
"repository": { | ||
@@ -18,25 +17,12 @@ "type": "git", | ||
}, | ||
"homepage": "https://reactjs.org/", | ||
"dependencies": { | ||
"loose-envify": "^1.1.0", | ||
"object-assign": "^4.1.1" | ||
}, | ||
"homepage": "https://react.dev/", | ||
"files": [ | ||
"LICENSE", | ||
"README.md", | ||
"build-info.json", | ||
"index.js", | ||
"tracing.js", | ||
"tracing-profiling.js", | ||
"index.native.js", | ||
"unstable_mock.js", | ||
"unstable_no_dom.js", | ||
"unstable_post_task.js", | ||
"cjs/", | ||
"umd/" | ||
], | ||
"browserify": { | ||
"transform": [ | ||
"loose-envify" | ||
] | ||
} | ||
"cjs/" | ||
] | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/scheduler-unstable_mock.production.min.js'); | ||
module.exports = require('./cjs/scheduler-unstable_mock.production.js'); | ||
} else { | ||
module.exports = require('./cjs/scheduler-unstable_mock.development.js'); | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/scheduler-unstable_post_task.production.min.js'); | ||
module.exports = require('./cjs/scheduler-unstable_post_task.production.js'); | ||
} else { | ||
module.exports = require('./cjs/scheduler-unstable_post_task.development.js'); | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
4
99114
15
2950
1
- Removedloose-envify@^1.1.0
- Removedobject-assign@^4.1.1
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedobject-assign@4.1.1(transitive)