11/* eslint-disable import/no-mutable-exports */
22// eslint-disable-next-line
3- import Framework7 from 'framework7/lite' ;
43import { extend , unsetRouterIds } from './utils.js' ;
54
65let f7 ;
76const theme = { } ;
87
9- // eslint-disable-next-line
10- if ( ! Framework7 . __app__ ) {
11- // eslint-disable-next-line
12- Framework7 . __app__ = {
13- f7 : undefined ,
14- f7events : undefined ,
15- theme : { } ,
16- f7routers : {
17- views : [ ] ,
18- tabs : [ ] ,
19- modals : null ,
20- } ,
21- } ;
8+ /* eslint-disable no-restricted-globals */
9+ const app =
10+ typeof window !== 'undefined' && window . Framework7ComponentsApp
11+ ? window . Framework7ComponentsApp
12+ : {
13+ Framework7 : undefined ,
14+ f7 : undefined ,
15+ f7events : undefined ,
16+ theme : { } ,
17+ f7routers : {
18+ views : [ ] ,
19+ tabs : [ ] ,
20+ modals : null ,
21+ } ,
22+ } ;
23+ if ( typeof window !== 'undefined' ) {
24+ window . Framework7ComponentsApp = app ;
2225}
23-
24- const { __app__ : app } = Framework7 ;
26+ /* eslint-enable no-restricted-globals */
2527
2628app . setInstance = ( instance ) => {
2729 f7 = instance ;
@@ -51,7 +53,7 @@ const cleanup = () => {
5153} ;
5254
5355const f7initEvents = ( ) => {
54- app . f7events = new Framework7 . Events ( ) ;
56+ app . f7events = new app . Framework7 . Events ( ) ;
5557} ;
5658
5759const f7init = ( rootEl , params = { } , init = true ) => {
@@ -63,7 +65,7 @@ const f7init = (rootEl, params = {}, init = true) => {
6365 if ( ! f7Params . routes ) f7Params . routes = [ ] ;
6466
6567 if ( f7Params . userAgent && ( f7Params . theme === 'auto' || ! f7Params . theme ) ) {
66- const device = Framework7 . getDevice ( { userAgent : f7Params . userAgent } , true ) ;
68+ const device = app . Framework7 . getDevice ( { userAgent : f7Params . userAgent } , true ) ;
6769 app . theme . ios = ! ! device . ios ;
6870 app . theme . aurora = device . desktop && device . electron ;
6971 app . theme . md = ! app . theme . ios && ! app . theme . aurora ;
@@ -74,7 +76,7 @@ const f7init = (rootEl, params = {}, init = true) => {
7476 // eslint-disable-next-line
7577 if ( typeof window === 'undefined' ) cleanup ( ) ;
7678
77- const instance = new Framework7 ( f7Params ) ;
79+ const instance = new app . Framework7 ( f7Params ) ;
7880 app . f7 = instance ;
7981 f7 = instance ;
8082 app . setInstance ( instance ) ;
0 commit comments