@@ -79,12 +79,12 @@ import {
7979 LOADING_AFTER_CLEANUP_FN ,
8080 NEXT_DEFER_BLOCK_STATE ,
8181 ON_COMPLETE_FNS ,
82- SSR_STATE ,
82+ SSR_BLOCK_STATE ,
8383 STATE_IS_FROZEN_UNTIL ,
8484 TDeferBlockDetails ,
8585 TriggerType ,
8686 DeferBlock ,
87- UNIQUE_SSR_ID ,
87+ SSR_UNIQUE_ID ,
8888} from './interfaces' ;
8989import { onTimer , scheduleTimerTrigger } from './timer_scheduler' ;
9090import {
@@ -144,7 +144,8 @@ function shouldTriggerWhenOnClient(
144144 if ( ! isPlatformBrowser ( injector ) ) {
145145 return false ;
146146 }
147- const isServerRendered = lDetails [ SSR_STATE ] && lDetails [ SSR_STATE ] === DeferBlockState . Complete ;
147+ const isServerRendered =
148+ lDetails [ SSR_BLOCK_STATE ] && lDetails [ SSR_BLOCK_STATE ] === DeferBlockState . Complete ;
148149 const hasHydrateTriggers = tDetails . hydrateTriggers && tDetails . hydrateTriggers . size > 0 ;
149150 if ( hasHydrateTriggers && isServerRendered && isIncrementalHydrationEnabled ( injector ) ) {
150151 return false ;
@@ -280,13 +281,12 @@ export function ɵɵdefer(
280281 // In client-only mode, this function is a noop.
281282 populateDehydratedViewsInLContainer ( lContainer , tNode , lView ) ;
282283
283- let ssrState = null ;
284- let uniqueId : string | null = null ;
284+ let ssrBlockState = null ;
285+ let ssrUniqueId : string | null = null ;
285286 if ( lContainer [ DEHYDRATED_VIEWS ] ?. length > 0 ) {
286- // TODO(incremental-hydration): this is a hack, we should serialize defer
287287 const info = lContainer [ DEHYDRATED_VIEWS ] [ 0 ] . data ;
288- uniqueId = info [ DEFER_BLOCK_ID ] ?? null ;
289- ssrState = info [ SERIALIZED_DEFER_BLOCK_STATE ] ;
288+ ssrUniqueId = info [ DEFER_BLOCK_ID ] ?? null ;
289+ ssrBlockState = info [ SERIALIZED_DEFER_BLOCK_STATE ] ;
290290 }
291291
292292 // Init instance-specific defer details and store it.
@@ -297,21 +297,21 @@ export function ɵɵdefer(
297297 null , // LOADING_AFTER_CLEANUP_FN
298298 null , // TRIGGER_CLEANUP_FNS
299299 null , // PREFETCH_TRIGGER_CLEANUP_FNS
300- uniqueId , // UNIQUE_ID
301- ssrState , // SSR_STATE
300+ ssrUniqueId , // SSR_UNIQUE_ID
301+ ssrBlockState , // SSR_BLOCK_STATE
302302 null , // ON_COMPLETE_FNS
303303 null , // HYDRATE_TRIGGER_CLEANUP_FNS
304304 ] ;
305305 setLDeferBlockDetails ( lView , adjustedIndex , lDetails ) ;
306306
307307 let registry : DeferBlockRegistry | null = null ;
308- if ( uniqueId !== null ) {
308+ if ( ssrUniqueId !== null ) {
309309 // TODO(incremental-hydration): explore how we can make
310310 // `DeferBlockRegistry` tree-shakable for client-only cases.
311311 registry = injector . get ( DeferBlockRegistry ) ;
312312
313313 // Also store this defer block in the registry.
314- registry . add ( uniqueId , { lView, tNode, lContainer} ) ;
314+ registry . add ( ssrUniqueId , { lView, tNode, lContainer} ) ;
315315 }
316316
317317 const cleanupTriggersFn = ( ) => invokeAllTriggerCleanupFns ( lDetails , registry ) ;
@@ -415,7 +415,7 @@ export function ɵɵdeferHydrateWhen(rawValue: unknown) {
415415 // state.
416416 incrementallyHydrateFromBlockName (
417417 injector ,
418- getLDeferBlockDetails ( lView , tNode ) [ UNIQUE_SSR_ID ] ! ,
418+ getLDeferBlockDetails ( lView , tNode ) [ SSR_UNIQUE_ID ] ! ,
419419 ( deferBlock : DeferBlock ) => triggerAndWaitForCompletion ( deferBlock ) ,
420420 ) ;
421421 }
@@ -534,7 +534,7 @@ export function ɵɵdeferHydrateOnImmediate() {
534534 } else {
535535 incrementallyHydrateFromBlockName (
536536 injector ,
537- lDetails [ UNIQUE_SSR_ID ] ! ,
537+ lDetails [ SSR_UNIQUE_ID ] ! ,
538538 ( deferBlock : DeferBlock ) => triggerAndWaitForCompletion ( deferBlock ) ,
539539 ) ;
540540 }
@@ -643,6 +643,8 @@ export function ɵɵdeferHydrateOnHover() {
643643 // We are on the server and SSR for defer blocks is enabled.
644644 triggerDeferBlock ( lView , tNode ) ;
645645 }
646+ // The actual triggering of hydration on hover is handled by JSAction in
647+ // event_replay.ts.
646648}
647649
648650/**
@@ -711,6 +713,8 @@ export function ɵɵdeferHydrateOnInteraction() {
711713 // We are on the server and SSR for defer blocks is enabled.
712714 triggerDeferBlock ( lView , tNode ) ;
713715 }
716+ // The actual triggering of hydration on interaction is handled by JSAction in
717+ // event_replay.ts.
714718}
715719
716720/**
@@ -780,6 +784,8 @@ export function ɵɵdeferHydrateOnViewport() {
780784 // We are on the server and SSR for defer blocks is enabled.
781785 triggerDeferBlock ( lView , tNode ) ;
782786 }
787+ // The actual triggering of hydration on viewport happens in incremental.ts,
788+ // since these instructions won't exist for dehydrated content.
783789}
784790
785791/********** Helper functions **********/
@@ -853,7 +859,7 @@ export function scheduleDelayedHydrating(
853859 ( ) =>
854860 incrementallyHydrateFromBlockName (
855861 injector ,
856- lDetails [ UNIQUE_SSR_ID ] ! ,
862+ lDetails [ SSR_UNIQUE_ID ] ! ,
857863 ( deferBlock : DeferBlock ) => triggerAndWaitForCompletion ( deferBlock ) ,
858864 ) ,
859865 injector ,
@@ -896,7 +902,7 @@ export function renderDeferBlockState(
896902
897903 const currentState = lDetails [ DEFER_BLOCK_STATE ] ;
898904
899- const ssrState = lDetails [ SSR_STATE ] ;
905+ const ssrState = lDetails [ SSR_BLOCK_STATE ] ;
900906 if ( ssrState !== null && newState < ssrState ) {
901907 return ; // trying to render a previous state, exit
902908 }
0 commit comments