1
+ import merge from "@ui5/webcomponents-utils/dist/sap/base/util/merge.js" ;
2
+ import { getFeature } from "./FeaturesRegistry.js" ;
3
+
1
4
let initialized = false ;
2
5
3
- const initialConfig = {
6
+ let initialConfig = {
4
7
animationMode : "full" ,
5
8
theme : "sap_fiori_3" ,
6
9
rtl : null ,
@@ -50,8 +53,6 @@ const booleanMapping = new Map();
50
53
booleanMapping . set ( "true" , true ) ;
51
54
booleanMapping . set ( "false" , false ) ;
52
55
53
- let runtimeConfig = { } ;
54
-
55
56
const parseConfigurationScript = ( ) => {
56
57
const configScript = document . querySelector ( "[data-ui5-config]" ) || document . querySelector ( "[data-id='sap-ui-config']" ) ; // for backward compatibility
57
58
@@ -65,7 +66,7 @@ const parseConfigurationScript = () => {
65
66
}
66
67
67
68
if ( configJSON ) {
68
- runtimeConfig = Object . assign ( { } , configJSON ) ;
69
+ initialConfig = merge ( initialConfig , configJSON ) ;
69
70
}
70
71
}
71
72
} ;
@@ -86,24 +87,34 @@ const parseURLParameters = () => {
86
87
value = booleanMapping . get ( lowerCaseValue ) ;
87
88
}
88
89
89
- runtimeConfig [ param ] = value ;
90
+ initialConfig [ param ] = value ;
90
91
} ) ;
91
92
} ;
92
93
93
- const applyConfigurations = ( ) => {
94
- Object . keys ( runtimeConfig ) . forEach ( key => {
95
- initialConfig [ key ] = runtimeConfig [ key ] ;
96
- } ) ;
94
+ const applyOpenUI5Configuration = ( ) => {
95
+ const OpenUI5Support = getFeature ( "OpenUI5Support" ) ;
96
+ if ( ! OpenUI5Support || ! OpenUI5Support . isLoaded ( ) ) {
97
+ return ;
98
+ }
99
+
100
+ const OpenUI5Config = OpenUI5Support . getConfigurationSettingsObject ( ) ;
101
+ initialConfig = merge ( initialConfig , OpenUI5Config ) ;
97
102
} ;
98
103
104
+
99
105
const initConfiguration = ( ) => {
100
106
if ( initialized ) {
101
107
return ;
102
108
}
103
109
110
+ // 1. Lowest priority - configuration script
104
111
parseConfigurationScript ( ) ;
112
+
113
+ // 2. URL parameters overwrite configuration script parameters
105
114
parseURLParameters ( ) ;
106
- applyConfigurations ( ) ;
115
+
116
+ // 3. If OpenUI5 is detected, it has the highest priority
117
+ applyOpenUI5Configuration ( ) ;
107
118
108
119
initialized = true ;
109
120
} ;
0 commit comments