scheduler
Advanced tools
Comparing version 0.0.0-experimental-20a257c25-20220929 to 0.0.0-experimental-20b6f4c0e8-20240607
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
@@ -113,5 +113,5 @@ * This source code is licensed under the MIT license found in the | ||
/* eslint-disable no-var */ | ||
// Max 31 bit integer. The max integer size in V8 for 32-bit systems. | ||
// Math.pow(2, 30) - 1 | ||
// 0b111111111111111111111111111111 | ||
var maxSigned31BitInt = 1073741823; // Times out immediately | ||
@@ -208,15 +208,3 @@ | ||
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 +229,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; | ||
@@ -257,2 +249,3 @@ | ||
// regardless of how much time is left in the current time slice. | ||
// $FlowFixMe[incompatible-use] found when upgrading Flow | ||
currentTask.callback = continuationCallback; | ||
@@ -347,2 +340,3 @@ | ||
var parentPriorityLevel = currentPriorityLevel; // $FlowFixMe[incompatible-return] | ||
// $FlowFixMe[missing-this-annot] | ||
@@ -633,3 +627,3 @@ return function () { | ||
function unstable_clearYields() { | ||
function unstable_clearLog() { | ||
if (yieldedValues === null) { | ||
@@ -656,3 +650,3 @@ return []; | ||
function unstable_yieldValue(value) { | ||
function log(value) { | ||
// eslint-disable-next-line react-internal/no-production-logging | ||
@@ -692,4 +686,5 @@ if (console.log.name === 'disabledLog' || disableYieldValue) { | ||
} | ||
var unstable_Profiling = null; | ||
var unstable_Profiling = null; | ||
exports.log = log; | ||
exports.reset = reset; | ||
@@ -704,3 +699,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; | ||
@@ -725,4 +720,3 @@ exports.unstable_flushAll = unstable_flushAll; | ||
exports.unstable_wrapCallback = unstable_wrapCallback; | ||
exports.unstable_yieldValue = unstable_yieldValue; | ||
})(); | ||
} |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
@@ -37,4 +37,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. | ||
@@ -69,5 +68,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, | ||
@@ -88,4 +88,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); | ||
@@ -95,11 +95,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); | ||
} | ||
} | ||
@@ -106,0 +107,0 @@ } catch (error) { |
@@ -5,3 +5,3 @@ /** | ||
* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
@@ -16,6 +16,3 @@ * This source code is licensed under the MIT license found in the | ||
(function() { | ||
'use strict'; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
'use strict'; | ||
if ( | ||
@@ -28,5 +25,8 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
var enableSchedulerDebugging = false; | ||
var enableSchedulerDebugging = false; | ||
var enableProfiling = false; | ||
var frameYieldMs = 5; | ||
var userBlockingPriorityTimeout = 250; | ||
var normalPriorityTimeout = 5000; | ||
var lowPriorityTimeout = 10000; | ||
@@ -125,5 +125,6 @@ function push(heap, 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) { | ||
@@ -137,7 +138,6 @@ var localPerformance = performance; | ||
var localDate = Date; | ||
var initialTime = localDate.now(); | ||
var _initialTime = localDate.now(); | ||
exports.unstable_now = function () { | ||
return localDate.now() - _initialTime; | ||
return localDate.now() - initialTime; | ||
}; | ||
@@ -149,12 +149,4 @@ } // Max 31 bit integer. The max integer size in V8 for 32-bit systems. | ||
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 = []; | ||
@@ -175,6 +167,2 @@ var timerQueue = []; // Incrementing id counter. Used to maintain insertion order. | ||
var isInputPending = typeof navigator !== 'undefined' && // $FlowFixMe[prop-missing] | ||
navigator.scheduling !== undefined && // $FlowFixMe[incompatible-type] | ||
navigator.scheduling.isInputPending !== undefined ? navigator.scheduling.isInputPending.bind(navigator.scheduling) : null; | ||
function advanceTimers(currentTime) { | ||
@@ -209,3 +197,3 @@ // Check for tasks that are no longer delayed and add them to the queue. | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
requestHostCallback(); | ||
} else { | ||
@@ -221,3 +209,3 @@ var firstTimer = peek(timerQueue); | ||
function flushWork(hasTimeRemaining, initialTime) { | ||
function flushWork(initialTime) { | ||
@@ -237,17 +225,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); | ||
} | ||
@@ -261,3 +237,3 @@ } finally { | ||
function workLoop(hasTimeRemaining, initialTime) { | ||
function workLoop(initialTime) { | ||
var currentTime = initialTime; | ||
@@ -268,12 +244,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; | ||
@@ -287,2 +267,3 @@ | ||
// regardless of how much time is left in the current time slice. | ||
// $FlowFixMe[incompatible-use] found when upgrading Flow | ||
currentTask.callback = continuationCallback; | ||
@@ -373,2 +354,3 @@ | ||
var parentPriorityLevel = currentPriorityLevel; // $FlowFixMe[incompatible-return] | ||
// $FlowFixMe[missing-this-annot] | ||
@@ -408,15 +390,19 @@ return function () { | ||
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; | ||
@@ -426,3 +412,4 @@ | ||
default: | ||
timeout = NORMAL_PRIORITY_TIMEOUT; | ||
// Eventually times out | ||
timeout = normalPriorityTimeout; | ||
break; | ||
@@ -466,3 +453,3 @@ } | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
requestHostCallback(); | ||
} | ||
@@ -481,3 +468,3 @@ } | ||
isHostCallbackScheduled = true; | ||
requestHostCallback(flushWork); | ||
requestHostCallback(); | ||
} | ||
@@ -503,3 +490,2 @@ } | ||
var isMessageLoopRunning = false; | ||
var scheduledHostCallback = null; | ||
var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main | ||
@@ -520,3 +506,3 @@ // thread, like user events. By default, it yields multiple times per frame. | ||
return false; | ||
} // The main thread has been blocked for a non-negligible amount of time. We | ||
} // Yield now. | ||
@@ -527,6 +513,4 @@ | ||
function requestPaint() { | ||
function requestPaint() {} | ||
} | ||
function forceFrameRate(fps) { | ||
@@ -548,13 +532,12 @@ if (fps < 0 || fps > 125) { | ||
var performWorkUntilDeadline = function () { | ||
if (scheduledHostCallback !== null) { | ||
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. | ||
startTime = currentTime; | ||
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. | ||
@@ -564,3 +547,3 @@ var hasMoreWork = true; | ||
try { | ||
hasMoreWork = scheduledHostCallback(_hasTimeRemaining, currentTime); | ||
hasMoreWork = flushWork(currentTime); | ||
} finally { | ||
@@ -573,8 +556,5 @@ if (hasMoreWork) { | ||
isMessageLoopRunning = false; | ||
scheduledHostCallback = null; | ||
} | ||
} | ||
} else { | ||
isMessageLoopRunning = false; | ||
} // Yielding to the browser will give it a chance to paint, so we can | ||
} | ||
}; | ||
@@ -617,5 +597,3 @@ | ||
function requestHostCallback(callback) { | ||
scheduledHostCallback = callback; | ||
function requestHostCallback() { | ||
if (!isMessageLoopRunning) { | ||
@@ -639,3 +617,3 @@ isMessageLoopRunning = true; | ||
} | ||
var unstable_Profiling = null; | ||
var unstable_Profiling = null; | ||
@@ -660,3 +638,2 @@ exports.unstable_IdlePriority = IdlePriority; | ||
exports.unstable_wrapCallback = unstable_wrapCallback; | ||
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ | ||
if ( | ||
@@ -669,4 +646,4 @@ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && | ||
} | ||
})(); | ||
} |
'use strict'; | ||
if (process.env.NODE_ENV === 'production') { | ||
module.exports = require('./cjs/scheduler.production.min.js'); | ||
module.exports = require('./cjs/scheduler.production.js'); | ||
} else { | ||
module.exports = require('./cjs/scheduler.development.js'); | ||
} |
{ | ||
"name": "scheduler", | ||
"version": "0.0.0-experimental-20a257c25-20220929", | ||
"version": "0.0.0-experimental-20b6f4c0e8-20240607", | ||
"description": "Cooperative scheduler for the browser environment.", | ||
"main": "index.js", | ||
"repository": { | ||
@@ -18,6 +17,3 @@ "type": "git", | ||
}, | ||
"homepage": "https://reactjs.org/", | ||
"dependencies": { | ||
"loose-envify": "^1.1.0" | ||
}, | ||
"homepage": "https://react.dev/", | ||
"files": [ | ||
@@ -27,12 +23,7 @@ "LICENSE", | ||
"index.js", | ||
"index.native.js", | ||
"unstable_mock.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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99114
0
2950
15
4
1
- Removedloose-envify@^1.1.0
- Removedjs-tokens@4.0.0(transitive)
- Removedloose-envify@1.4.0(transitive)