@@ -2,11 +2,11 @@ import { isBrowser } from "./tools/isBrowser";
22import { assert } from "tsafe/assert" ;
33import type { ColorScheme } from "./useIsDark" ;
44import { startClientSideIsDarkLogic } from "./useIsDark/client" ;
5+ import { Deferred } from "./tools/Deferred" ;
56
67type Params = {
78 defaultColorScheme : ColorScheme | "system" ;
89 verbose : boolean ;
9- eulerianAnalytics : EulerianAnalytics | undefined ;
1010 nextParams :
1111 | {
1212 doPersistDarkModePreferenceWithCookie : boolean ;
@@ -18,7 +18,7 @@ type Params = {
1818let isStarted = false ;
1919
2020export async function start ( params : Params ) {
21- const { defaultColorScheme, verbose, nextParams, eulerianAnalytics } = params ;
21+ const { defaultColorScheme, verbose, nextParams } = params ;
2222
2323 assert ( isBrowser ) ;
2424
@@ -38,89 +38,23 @@ export async function start(params: Params) {
3838 registerEffectAction
3939 } ) ;
4040
41- ( window as any ) . dsfr = {
41+ // @ts -expect-error
42+ window . dsfr = {
4243 verbose,
43- "mode" : "react" ,
44- "analytics" : eulerianAnalytics
44+ "mode" : "react"
4545 } ;
4646
47- await import ( "./dsfr/dsfr.module" as any ) ;
47+ // @ts -expect-error
48+ await import ( "./dsfr/dsfr.module.min" ) ;
4849
49- if ( eulerianAnalytics !== undefined ) {
50- await import ( "./dsfr/analytics/analytics.module.js" as any ) ;
51- }
52-
53- const { dsfr } = window as unknown as { dsfr : { start : ( ) => void } } ;
50+ dDsfrLoaded . resolve ( ) ;
5451
55- registerEffectAction ( ( ) => dsfr . start ( ) ) ;
52+ registerEffectAction ( ( ) => {
53+ // @ts -expect-error
54+ window . dsfr . start ( ) ;
55+ } ) ;
5656}
5757
58- export type EulerianAnalytics = {
59- domain : string ;
60- /** default: false */
61- enableRating ?: boolean ;
62- page ?: Partial < {
63- path : string ; // path for page tracking
64- referrer : string ; // referrer for virtual pages (not for real page, eulerian automatically collects document.referrer)
65- id : string ; // unique page id (string)
66- title : string ; // page title for virtual pages
67- name : string ; // equivalent to title if not defined
68- author : string ; // page author name
69- date : string ; // page creation date
70- labels : string [ ] ;
71- tags : string [ ] ; // no tags limit
72- template : string ; // page template
73- group : string ; // page group. if not defined, fallback to template value
74- segment : string ; // site segment. if not defined, fallback to template value
75- subtemplate : string ; // page subtemplate
76- theme : string ; // page theme
77- subtheme : string ; // page subtheme
78- related : string ; // related page id
79- depth : number ; // page depth
80- isError : boolean ; // is this an error page (404, 500, 503...)
81- current : number ; // In case of pagination, current page number
82- total : number ; // In case of pagination, total pages number
83- filters : string ; // array of filters that were applied on the page (strings)
84- } > ;
85- site ?: Partial < {
86- environment : "development" | "stage" | "production" ; // by default development ['development', 'stage', 'production']
87- entity : string ; // Entity responsible for website
88- language : string ; // language of the website (ISO 639-1). default to html lang
89- target : string ; // site target
90- type : string ; // site type
91- region : string ; // region of the website (ISO 3166-2:FR)
92- department : string ; // department of the website (ISO 3166-2:FR)
93- } > ;
94- user ?: Partial < {
95- connect : {
96- uid : string ; // user id - required when connected
97- email : string ; // encoded user email - required when connected
98- isNew : boolean ; // user just registered
99- } ;
100- profile : string ; // user profile
101- language : string ;
102- type : string ;
103- } > ;
104- search ?: Partial < {
105- engine : string ;
106- results : number ;
107- terms : string ;
108- category : string ;
109- theme : string ;
110- type : string ;
111- method : string ;
112- } > ;
113- funnel ?: Partial < {
114- id : string ;
115- type : string ;
116- name : string ;
117- step : string ; // step name
118- current : number ; // step number
119- total : number ; // total number of steps
120- objective : string ; // form objective
121- error : string ; // form's error type
122- } > ;
123- cmp ?: Partial < {
124- id : string ;
125- } > ;
126- } ;
58+ const dDsfrLoaded = new Deferred < void > ( ) ;
59+
60+ export const prDsfrLoaded = dDsfrLoaded . pr ;
0 commit comments