@@ -536,6 +536,13 @@ private void GenerateConfigFiles()
536
536
{
537
537
GenerateConfigFile ( "uno-config.js" , isModule : true ) ;
538
538
539
+ GenerateConfigFile ( "uno-config-script.js" , isModule : false ) ;
540
+ }
541
+
542
+ private void GenerateConfigFile ( string fileName , bool isModule )
543
+ {
544
+ var unoConfigJsPath = Path . Combine ( _intermediateAssetsPath , fileName ) ;
545
+
539
546
using ( var w = new StreamWriter ( unoConfigJsPath , false , _utf8Encoding ) )
540
547
{
541
548
var baseLookup = _shellMode == ShellMode . Node ? "" : $ "{ WebAppBasePath } { PackageAssetsFolder } /";
@@ -555,7 +562,7 @@ private void GenerateConfigFiles()
555
562
. Select ( f => f . GetMetadata ( "Link" )
556
563
. Replace ( "\\ " , "/" )
557
564
. Replace ( "wwwroot/" , "" ) )
558
- . Concat ( [ $ "uno-config.js" , "_framework/dotnet.boot.js" , "." ] ) ;
565
+ . Concat ( [ fileName , "_framework/dotnet.boot.js" , "." ] ) ;
559
566
560
567
var offlineFiles = enablePWA ? string . Join ( ", " , sanitizedOfflineFiles . Select ( f => $ "\" { WebAppBasePath } { f } \" ") ) : "" ;
561
568
@@ -618,7 +625,9 @@ private void GenerateConfigFiles()
618
625
AddEnvironmentVariable ( "UNO_BOOTSTRAP_LOG_PROFILER_OPTIONS" , LogProfilerOptions ) ;
619
626
}
620
627
621
- config . AppendLine ( "export { config };" ) ;
628
+ config . AppendLine ( isModule ?
629
+ "export { config };" :
630
+ $ "self.config = config;") ;
622
631
623
632
w . Write ( config . ToString ( ) ) ;
624
633
@@ -634,122 +643,6 @@ private void GenerateConfigFiles()
634
643
}
635
644
}
636
645
637
- private void GenerateConfigFile ( string fileName , bool isModule )
638
- {
639
- var self = isModule ? "" : "self." ;
640
-
641
- var unoConfigJsPath = Path . Combine ( _intermediateAssetsPath , fileName ) ;
642
-
643
- using ( var w = new StreamWriter ( unoConfigJsPath , false , _utf8Encoding ) )
644
- {
645
- var baseLookup = _shellMode == ShellMode . Node ? "" : $ "{ WebAppBasePath } { PackageAssetsFolder } /";
646
- var dependencies = string . Join ( ", " , _dependencies
647
- . Where ( d =>
648
- ! d . EndsWith ( "require.js" )
649
- && ! d . EndsWith ( "uno-bootstrap.js" )
650
- && ! d . EndsWith ( "service-worker.js" )
651
- && ! d . EndsWith ( "service-worker-classic.js" ) )
652
- . Select ( dep => BuildDependencyPath ( dep , baseLookup ) ) ) ;
653
-
654
- var config = new StringBuilder ( ) ;
655
-
656
- var enablePWA = ! string . IsNullOrEmpty ( PWAManifestFile ) ;
657
-
658
- var sanitizedOfflineFiles = StaticWebContent
659
- . Select ( f => f . GetMetadata ( "Link" )
660
- . Replace ( "\\ " , "/" )
661
- . Replace ( "wwwroot/" , "" ) )
662
- . Concat ( [ fileName , "_framework/blazor.boot.json" , "." ] ) ;
663
-
664
- var offlineFiles = enablePWA ? string . Join ( ", " , sanitizedOfflineFiles . Select ( f => $ "\" { WebAppBasePath } { f } \" ") ) : "" ;
665
-
666
- var emccExportedRuntimeMethodsParams = string . Join (
667
- "," ,
668
- GetEmccExportedRuntimeMethods ( ) . Select ( f => $ "\' { f } \' ") ) ;
669
-
670
- var runtimeOptionsSet = string . Join ( "," , ( RuntimeOptions ? . Split ( ' ' ) ?? [ ] ) . Select ( f => $ "\' { f } \' ") ) ;
671
-
672
-
673
- if ( isModule )
674
- {
675
- config . AppendLine ( $ "let config = {{}};") ;
676
- }
677
- else
678
- {
679
- config . AppendLine ( $ "{ self } config = {{}};") ;
680
- }
681
-
682
- config . AppendLine ( $ "{ self } config.uno_remote_managedpath = \" _framework\" ;") ;
683
- config . AppendLine ( $ "{ self } config.uno_app_base = \" { WebAppBasePath } { PackageAssetsFolder } \" ;") ;
684
- config . AppendLine ( $ "{ self } config.uno_dependencies = [{ dependencies } ];") ;
685
- config . AppendLine ( $ "{ self } config.uno_runtime_options = [{ runtimeOptionsSet } ];") ;
686
- config . AppendLine ( $ "{ self } config.enable_pwa = { enablePWA . ToString ( ) . ToLowerInvariant ( ) } ;") ;
687
- config . AppendLine ( $ "{ self } config.offline_files = ['{ WebAppBasePath } ', { offlineFiles } ];") ;
688
- config . AppendLine ( $ "{ self } config.uno_shell_mode = \" { _shellMode } \" ;") ;
689
- config . AppendLine ( $ "{ self } config.uno_debugging_enabled = { ( ! Optimize ) . ToString ( ) . ToLowerInvariant ( ) } ;") ;
690
- config . AppendLine ( $ "{ self } config.uno_enable_tracing = { EnableTracing . ToString ( ) . ToLowerInvariant ( ) } ;") ;
691
- config . AppendLine ( $ "{ self } config.uno_load_all_satellite_resources = { LoadAllSatelliteResources . ToString ( ) . ToLowerInvariant ( ) } ;") ;
692
- config . AppendLine ( $ "{ self } config.emcc_exported_runtime_methods = [{ emccExportedRuntimeMethodsParams } ];") ;
693
-
694
- if ( GenerateAOTProfile )
695
- {
696
- config . AppendLine ( $ "{ self } config.generate_aot_profile = true;") ;
697
- }
698
-
699
- config . AppendLine ( $ "{ self } config.environmentVariables = { self } config.environmentVariables || {{}};") ;
700
-
701
- void AddEnvironmentVariable ( string name , string value ) => config . AppendLine ( $ "{ self } config.environmentVariables[\" { name } \" ] = \" { value } \" ;") ;
702
-
703
- if ( MonoEnvironment != null )
704
- {
705
- foreach ( var env in MonoEnvironment )
706
- {
707
- AddEnvironmentVariable ( env . ItemSpec , env . GetMetadata ( "Value" ) ) ;
708
- }
709
- }
710
-
711
- var isProfiledAOT = UseAotProfile && _runtimeExecutionMode == RuntimeExecutionMode . InterpreterAndAOT ;
712
-
713
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_MONO_RUNTIME_MODE" , _runtimeExecutionMode . ToString ( ) ) ;
714
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_MONO_PROFILED_AOT" , isProfiledAOT . ToString ( ) ) ;
715
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_LINKER_ENABLED" , ( PublishTrimmed && RunILLink ) . ToString ( ) ) ;
716
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_DEBUGGER_ENABLED" , ( ! Optimize ) . ToString ( ) ) ;
717
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_MONO_RUNTIME_CONFIGURATION" , "Release" ) ;
718
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_MONO_RUNTIME_FEATURES" , BuildRuntimeFeatures ( ) ) ;
719
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_APP_BASE" , PackageAssetsFolder ) ;
720
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_WEBAPP_BASE_PATH" , WebAppBasePath ) ;
721
-
722
- if ( EmccFlags ? . Any ( f => f . ItemSpec ? . Contains ( "MAXIMUM_MEMORY=4GB" ) ?? false ) ?? false )
723
- {
724
- // Detects the use of the 4GB flag: https://v8.dev/blog/4gb-wasm-memory
725
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_EMSCRIPTEN_MAXIMUM_MEMORY" , "4GB" ) ;
726
- }
727
-
728
- if ( EnableLogProfiler )
729
- {
730
- AddEnvironmentVariable ( "UNO_BOOTSTRAP_LOG_PROFILER_OPTIONS" , LogProfilerOptions ) ;
731
- }
732
-
733
- if ( isModule )
734
- {
735
- config . AppendLine ( "export { config };" ) ;
736
- }
737
-
738
- w . Write ( config . ToString ( ) ) ;
739
-
740
- TaskItem indexMetadata = new (
741
- unoConfigJsPath , new Dictionary < string , string >
742
- {
743
- [ "CopyToOutputDirectory" ] = "PreserveNewest" ,
744
- [ "ContentRoot" ] = _intermediateAssetsPath ,
745
- [ "Link" ] = $ "wwwroot/{ PackageAssetsFolder } /" + Path . GetFileName ( unoConfigJsPath ) ,
746
- } ) ;
747
-
748
- StaticWebContent = StaticWebContent . Concat ( [ indexMetadata ] ) . ToArray ( ) ;
749
- }
750
- }
751
-
752
-
753
646
private void GenerateIndexHtml ( )
754
647
{
755
648
if ( _shellMode != ShellMode . Browser )
0 commit comments