@@ -21,7 +21,14 @@ export type PendingTransitionCallbacks = {
2121 transitionStart : Array < Transition > | null ,
2222 transitionProgress : Map < Transition , PendingBoundaries> | null ,
2323 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 ,
2532 markerComplete : Map < string , Set < Transition >> | null ,
2633} ;
2734
@@ -39,7 +46,16 @@ export type BatchConfigTransition = {
3946export type TracingMarkerInstance = { |
4047 pendingBoundaries : PendingBoundaries | null ,
4148 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' ,
4255 name ?: string ,
56+ newName ?: string ,
57+ endTime : number ,
58+ transitions : Set < Transition > ,
4359| } ;
4460
4561export type PendingBoundaries = Map < OffscreenInstance , SuspenseInfo > ;
@@ -64,6 +80,7 @@ export function processTransitionCallbacks(
6480 if ( onMarkerProgress != null && markerProgress !== null ) {
6581 markerProgress . forEach ( ( markerInstance , markerName ) => {
6682 if ( markerInstance . transitions !== null ) {
83+ // TODO: Clone the suspense object so users can't modify it
6784 const pending =
6885 markerInstance . pendingBoundaries !== null
6986 ? Array . from ( markerInstance . pendingBoundaries . values ( ) )
@@ -96,6 +113,30 @@ export function processTransitionCallbacks(
96113 } ) ;
97114 }
98115
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+
99140 const transitionProgress = pendingTransitions . transitionProgress ;
100141 const onTransitionProgress = callbacks . onTransitionProgress ;
101142 if ( onTransitionProgress != null && transitionProgress !== null ) {
@@ -120,6 +161,28 @@ export function processTransitionCallbacks(
120161 }
121162}
122163
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+
123186// For every tracing marker, store a pointer to it. We will later access it
124187// to get the set of suspense boundaries that need to resolve before the
125188// tracing marker can be logged as complete
@@ -148,6 +211,8 @@ export function pushRootMarkerInstance(workInProgress: Fiber): void {
148211 const markerInstance : TracingMarkerInstance = {
149212 transitions : new Set ( [ transition ] ) ,
150213 pendingBoundaries : null ,
214+ deletions : null ,
215+ name : null ,
151216 } ;
152217 root . incompleteTransitions . set ( transition , markerInstance ) ;
153218 }
0 commit comments