@@ -13,10 +13,10 @@ import { mono_wasm_init_aot_profiler, mono_wasm_init_devtools_profiler, mono_was
13
13
import { initialize_marshalers_to_cs } from "./marshal-to-cs" ;
14
14
import { initialize_marshalers_to_js } from "./marshal-to-js" ;
15
15
import { init_polyfills_async } from "./polyfills" ;
16
- import { strings_init , utf8ToString } from "./strings" ;
16
+ import { strings_init , stringToUTF8Ptr , utf8ToString } from "./strings" ;
17
17
import { init_managed_exports } from "./managed-exports" ;
18
18
import { cwraps_internal } from "./exports-internal" ;
19
- import { CharPtr , EmscriptenModule , InstantiateWasmCallBack , InstantiateWasmSuccessCallback } from "./types/emscripten" ;
19
+ import { CharPtr , CharPtrPtr , EmscriptenModule , InstantiateWasmCallBack , InstantiateWasmSuccessCallback , VoidPtr } from "./types/emscripten" ;
20
20
import { wait_for_all_assets } from "./assets" ;
21
21
import { replace_linker_placeholders } from "./exports-binding" ;
22
22
import { endMeasure , MeasuredBlock , startMeasure } from "./profiler" ;
@@ -28,7 +28,7 @@ import { populateEmscriptenPool, mono_wasm_init_threads } from "./pthreads";
28
28
import { currentWorkerThreadEvents , dotnetPthreadCreated , initWorkerThreadEvents , monoThreadInfo } from "./pthreads" ;
29
29
import { mono_wasm_pthread_ptr , update_thread_info } from "./pthreads" ;
30
30
import { jiterpreter_allocate_tables } from "./jiterpreter-support" ;
31
- import { localHeapViewU8 , malloc } from "./memory" ;
31
+ import { localHeapViewU8 , malloc , setU32 } from "./memory" ;
32
32
import { assertNoProxies } from "./gc-handles" ;
33
33
import { runtimeList } from "./exports" ;
34
34
import { nativeAbort , nativeExit } from "./run" ;
@@ -617,7 +617,41 @@ export function mono_wasm_load_runtime (): void {
617
617
if ( ! loaderHelpers . isDebuggingSupported ( ) || ! runtimeHelpers . config . resources ! . pdb ) {
618
618
debugLevel = 0 ;
619
619
}
620
- cwraps . mono_wasm_load_runtime ( debugLevel ) ;
620
+
621
+ const runtimeConfigProperties = new Map < string , string > ( ) ;
622
+ if ( runtimeHelpers . config . runtimeConfig ?. runtimeOptions ?. configProperties ) {
623
+ for ( const [ key , value ] of Object . entries ( runtimeHelpers . config . runtimeConfig ?. runtimeOptions ?. configProperties ) ) {
624
+ runtimeConfigProperties . set ( key , "" + value ) ;
625
+ }
626
+ }
627
+ runtimeConfigProperties . set ( "APP_CONTEXT_BASE_DIRECTORY" , "/" ) ;
628
+ runtimeConfigProperties . set ( "RUNTIME_IDENTIFIER" , "browser-wasm" ) ;
629
+ const propertyCount = runtimeConfigProperties . size ;
630
+
631
+ const buffers :VoidPtr [ ] = [ ] ;
632
+ const appctx_keys = malloc ( 4 * runtimeConfigProperties . size ) as any as CharPtrPtr ;
633
+ const appctx_values = malloc ( 4 * runtimeConfigProperties . size ) as any as CharPtrPtr ;
634
+ buffers . push ( appctx_keys as any ) ;
635
+ buffers . push ( appctx_values as any ) ;
636
+
637
+ let position = 0 ;
638
+ for ( const [ key , value ] of runtimeConfigProperties . entries ( ) ) {
639
+ const keyPtr = stringToUTF8Ptr ( key ) ;
640
+ const valuePtr = stringToUTF8Ptr ( value ) ;
641
+ setU32 ( ( appctx_keys as any ) + ( position * 4 ) , keyPtr ) ;
642
+ setU32 ( ( appctx_values as any ) + ( position * 4 ) , valuePtr ) ;
643
+ position ++ ;
644
+ buffers . push ( keyPtr as any ) ;
645
+ buffers . push ( valuePtr as any ) ;
646
+ }
647
+
648
+ cwraps . mono_wasm_load_runtime ( debugLevel , propertyCount , appctx_keys , appctx_values ) ;
649
+
650
+ // free the buffers
651
+ for ( const buffer of buffers ) {
652
+ Module . _free ( buffer ) ;
653
+ }
654
+
621
655
endMeasure ( mark , MeasuredBlock . loadRuntime ) ;
622
656
623
657
} catch ( err : any ) {
0 commit comments