@@ -47,7 +47,6 @@ type Props = {
4747 left ?: null | number ,
4848 right ?: null | number ,
4949 top ?: null | number ,
50- src ?: string ,
5150 ...
5251} ;
5352type Instance = {
@@ -73,11 +72,6 @@ type CreateRootOptions = {
7372 ...
7473} ;
7574
76- type SuspenseyCommitSubscription = {
77- pendingCount : number ,
78- commit : null | ( ( ) => void ) ,
79- } ;
80-
8175const NO_CONTEXT = { } ;
8276const UPPERCASE_CONTEXT = { } ;
8377const UPDATE_SIGNAL = { } ;
@@ -244,11 +238,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
244238 hidden : ! ! newProps . hidden ,
245239 context : instance . context ,
246240 } ;
247-
248- if ( type === 'suspensey-thing' && typeof newProps . src === 'string' ) {
249- clone . src = newProps . src ;
250- }
251-
252241 Object . defineProperty ( clone , 'id' , {
253242 value : clone . id ,
254243 enumerable : false ,
@@ -282,78 +271,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
282271 return hostContext === UPPERCASE_CONTEXT ? rawText . toUpperCase ( ) : rawText ;
283272 }
284273
285- type SuspenseyThingRecord = {
286- status : 'pending' | 'fulfilled' ,
287- subscriptions : Array < SuspenseyCommitSubscription > | null ,
288- } ;
289-
290- let suspenseyThingCache : Map <
291- SuspenseyThingRecord ,
292- 'pending' | 'fulfilled' ,
293- > | null = null ;
294-
295- // Represents a subscription for all the suspensey things that block a
296- // particular commit. Once they've all loaded, the commit phase can proceed.
297- let suspenseyCommitSubscription : SuspenseyCommitSubscription | null = null ;
298-
299- function startSuspendingCommit ( ) : void {
300- // This is where we might suspend on things that aren't associated with a
301- // particular node, like document.fonts.ready.
302- suspenseyCommitSubscription = null ;
303- }
304-
305- function suspendInstance ( type : string , props : Props ) : void {
306- const src = props . src ;
307- if ( type === 'suspensey-thing' && typeof src === 'string' ) {
308- // Attach a listener to the suspensey thing and create a subscription
309- // object that uses reference counting to track when all the suspensey
310- // things have loaded.
311- const record = suspenseyThingCache . get ( src ) ;
312- if ( record === undefined ) {
313- throw new Error ( 'Could not find record for key.' ) ;
314- }
315- if ( record . status === 'pending' ) {
316- if ( suspenseyCommitSubscription === null ) {
317- suspenseyCommitSubscription = {
318- pendingCount : 1 ,
319- commit : null ,
320- } ;
321- } else {
322- suspenseyCommitSubscription . pendingCount ++ ;
323- }
324- }
325- // Stash the subscription on the record. In `resolveSuspenseyThing`,
326- // we'll use this fire the commit once all the things have loaded.
327- if ( record . subscriptions === null ) {
328- record . subscriptions = [ ] ;
329- }
330- record . subscriptions . push ( suspenseyCommitSubscription ) ;
331- } else {
332- throw new Error (
333- 'Did not expect this host component to be visited when suspending ' +
334- 'the commit. Did you check the SuspendCommit flag?' ,
335- ) ;
336- }
337- return suspenseyCommitSubscription ;
338- }
339-
340- function waitForCommitToBeReady ( ) :
341- | ( ( commit : ( ) => mixed ) => ( ) => void )
342- | null {
343- const subscription = suspenseyCommitSubscription ;
344- if ( subscription !== null ) {
345- suspenseyCommitSubscription = null ;
346- return ( commit : ( ) = > void ) => {
347- subscription . commit = commit ;
348- const cancelCommit = ( ) => {
349- subscription . commit = null ;
350- } ;
351- return cancelCommit ;
352- } ;
353- }
354- return null ;
355- }
356-
357274 const sharedHostConfig = {
358275 supportsSingletons : false ,
359276
@@ -405,11 +322,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
405322 hidden : ! ! props . hidden ,
406323 context : hostContext ,
407324 } ;
408-
409- if ( type === 'suspensey-thing' && typeof props . src === 'string' ) {
410- inst . src = props . src ;
411- }
412-
413325 // Hide from unit tests
414326 Object . defineProperty ( inst , 'id' , { value : inst . id , enumerable : false } ) ;
415327 Object . defineProperty ( inst , 'parent' , {
@@ -568,45 +480,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
568480 const endTime = Scheduler . unstable_now ( ) ;
569481 callback ( endTime ) ;
570482 } ,
571-
572- shouldSuspendCommit ( type : string , props : Props ) : boolean {
573- if ( type === 'suspensey-thing' && typeof props . src === 'string' ) {
574- if ( suspenseyThingCache === null ) {
575- suspenseyThingCache = new Map ( ) ;
576- }
577- const record = suspenseyThingCache . get ( props . src ) ;
578- if ( record === undefined ) {
579- const newRecord : SuspenseyThingRecord = {
580- status : 'pending' ,
581- subscriptions : null ,
582- } ;
583- suspenseyThingCache . set ( props . src , newRecord ) ;
584- const onLoadStart = props . onLoadStart ;
585- if ( typeof onLoadStart === 'function' ) {
586- onLoadStart ( ) ;
587- }
588- return props . src ;
589- } else {
590- if ( record . status === 'pending' ) {
591- // The resource was already requested, but it hasn't finished
592- // loading yet.
593- return true ;
594- } else {
595- // The resource has already loaded. If the renderer is confident that
596- // the resource will still be cached by the time the render commits,
597- // then it can return false, like we do here.
598- return false ;
599- }
600- }
601- }
602- // Don't need to suspend.
603- return false ;
604- } ,
605-
606- startSuspendingCommit ,
607- suspendInstance ,
608- waitForCommitToBeReady ,
609-
610483 prepareRendererToRender ( ) { } ,
611484 resetRendererAfterRender ( ) { } ,
612485 } ;
@@ -635,11 +508,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
635508 hostUpdateCounter ++ ;
636509 instance . prop = newProps . prop ;
637510 instance . hidden = ! ! newProps . hidden ;
638-
639- if ( type === 'suspensey-thing' && typeof newProps . src === 'string' ) {
640- instance . src = newProps . src ;
641- }
642-
643511 if ( shouldSetTextContent ( type , newProps ) ) {
644512 if ( __DEV__ ) {
645513 checkPropStringCoercion ( newProps . children , 'children' ) ;
@@ -821,9 +689,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
821689 if ( instance . hidden ) {
822690 props . hidden = true ;
823691 }
824- if ( instance . src ) {
825- props . src = instance . src ;
826- }
827692 if ( children !== null ) {
828693 props . children = children ;
829694 }
@@ -1050,50 +915,6 @@ function createReactNoop(reconciler: Function, useMutation: boolean) {
1050915 return getPendingChildrenAsJSX ( container ) ;
1051916 } ,
1052917
1053- getSuspenseyThingStatus ( src ) : string | null {
1054- if ( suspenseyThingCache === null ) {
1055- return null ;
1056- } else {
1057- const record = suspenseyThingCache . get ( src ) ;
1058- return record === undefined ? null : record . status ;
1059- }
1060- } ,
1061-
1062- resolveSuspenseyThing ( key : string ) : void {
1063- if ( suspenseyThingCache === null ) {
1064- suspenseyThingCache = new Map ( ) ;
1065- }
1066- const record = suspenseyThingCache . get ( key ) ;
1067- if ( record === undefined ) {
1068- const newRecord : SuspenseyThingRecord = {
1069- status : 'fulfilled' ,
1070- subscriptions : null ,
1071- } ;
1072- suspenseyThingCache . set ( key , newRecord ) ;
1073- } else {
1074- if ( record . status === 'pending' ) {
1075- record . status = 'fulfilled' ;
1076- const subscriptions = record . subscriptions ;
1077- if ( subscriptions !== null ) {
1078- record . subscriptions = null ;
1079- for ( let i = 0 ; i < subscriptions . length ; i ++ ) {
1080- const subscription = subscriptions [ i ] ;
1081- subscription . pendingCount -- ;
1082- if ( subscription . pendingCount === 0 ) {
1083- const commit = subscription . commit ;
1084- subscription . commit = null ;
1085- commit ( ) ;
1086- }
1087- }
1088- }
1089- }
1090- }
1091- } ,
1092-
1093- resetSuspenseyThingCache ( ) {
1094- suspenseyThingCache = null ;
1095- } ,
1096-
1097918 createPortal (
1098919 children : ReactNodeList ,
1099920 container : Container ,
0 commit comments