8
8
*/
9
9
10
10
import type { AnyNativeEvent } from '../events/PluginModuleType' ;
11
- import type { FiberRoot } from 'react-reconciler/src/ReactInternalTypes' ;
11
+ import type {
12
+ FiberRoot ,
13
+ ReactPriorityLevel ,
14
+ } from 'react-reconciler/src/ReactInternalTypes' ;
12
15
import type { Container , SuspenseInstance } from '../client/ReactDOMHostConfig' ;
13
16
import type { DOMEventName } from '../events/DOMEventNames' ;
14
17
@@ -50,18 +53,27 @@ import {
50
53
DefaultLanePriority as DefaultLanePriority_old ,
51
54
getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_old ,
52
55
setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_old ,
53
- schedulerPriorityToLanePriority as schedulerPriorityToLanePriority_old ,
54
56
} from 'react-reconciler/src/ReactFiberLane.old' ;
55
57
import {
56
58
InputDiscreteLanePriority as InputDiscreteLanePriority_new ,
57
59
InputContinuousLanePriority as InputContinuousLanePriority_new ,
58
60
DefaultLanePriority as DefaultLanePriority_new ,
59
61
getCurrentUpdateLanePriority as getCurrentUpdateLanePriority_new ,
60
62
setCurrentUpdateLanePriority as setCurrentUpdateLanePriority_new ,
61
- schedulerPriorityToLanePriority as schedulerPriorityToLanePriority_new ,
63
+ SyncLanePriority ,
64
+ IdleLanePriority ,
65
+ NoLanePriority ,
62
66
} from 'react-reconciler/src/ReactFiberLane.new' ;
63
67
import { getCurrentPriorityLevel as getCurrentPriorityLevel_old } from 'react-reconciler/src/SchedulerWithReactIntegration.old' ;
64
- import { getCurrentPriorityLevel as getCurrentPriorityLevel_new } from 'react-reconciler/src/SchedulerWithReactIntegration.new' ;
68
+ import {
69
+ getCurrentPriorityLevel as getCurrentPriorityLevel_new ,
70
+ IdlePriority as IdleSchedulerPriority ,
71
+ ImmediatePriority as ImmediateSchedulerPriority ,
72
+ LowPriority as LowSchedulerPriority ,
73
+ NormalPriority as NormalSchedulerPriority ,
74
+ UserBlockingPriority as UserBlockingSchedulerPriority ,
75
+ } from 'react-reconciler/src/SchedulerWithReactIntegration.new' ;
76
+ import type { LanePriority } from 'react-reconciler/src/ReactFiberLane.new' ;
65
77
66
78
const InputDiscreteLanePriority = enableNewReconciler
67
79
? InputDiscreteLanePriority_new
@@ -78,13 +90,29 @@ const getCurrentUpdateLanePriority = enableNewReconciler
78
90
const setCurrentUpdateLanePriority = enableNewReconciler
79
91
? setCurrentUpdateLanePriority_new
80
92
: setCurrentUpdateLanePriority_old ;
81
- const schedulerPriorityToLanePriority = enableNewReconciler
82
- ? schedulerPriorityToLanePriority_new
83
- : schedulerPriorityToLanePriority_old ;
84
93
const getCurrentPriorityLevel = enableNewReconciler
85
94
? getCurrentPriorityLevel_new
86
95
: getCurrentPriorityLevel_old ;
87
96
97
+ function schedulerPriorityToLanePriority (
98
+ schedulerPriorityLevel : ReactPriorityLevel ,
99
+ ) : LanePriority {
100
+ switch ( schedulerPriorityLevel ) {
101
+ case ImmediateSchedulerPriority :
102
+ return SyncLanePriority ;
103
+ case UserBlockingSchedulerPriority :
104
+ return InputContinuousLanePriority ;
105
+ case NormalSchedulerPriority :
106
+ case LowSchedulerPriority :
107
+ // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration.
108
+ return DefaultLanePriority ;
109
+ case IdleSchedulerPriority :
110
+ return IdleLanePriority ;
111
+ default :
112
+ return NoLanePriority ;
113
+ }
114
+ }
115
+
88
116
// TODO: can we stop exporting these?
89
117
export let _enabled = true ;
90
118
@@ -410,8 +438,6 @@ export function getEventPriority(domEventName: DOMEventName): * {
410
438
// Eventually this mechanism will be replaced by a check
411
439
// of the current priority on the native scheduler.
412
440
const schedulerPriority = getCurrentPriorityLevel ( ) ;
413
- // TODO: Inline schedulerPriorityToLanePriority into this file
414
- // when we delete the enableNativeEventPriorityInference flag.
415
441
return schedulerPriorityToLanePriority ( schedulerPriority ) ;
416
442
}
417
443
default :
0 commit comments