diff --git a/packages/react/src/ReactSharedInternals.js b/packages/react/src/ReactSharedInternals.js index 1fe0c2391bd13..b4d1b9358c483 100644 --- a/packages/react/src/ReactSharedInternals.js +++ b/packages/react/src/ReactSharedInternals.js @@ -18,6 +18,11 @@ import { unstable_continueExecution, unstable_wrapCallback, unstable_getCurrentPriorityLevel, + unstable_IdlePriority, + unstable_ImmediatePriority, + unstable_LowPriority, + unstable_NormalPriority, + unstable_UserBlockingPriority, } from 'scheduler'; import { __interactionsRef, @@ -60,6 +65,11 @@ if (__UMD__) { unstable_pauseExecution, unstable_continueExecution, unstable_getCurrentPriorityLevel, + unstable_IdlePriority, + unstable_ImmediatePriority, + unstable_LowPriority, + unstable_NormalPriority, + unstable_UserBlockingPriority, }, SchedulerTracing: { __interactionsRef, diff --git a/packages/scheduler/npm/umd/scheduler.development.js b/packages/scheduler/npm/umd/scheduler.development.js index ac632eb288bff..206897dcfb97f 100644 --- a/packages/scheduler/npm/umd/scheduler.development.js +++ b/packages/scheduler/npm/umd/scheduler.development.js @@ -108,5 +108,25 @@ unstable_continueExecution: unstable_continueExecution, unstable_pauseExecution: unstable_pauseExecution, unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, + get unstable_IdlePriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_IdlePriority; + }, + get unstable_ImmediatePriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_ImmediatePriority; + }, + get unstable_LowPriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_LowPriority; + }, + get unstable_NormalPriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_NormalPriority; + }, + get unstable_UserBlockingPriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_UserBlockingPriority; + }, }); }); diff --git a/packages/scheduler/npm/umd/scheduler.production.min.js b/packages/scheduler/npm/umd/scheduler.production.min.js index da2aefa9e4bf1..90ee11f122d92 100644 --- a/packages/scheduler/npm/umd/scheduler.production.min.js +++ b/packages/scheduler/npm/umd/scheduler.production.min.js @@ -102,5 +102,25 @@ unstable_continueExecution: unstable_continueExecution, unstable_pauseExecution: unstable_pauseExecution, unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, + get unstable_IdlePriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_IdlePriority; + }, + get unstable_ImmediatePriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_ImmediatePriority; + }, + get unstable_LowPriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_LowPriority; + }, + get unstable_NormalPriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_NormalPriority; + }, + get unstable_UserBlockingPriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_UserBlockingPriority; + }, }); }); diff --git a/packages/scheduler/npm/umd/scheduler.profiling.min.js b/packages/scheduler/npm/umd/scheduler.profiling.min.js index da2aefa9e4bf1..90ee11f122d92 100644 --- a/packages/scheduler/npm/umd/scheduler.profiling.min.js +++ b/packages/scheduler/npm/umd/scheduler.profiling.min.js @@ -102,5 +102,25 @@ unstable_continueExecution: unstable_continueExecution, unstable_pauseExecution: unstable_pauseExecution, unstable_getFirstCallbackNode: unstable_getFirstCallbackNode, + get unstable_IdlePriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_IdlePriority; + }, + get unstable_ImmediatePriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_ImmediatePriority; + }, + get unstable_LowPriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_LowPriority; + }, + get unstable_NormalPriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_NormalPriority; + }, + get unstable_UserBlockingPriority() { + return global.React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED + .Scheduler.unstable_UserBlockingPriority; + }, }); }); diff --git a/packages/scheduler/src/__tests__/SchedulerUMDBundle-test.internal.js b/packages/scheduler/src/__tests__/SchedulerUMDBundle-test.internal.js index 8fd78522480f1..b22d2c27704ce 100644 --- a/packages/scheduler/src/__tests__/SchedulerUMDBundle-test.internal.js +++ b/packages/scheduler/src/__tests__/SchedulerUMDBundle-test.internal.js @@ -17,8 +17,17 @@ describe('Scheduling UMD bundle', () => { }); function filterPrivateKeys(name) { - // TODO: Figure out how to forward priority levels. - return !name.startsWith('_') && !name.endsWith('Priority'); + // Be very careful adding things to this whitelist! + // It's easy to introduce bugs by doing it: + // https://github.com/facebook/react/issues/14904 + switch (name) { + case '__interactionsRef': + case '__subscriberRef': + // Don't forward these. (TODO: why?) + return false; + default: + return true; + } } function validateForwardedAPIs(api, forwardedAPIs) {