@@ -26,7 +26,17 @@ export type PendingTransitionCallbacks = {
2626 transitionStart : Array < Transition > | null ,
2727 transitionProgress : Map < Transition , PendingSuspenseBoundaries> | null ,
2828 transitionComplete : Array < Transition > | null ,
29- markerProgress : Map < string , TracingMarkerInstance> | null ,
29+ markerProgress : Map <
30+ string ,
31+ {
32+ pendingSuspenseBoundaries : PendingSuspenseBoundaries ,
33+ transitions : Set < Transition > ,
34+ } ,
35+ > | null ,
36+ markerIncomplete : Map <
37+ string ,
38+ { deletions : Array < TransitionDeletion > , transitions : Set < Transition > } ,
39+ > | null ,
3040 markerComplete : Array < MarkerTransition > | null ,
3141} ;
3242
@@ -44,7 +54,17 @@ export type BatchConfigTransition = {
4454export type TracingMarkerInstance = { |
4555 pendingSuspenseBoundaries : PendingSuspenseBoundaries | null ,
4656 transitions : Set < Transition > | null ,
57+ deletions : Array < TransitionDeletion > | null ,
58+ parents : Array < TracingMarkerInstance > | null ,
59+ name : string | null ,
60+ | } ;
61+
62+ export type TransitionDeletion = { |
63+ type : 'error' | 'unknown' | 'marker' | 'suspense' ,
4764 name ?: string ,
65+ newName ?: string ,
66+ endTime : number ,
67+ transitions : Set < Transition > ,
4868| } ;
4969
5070export type PendingSuspenseBoundaries = Map < OffscreenInstance , SuspenseInfo > ;
@@ -70,6 +90,7 @@ export function processTransitionCallbacks(
7090 if ( onMarkerProgress != null && markerProgress !== null ) {
7191 markerProgress . forEach ( ( markerInstance , markerName ) => {
7292 if ( markerInstance . transitions !== null ) {
93+ // TODO: Clone the suspense object so users can't modify it
7394 const pending =
7495 markerInstance . pendingSuspenseBoundaries !== null
7596 ? Array . from ( markerInstance . pendingSuspenseBoundaries . values ( ) )
@@ -101,6 +122,30 @@ export function processTransitionCallbacks(
101122 } ) ;
102123 }
103124
125+ const markerIncomplete = pendingTransitions . markerIncomplete ;
126+ const onMarkerIncomplete = callbacks . onMarkerIncomplete ;
127+ if ( onMarkerIncomplete != null && markerIncomplete !== null ) {
128+ markerIncomplete . forEach ( ( { transitions, deletions} , markerName ) => {
129+ transitions . forEach ( transition => {
130+ const filteredDeletions = [ ] ;
131+ deletions . forEach ( deletion => {
132+ if ( deletion . transitions . has ( transition ) ) {
133+ const filteredDeletion = getFilteredDeletion ( deletion , endTime ) ;
134+ if ( filteredDeletion !== null ) {
135+ filteredDeletions . push ( filteredDeletion ) ;
136+ }
137+ }
138+ } ) ;
139+ onMarkerIncomplete (
140+ transition . name ,
141+ markerName ,
142+ transition . startTime ,
143+ filteredDeletions ,
144+ ) ;
145+ } ) ;
146+ } ) ;
147+ }
148+
104149 const transitionProgress = pendingTransitions . transitionProgress ;
105150 const onTransitionProgress = callbacks . onTransitionProgress ;
106151 if ( onTransitionProgress != null && transitionProgress !== null ) {
@@ -130,6 +175,28 @@ export function processTransitionCallbacks(
130175 }
131176}
132177
178+ function getFilteredDeletion ( deletion : TransitionDeletion , endTime : number ) {
179+ switch ( deletion . type ) {
180+ case 'marker' : {
181+ return deletion . newName
182+ ? {
183+ type : deletion . type ,
184+ name : deletion . name ,
185+ newName : deletion . newName ,
186+ endTime,
187+ }
188+ : {
189+ type : deletion . type ,
190+ name : deletion . name ,
191+ endTime,
192+ } ;
193+ }
194+ default : {
195+ return null ;
196+ }
197+ }
198+ }
199+
133200// For every tracing marker, store a pointer to it. We will later access it
134201// to get the set of suspense boundaries that need to resolve before the
135202// tracing marker can be logged as complete
@@ -158,6 +225,9 @@ export function pushRootMarkerInstance(workInProgress: Fiber): void {
158225 const markerInstance : TracingMarkerInstance = {
159226 transitions : new Set ( [ transition ] ) ,
160227 pendingSuspenseBoundaries : null ,
228+ deletions : null ,
229+ parents : null ,
230+ name : null ,
161231 } ;
162232 root . incompleteTransitions . set ( transition , markerInstance ) ;
163233 }
0 commit comments