@@ -150,9 +150,9 @@ impl<R: Runtime> WebviewManager<R> {
150150 }
151151 . render_default ( & Default :: default ( ) ) ?;
152152
153- webview_attributes = webview_attributes
154- . initialization_script (
155- r"
153+ let mut all_initialization_scripts : Vec < String > = vec ! [ ] ;
154+ all_initialization_scripts . push (
155+ r"
156156 Object.defineProperty(window, 'isTauri', {
157157 value: true,
158158 });
@@ -164,51 +164,60 @@ impl<R: Runtime> WebviewManager<R> {
164164 }
165165 })
166166 }
167- " ,
168- )
169- . initialization_script ( & self . invoke_initialization_script )
170- . initialization_script ( & format ! (
171- r#"
167+ "
168+ . to_string ( ) ,
169+ ) ;
170+ all_initialization_scripts. push ( self . invoke_initialization_script . to_string ( ) ) ;
171+ all_initialization_scripts. push ( format ! (
172+ r#"
172173 Object.defineProperty(window.__TAURI_INTERNALS__, 'metadata', {{
173174 value: {{
174175 currentWindow: {{ label: {current_window_label} }},
175176 currentWebview: {{ label: {current_webview_label} }}
176177 }}
177178 }})
178179 "# ,
179- current_window_label = serde_json:: to_string( window_label) ?,
180- current_webview_label = serde_json:: to_string( & label) ?,
181- ) )
182- . initialization_script ( & self . initialization_script (
183- app_manager,
184- & ipc_init. into_string ( ) ,
185- & pattern_init. into_string ( ) ,
186- is_init_global,
187- use_https_scheme,
188- ) ?) ;
180+ current_window_label = serde_json:: to_string( window_label) ?,
181+ current_webview_label = serde_json:: to_string( & label) ?,
182+ ) ) ;
183+ all_initialization_scripts. push (
184+ self
185+ . initialization_script (
186+ app_manager,
187+ & ipc_init. into_string ( ) ,
188+ & pattern_init. into_string ( ) ,
189+ is_init_global,
190+ use_https_scheme,
191+ ) ?
192+ . to_string ( ) ,
193+ ) ;
189194
190195 for plugin_init_script in plugin_init_scripts {
191- webview_attributes = webview_attributes . initialization_script ( & plugin_init_script) ;
196+ all_initialization_scripts . push ( plugin_init_script. to_string ( ) ) ;
192197 }
193198
194199 #[ cfg( feature = "isolation" ) ]
195200 if let crate :: Pattern :: Isolation { schema, .. } = & * app_manager. pattern {
196- webview_attributes = webview_attributes . initialization_script (
197- & IsolationJavascript {
201+ all_initialization_scripts . push (
202+ IsolationJavascript {
198203 isolation_src : & crate :: pattern:: format_real_schema ( schema, use_https_scheme) ,
199204 style : tauri_utils:: pattern:: isolation:: IFRAME_STYLE ,
200205 }
201206 . render_default ( & Default :: default ( ) ) ?
202- . into_string ( ) ,
207+ . to_string ( ) ,
203208 ) ;
204209 }
205210
206211 if let Some ( plugin_global_api_scripts) = & * app_manager. plugin_global_api_scripts {
207212 for script in plugin_global_api_scripts. iter ( ) {
208- webview_attributes = webview_attributes . initialization_script ( script) ;
213+ all_initialization_scripts . push ( script. to_string ( ) ) ;
209214 }
210215 }
211216
217+ webview_attributes
218+ . initialization_scripts
219+ . splice ( 0 ..0 , all_initialization_scripts) ;
220+
212221 pending. webview_attributes = webview_attributes;
213222
214223 let mut registered_scheme_protocols = Vec :: new ( ) ;
0 commit comments