File tree Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Expand file tree Collapse file tree 4 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -38,8 +38,10 @@ export function startReactDsfr(params: {
3838 "doPersistDarkModePreferenceWithCookie" : false ,
3939 "registerEffectAction" : action => {
4040 if ( isAfterFirstEffect ) {
41+ console . log ( "We are after hydration, executing action now" ) ;
4142 action ( ) ;
4243 } else {
44+ console . log ( "action delayed to be executed on hydration" ) ;
4345 actions . push ( action ) ;
4446 }
4547 }
Original file line number Diff line number Diff line change @@ -131,8 +131,10 @@ export function createNextDsfrIntegrationApi(
131131 doPersistDarkModePreferenceWithCookie,
132132 "registerEffectAction" : action => {
133133 if ( isAfterFirstEffect ) {
134+ console . log ( "We are after hydration, executing action now" ) ;
134135 action ( ) ;
135136 } else {
137+ console . log ( "action delayed to be executed on hydration" ) ;
136138 actions . push ( action ) ;
137139 }
138140 }
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ export async function start(params: Params) {
3030 const registerEffectAction : ( action : ( ) => void ) => void =
3131 nextParams === undefined ? action => action ( ) : nextParams . registerEffectAction ;
3232
33+ console . log ( "startClientSideIsDarkLogic" , Date . now ( ) ) ;
34+
3335 startClientSideIsDarkLogic ( {
3436 "colorSchemeExplicitlyProvidedAsParameter" : defaultColorScheme ,
3537 "doPersistDarkModePreferenceWithCookie" :
@@ -39,9 +41,19 @@ export async function start(params: Params) {
3941
4042 ( window as any ) . dsfr = { verbose, "mode" : "manual" } ;
4143
44+ console . log ( "Start download DSFR js" , Date . now ( ) ) ;
45+
4246 await import ( "./dsfr/dsfr.module" as any ) ;
4347
48+ console . log ( "DSFR js downloaded" , Date . now ( ) ) ;
49+
4450 const { dsfr } = window as unknown as { dsfr : { start : ( ) => void } } ;
4551
46- registerEffectAction ( ( ) => dsfr . start ( ) ) ;
52+ console . log ( "registering action dsfr.start" , Date . now ( ) ) ;
53+
54+ registerEffectAction ( ( ) => {
55+ console . log ( "executing action dsfr.start" , Date . now ( ) ) ;
56+
57+ dsfr . start ( ) ;
58+ } ) ;
4759}
Original file line number Diff line number Diff line change @@ -100,6 +100,21 @@ export function startClientSideIsDarkLogic(params: {
100100 const isDarkFromHtmlAttribute = getCurrentIsDarkFromHtmlAttribute ( ) ;
101101
102102 if ( isDarkFromHtmlAttribute !== undefined ) {
103+ console . log (
104+ `We had html theme attribute window.ssrWasPerformedWithIsDark: ${ ( ( ) => {
105+ switch ( ( window as any ) . ssrWasPerformedWithIsDark as boolean | undefined ) {
106+ case true :
107+ return "true" ;
108+ case false :
109+ return "false" ;
110+ case undefined :
111+ return "undefined" ;
112+ default :
113+ return "other" ;
114+ }
115+ } ) ( ) } `
116+ ) ;
117+
103118 return {
104119 "clientSideIsDark" : isDarkFromHtmlAttribute ,
105120 "ssrWasPerformedWithIsDark" :
@@ -150,6 +165,13 @@ export function startClientSideIsDarkLogic(params: {
150165
151166 const isDarkFallback = false ;
152167
168+ console . log ( {
169+ isDarkExplicitlyProvidedAsParameter,
170+ isDarkFromLocalStorage,
171+ isDarkFromOsPreference,
172+ isDarkFallback
173+ } ) ;
174+
153175 return {
154176 "ssrWasPerformedWithIsDark" : isDarkExplicitlyProvidedAsParameter ?? isDarkFallback ,
155177 "clientSideIsDark" :
@@ -160,6 +182,8 @@ export function startClientSideIsDarkLogic(params: {
160182 } ;
161183 } ) ( ) ;
162184
185+ console . log ( { clientSideIsDark, ssrWasPerformedWithIsDark_ } ) ;
186+
163187 ssrWasPerformedWithIsDark = ssrWasPerformedWithIsDark_ ;
164188
165189 $clientSideIsDark . current = clientSideIsDark ;
You can’t perform that action at this time.
0 commit comments