@@ -21,7 +21,14 @@ export type PendingTransitionCallbacks = {
21
21
transitionStart : Array < Transition > | null ,
22
22
transitionProgress : Map < Transition , PendingBoundaries> | null ,
23
23
transitionComplete : Array < Transition > | null ,
24
- markerProgress : Map < string , TracingMarkerInstance> | null ,
24
+ markerProgress : Map <
25
+ string ,
26
+ { pendingBoundaries : PendingBoundaries , transitions : Set < Transition > } ,
27
+ > | null ,
28
+ markerIncomplete : Map <
29
+ string ,
30
+ { deletions : Array < TransitionDeletion > , transitions : Set < Transition > } ,
31
+ > | null ,
25
32
markerComplete : Map < string , Set < Transition >> | null ,
26
33
} ;
27
34
@@ -39,7 +46,16 @@ export type BatchConfigTransition = {
39
46
export type TracingMarkerInstance = { |
40
47
pendingBoundaries : PendingBoundaries | null ,
41
48
transitions : Set < Transition > | null ,
49
+ deletions : Array < TransitionDeletion > | null ,
50
+ name : string | null ,
51
+ | } ;
52
+
53
+ export type TransitionDeletion = { |
54
+ type : 'error' | 'unknown' | 'marker' | 'suspense' ,
42
55
name ?: string ,
56
+ newName ?: string ,
57
+ endTime : number ,
58
+ transitions : Set < Transition > ,
43
59
| } ;
44
60
45
61
export type PendingBoundaries = Map < OffscreenInstance , SuspenseInfo > ;
@@ -64,6 +80,7 @@ export function processTransitionCallbacks(
64
80
if ( onMarkerProgress != null && markerProgress !== null ) {
65
81
markerProgress . forEach ( ( markerInstance , markerName ) => {
66
82
if ( markerInstance . transitions !== null ) {
83
+ // TODO: Clone the suspense object so users can't modify it
67
84
const pending =
68
85
markerInstance . pendingBoundaries !== null
69
86
? Array . from ( markerInstance . pendingBoundaries . values ( ) )
@@ -96,6 +113,30 @@ export function processTransitionCallbacks(
96
113
} ) ;
97
114
}
98
115
116
+ const markerIncomplete = pendingTransitions . markerIncomplete ;
117
+ const onMarkerIncomplete = callbacks . onMarkerIncomplete ;
118
+ if ( onMarkerIncomplete != null && markerIncomplete !== null ) {
119
+ markerIncomplete . forEach ( ( { transitions, deletions} , markerName ) => {
120
+ transitions . forEach ( transition => {
121
+ const filteredDeletions = [ ] ;
122
+ deletions . forEach ( deletion => {
123
+ if ( deletion . transitions . has ( transition ) ) {
124
+ const filteredDeletion = getFilteredDeletion ( deletion , endTime ) ;
125
+ if ( filteredDeletion !== null ) {
126
+ filteredDeletions . push ( filteredDeletion ) ;
127
+ }
128
+ }
129
+ } ) ;
130
+ onMarkerIncomplete (
131
+ transition . name ,
132
+ markerName ,
133
+ transition . startTime ,
134
+ filteredDeletions ,
135
+ ) ;
136
+ } ) ;
137
+ } ) ;
138
+ }
139
+
99
140
const transitionProgress = pendingTransitions . transitionProgress ;
100
141
const onTransitionProgress = callbacks . onTransitionProgress ;
101
142
if ( onTransitionProgress != null && transitionProgress !== null ) {
@@ -120,6 +161,28 @@ export function processTransitionCallbacks(
120
161
}
121
162
}
122
163
164
+ function getFilteredDeletion ( deletion : TransitionDeletion , endTime : number ) {
165
+ switch ( deletion . type ) {
166
+ case 'marker' : {
167
+ return deletion . newName
168
+ ? {
169
+ type : deletion . type ,
170
+ name : deletion . name ,
171
+ newName : deletion . newName ,
172
+ endTime,
173
+ }
174
+ : {
175
+ type : deletion . type ,
176
+ name : deletion . name ,
177
+ endTime,
178
+ } ;
179
+ }
180
+ default : {
181
+ return null ;
182
+ }
183
+ }
184
+ }
185
+
123
186
// For every tracing marker, store a pointer to it. We will later access it
124
187
// to get the set of suspense boundaries that need to resolve before the
125
188
// tracing marker can be logged as complete
@@ -148,6 +211,8 @@ export function pushRootMarkerInstance(workInProgress: Fiber): void {
148
211
const markerInstance : TracingMarkerInstance = {
149
212
transitions : new Set ( [ transition ] ) ,
150
213
pendingBoundaries : null ,
214
+ deletions : null ,
215
+ name : null ,
151
216
} ;
152
217
root . incompleteTransitions . set ( transition , markerInstance ) ;
153
218
}
0 commit comments