diff --git a/.gitattributes b/.gitattributes
index a25b1f94d6e..a3a9aba9074 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -76,3 +76,4 @@ src/tests/JIT/Performance/CodeQuality/BenchmarksGame/reverse-complement/revcomp-
src/tests/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/knucleotide-input.txt text eol=lf
src/tests/JIT/Performance/CodeQuality/BenchmarksGame/k-nucleotide/knucleotide-input-big.txt text eol=lf
src/mono/wasm/runtime/dotnet.d.ts text eol=lf
+src/mono/wasm/runtime/dotnet-legacy.d.ts text eol=lf
diff --git a/.gitignore b/.gitignore
index 28326fe3f5e..7317c06261a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -188,6 +188,8 @@ node_modules/
*.metaproj.tmp
bin.localpkg/
src/mono/wasm/runtime/dotnet.d.ts.sha256
+src/mono/wasm/runtime/dotnet-legacy.d.ts.sha256
+
src/mono/sample/wasm/browser-nextjs/public/
# RIA/Silverlight projects
diff --git a/eng/liveBuilds.targets b/eng/liveBuilds.targets
index 44a60fce233..0da788b3c27 100644
--- a/eng/liveBuilds.targets
+++ b/eng/liveBuilds.targets
@@ -181,6 +181,7 @@
$(LibrariesNativeArtifactsPath)dotnet.js;
$(LibrariesNativeArtifactsPath)src\dotnet-crypto-worker.js;
$(LibrariesNativeArtifactsPath)dotnet.d.ts;
+ $(LibrariesNativeArtifactsPath)dotnet-legacy.d.ts;
$(LibrariesNativeArtifactsPath)package.json;
$(LibrariesNativeArtifactsPath)dotnet.wasm;
$(LibrariesNativeArtifactsPath)dotnet.js.symbols;
diff --git a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props
index 42c107d012c..b9cc3a522b4 100644
--- a/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props
+++ b/src/installer/pkg/sfx/Microsoft.NETCore.App/Directory.Build.props
@@ -218,6 +218,7 @@
+
diff --git a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/MemoryTests.cs b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/MemoryTests.cs
index d7027fe0b95..70eb88b1a55 100644
--- a/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/MemoryTests.cs
+++ b/src/libraries/System.Private.Runtime.InteropServices.JavaScript/tests/System/Runtime/InteropServices/JavaScript/MemoryTests.cs
@@ -26,8 +26,8 @@ namespace System.Runtime.InteropServices.JavaScript.Tests
long dummy = 0xA6A6A6A6L;
long actual2 = dummy;
var bagFn = new Function("ptr", "ptr2", @"
- const value=globalThis.App.MONO.getI52(ptr);
- globalThis.App.MONO.setI52(ptr2, value);
+ const value=globalThis.App.runtime.getHeapI52(ptr);
+ globalThis.App.runtime.setHeapI52(ptr2, value);
return ''+value;");
uint ptr = (uint)Unsafe.AsPointer(ref expected);
@@ -53,8 +53,8 @@ namespace System.Runtime.InteropServices.JavaScript.Tests
ulong dummy = 0xA6A6A6A6UL;
ulong actual2 = dummy;
var bagFn = new Function("ptr", "ptr2", @"
- const value=globalThis.App.MONO.getI52(ptr);
- globalThis.App.MONO.setU52(ptr2, value);
+ const value=globalThis.App.runtime.getHeapI52(ptr);
+ globalThis.App.runtime.setHeapU52(ptr2, value);
return ''+value;");
uint ptr = (uint)Unsafe.AsPointer(ref expected);
@@ -99,14 +99,14 @@ namespace System.Runtime.InteropServices.JavaScript.Tests
long actual = 0;
uint ptr = (uint)Unsafe.AsPointer(ref actual);
var bagFn = new Function("ptr", "value", @"
- globalThis.App.MONO.setI52(ptr, value);");
+ globalThis.App.runtime.setHeapI52(ptr, value);");
var ex=Assert.Throws(() => bagFn.Call(null, ptr, value));
Assert.Contains("Value is not a safe integer", ex.Message);
double expectedD = value;
uint ptrD = (uint)Unsafe.AsPointer(ref expectedD);
var bagFnD = new Function("ptr", "value", @"
- globalThis.App.MONO.getI52(ptr);");
+ globalThis.App.runtime.getHeapI52(ptr);");
var exD = Assert.Throws(() => bagFn.Call(null, ptr, value));
Assert.Contains("Value is not a safe integer", ex.Message);
}
@@ -118,14 +118,14 @@ namespace System.Runtime.InteropServices.JavaScript.Tests
long actual = 0;
uint ptr = (uint)Unsafe.AsPointer(ref actual);
var bagFn = new Function("ptr", "value", @"
- globalThis.App.MONO.setU52(ptr, value);");
+ globalThis.App.runtime.setHeapU52(ptr, value);");
var ex=Assert.Throws(() => bagFn.Call(null, ptr, value));
Assert.Contains("Can't convert negative Number into UInt64", ex.Message);
double expectedD = value;
uint ptrD = (uint)Unsafe.AsPointer(ref expectedD);
var bagFnD = new Function("ptr", "value", @"
- globalThis.App.MONO.getU52(ptr);");
+ globalThis.App.runtime.getHeapU52(ptr);");
var exD = Assert.Throws(() => bagFn.Call(null, ptr, value));
Assert.Contains("Can't convert negative Number into UInt64", ex.Message);
}
@@ -136,7 +136,7 @@ namespace System.Runtime.InteropServices.JavaScript.Tests
long actual = 0;
uint ptr = (uint)Unsafe.AsPointer(ref actual);
var bagFn = new Function("ptr", "value", @"
- globalThis.App.MONO.setI52(ptr, value);");
+ globalThis.App.runtime.setHeapI52(ptr, value);");
var ex=Assert.Throws(() => bagFn.Call(null, ptr, double.NaN));
Assert.Contains("Value is not a safe integer: NaN (number)", ex.Message);
}
diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs
index c0aa35fed87..d2916b4e9c7 100644
--- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs
+++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/Interop/JavaScriptExports.cs
@@ -117,7 +117,7 @@ namespace System.Runtime.InteropServices.JavaScript
{
}
- // Called by the AOT profiler to save profile data into INTERNAL.aot_profile_data
+ // Called by the AOT profiler to save profile data into INTERNAL.aotProfileData
[MethodImpl(MethodImplOptions.NoInlining)] // https://github.com/dotnet/runtime/issues/71425
public static unsafe void DumpAotProfileData(ref byte buf, int len, string extraArg)
{
@@ -133,7 +133,7 @@ namespace System.Runtime.InteropServices.JavaScript
if (module == null)
throw new InvalidOperationException();
- module.SetProperty("aot_profile_data", span.ToArray());
+ module.SetProperty("aotProfileData", span.ToArray());
}
}
}
diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSImportAttribute.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSImportAttribute.cs
index 05704d60499..2fe067921fb 100644
--- a/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSImportAttribute.cs
+++ b/src/libraries/System.Runtime.InteropServices.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSImportAttribute.cs
@@ -20,8 +20,6 @@ namespace System.Runtime.InteropServices.JavaScript
/// public static partial int librarySum(int a, int b);
/// [JSImport("Math.sum", "my-math-helper")]
/// public static partial int libraryNamespaceSum(int a, int b);
- /// [JSImport("IMPORTS.sum")]
- /// public static partial int runtimeImportsSum(int a, int b);
/// [JSImport("globalThis.Math.sum")]
/// public static partial int globalSum(int a, int b);
///
@@ -31,7 +29,7 @@ namespace System.Runtime.InteropServices.JavaScript
public sealed class JSImportAttribute : Attribute
{
///
- /// The name of the target JavaScript function. This name will be used as a key to locate the function in the IMPORTS JavaScript object owned by the runtime.
+ /// The name of the target JavaScript function. This name will be used as a key to locate the function in the module.
/// Functions nested inside of objects can be referred to by using the dot operator to connect one or more names.
///
public string FunctionName { get; }
@@ -44,7 +42,7 @@ namespace System.Runtime.InteropServices.JavaScript
///
/// Initializes a new instance of the .
///
- /// Name of the function to be bound in the IMPORTS object of the runtime instance in the JavaScript page. It allows dots for nested objects.
+ /// Name of the function to be bound in the module. It allows dots for nested objects.
public JSImportAttribute(string functionName)
{
FunctionName = functionName;
@@ -54,7 +52,7 @@ namespace System.Runtime.InteropServices.JavaScript
/// Initializes a new instance of the .
///
///
- /// The name of the target JavaScript function. This name will be used as a key to locate the function in the IMPORTS JavaScript object owned by the runtime.
+ /// The name of the target JavaScript function. This name will be used as a key to locate the function in the module.
/// Functions nested inside of objects can be referred to by using the dot operator to connect one or more names.
///
///
diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.cs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.cs
index 47501520abc..aaa5d16c2b8 100644
--- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.cs
+++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.cs
@@ -918,6 +918,9 @@ namespace System.Runtime.InteropServices.JavaScript.Tests
}
#endregion JSObject
+ [JSImport("setup", "JavaScriptTestHelper")]
+ internal static partial Task Setup();
+
static JSObject _module;
public static async Task InitializeAsync()
{
@@ -925,6 +928,7 @@ namespace System.Runtime.InteropServices.JavaScript.Tests
{
// Log("JavaScriptTestHelper.mjs importing");
_module = await JSHost.ImportAsync("JavaScriptTestHelper", "./JavaScriptTestHelper.mjs");
+ await Setup();
// Log("JavaScriptTestHelper.mjs imported");
}
}
diff --git a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.mjs b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.mjs
index c6494638b67..c3cc24ed739 100644
--- a/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.mjs
+++ b/src/libraries/System.Runtime.InteropServices.JavaScript/tests/System.Runtime.InteropServices.JavaScript.UnitTests/System/Runtime/InteropServices/JavaScript/JavaScriptTestHelper.mjs
@@ -5,8 +5,8 @@ class JSData {
constructor(name) {
this.name = name;
}
- echoMemberMethod(arg1){
- return arg1 + "-w-i-t-h-"+ this.name;
+ echoMemberMethod(arg1) {
+ return arg1 + "-w-i-t-h-" + this.name;
}
toString() {
return `JSData("${this.name}")`;
@@ -146,14 +146,14 @@ export function getClass1() {
// console.log(`getClass1(arg1:${cname !== null ? cname : ''})`)
return cname;
}
-
+let dllExports;
export function invoke1(arg1, name) {
if (globalThis.gc) {
// console.log('globalThis.gc');
globalThis.gc();
}
// console.log(`invoke1: ${name}(arg1:${arg1 !== null ? typeof arg1 : ''})`)
- const JavaScriptTestHelper = globalThis.App.EXPORTS.System.Runtime.InteropServices.JavaScript.Tests.JavaScriptTestHelper
+ const JavaScriptTestHelper = dllExports.System.Runtime.InteropServices.JavaScript.Tests.JavaScriptTestHelper;
const fn = JavaScriptTestHelper[name];
// console.log("invoke1:" + typeof fn);
@@ -164,8 +164,7 @@ export function invoke1(arg1, name) {
}
export function invoke2(arg1, name) {
- const JavaScriptTestHelperNoNamespace = globalThis.App.EXPORTS.JavaScriptTestHelperNoNamespace
- const fn = JavaScriptTestHelperNoNamespace[name];
+ const fn = dllExports.JavaScriptTestHelperNoNamespace[name];
//console.log("invoke1:" + fn.toString());
const res = fn(arg1);
// console.log(`invoke1: res ${res !== null ? typeof res : ''}`)
@@ -272,5 +271,8 @@ globalThis.rebound = {
echoMemberMethod: globalThis.data.echoMemberMethod.bind(globalThis.data)
}
+export async function setup() {
+ dllExports = await App.runtime.getAssemblyExports("System.Runtime.InteropServices.JavaScript.Tests.dll");
+}
// console.log('JavaScriptTestHelper:' Object.keys(globalThis.JavaScriptTestHelper));
diff --git a/src/mono/sample/mbr/browser/main.js b/src/mono/sample/mbr/browser/main.js
index 4ea89023335..11d83de7f5d 100644
--- a/src/mono/sample/mbr/browser/main.js
+++ b/src/mono/sample/mbr/browser/main.js
@@ -3,8 +3,8 @@ import createDotnetRuntime from './dotnet.js'
try {
const { BINDING } = await createDotnetRuntime(({ MONO }) => ({
configSrc: "./mono-config.json",
- onConfigLoaded: () => {
- MONO.config.environment_variables["DOTNET_MODIFIABLE_ASSEMBLIES"] = "debug";
+ onConfigLoaded: (config) => {
+ config.environmentVariables["DOTNET_MODIFIABLE_ASSEMBLIES"] = "debug";
},
}));
const update = BINDING.bind_static_method("[WasmDelta] Sample.Test:Update");
diff --git a/src/mono/sample/wasm/browser-bench/frame-main.js b/src/mono/sample/wasm/browser-bench/frame-main.js
index 0d189ff66a8..bf767c9e7eb 100644
--- a/src/mono/sample/wasm/browser-bench/frame-main.js
+++ b/src/mono/sample/wasm/browser-bench/frame-main.js
@@ -6,28 +6,31 @@
import createDotnetRuntime from './dotnet.js'
class FrameApp {
- async init({ MONO }) {
- const exports = await MONO.mono_wasm_get_assembly_exports("Wasm.Browser.Bench.Sample.dll");
+ async init({ getAssemblyExports }) {
+ const exports = await getAssemblyExports("Wasm.Browser.Bench.Sample.dll");
exports.Sample.AppStartTask.FrameApp.ReachedManaged();
}
reachedCallback() {
- window.parent.resolveAppStartEvent("reached");
+ if (window.parent != window) {
+ window.parent.resolveAppStartEvent("reached");
+ }
}
}
+let mute = false;
try {
globalThis.frameApp = new FrameApp();
globalThis.frameApp.ReachedCallback = globalThis.frameApp.reachedCallback.bind(globalThis.frameApp);
-
- let mute = false;
- window.addEventListener("pageshow", event => { window.parent.resolveAppStartEvent("pageshow"); })
+ if (window.parent != window) {
+ window.addEventListener("pageshow", event => { window.parent.resolveAppStartEvent("pageshow"); })
+ }
window.muteErrors = () => {
mute = true;
}
- const { MONO } = await createDotnetRuntime(() => ({
+ const runtime = await createDotnetRuntime(() => ({
disableDotnet6Compatibility: true,
configSrc: "./mono-config.json",
printErr: function () {
@@ -36,16 +39,20 @@ try {
}
},
onConfigLoaded: () => {
- window.parent.resolveAppStartEvent("onConfigLoaded");
- // Module.config.diagnostic_tracing = true;
+ if (window.parent != window) {
+ window.parent.resolveAppStartEvent("onConfigLoaded");
+ }
+ // Module.config.diagnosticTracing = true;
},
onAbort: (error) => {
wasm_exit(1, error);
},
}));
- window.parent.resolveAppStartEvent("onDotnetReady");
- await frameApp.init({ MONO });
+ if (window.parent != window) {
+ window.parent.resolveAppStartEvent("onDotnetReady");
+ }
+ await frameApp.init(runtime);
}
catch (err) {
if (!mute) {
diff --git a/src/mono/sample/wasm/browser-bench/main.js b/src/mono/sample/wasm/browser-bench/main.js
index f76e7bb6d5a..d45c4e7aa51 100644
--- a/src/mono/sample/wasm/browser-bench/main.js
+++ b/src/mono/sample/wasm/browser-bench/main.js
@@ -10,8 +10,8 @@ let setTasks;
let getFullJsonResults;
class MainApp {
- async init({ MONO }) {
- const exports = await MONO.mono_wasm_get_assembly_exports("Wasm.Browser.Bench.Sample.dll");
+ async init({ getAssemblyExports }) {
+ const exports = await getAssemblyExports("Wasm.Browser.Bench.Sample.dll");
runBenchmark = exports.Sample.Test.RunBenchmark;
setTasks = exports.Sample.Test.SetTasks;
getFullJsonResults = exports.Sample.Test.GetFullJsonResults;
@@ -94,14 +94,14 @@ try {
globalThis.mainApp.FrameReachedManaged = globalThis.mainApp.frameReachedManaged.bind(globalThis.mainApp);
globalThis.mainApp.PageShow = globalThis.mainApp.pageShow.bind(globalThis.mainApp);
- const { MONO } = await createDotnetRuntime(() => ({
+ const runtime = await createDotnetRuntime(() => ({
disableDotnet6Compatibility: true,
configSrc: "./mono-config.json",
onAbort: (error) => {
wasm_exit(1, error);
}
}));
- await mainApp.init({ MONO });
+ await mainApp.init(runtime);
}
catch (err) {
wasm_exit(1, err);
diff --git a/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj b/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj
index 49f5718f129..f3feef21cce 100644
--- a/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj
+++ b/src/mono/sample/wasm/browser-eventpipe/Wasm.Browser.EventPipe.Sample.csproj
@@ -20,23 +20,23 @@
-
-
-
-
diff --git a/src/mono/sample/wasm/browser-mt-eventpipe/Wasm.Browser.ThreadsEP.Sample.csproj b/src/mono/sample/wasm/browser-mt-eventpipe/Wasm.Browser.ThreadsEP.Sample.csproj
index 4e097628df9..514d8ca176e 100644
--- a/src/mono/sample/wasm/browser-mt-eventpipe/Wasm.Browser.ThreadsEP.Sample.csproj
+++ b/src/mono/sample/wasm/browser-mt-eventpipe/Wasm.Browser.ThreadsEP.Sample.csproj
@@ -13,7 +13,7 @@
- {
+ const { MONO, BINDING, Module, runtimeBuildInfo } = await createDotnetRuntime(() => {
console.log('user code in createDotnetRuntime')
return {
disableDotnet6Compatibility: true,
@@ -40,7 +40,7 @@ async function main() {
try {
const testMeaning = BINDING.bind_static_method("[Wasm.Browser.ThreadsEP.Sample] Sample.Test:TestMeaning");
const ret = testMeaning();
- document.getElementById("out").innerHTML = `${ret} as computed on dotnet ver ${RuntimeBuildInfo.ProductVersion}`;
+ document.getElementById("out").innerHTML = `${ret} as computed on dotnet ver ${runtimeBuildInfo.productVersion}`;
console.debug(`ret: ${ret}`);
diff --git a/src/mono/sample/wasm/browser-profile/README.md b/src/mono/sample/wasm/browser-profile/README.md
index 08bedff4756..9d7327a6308 100644
--- a/src/mono/sample/wasm/browser-profile/README.md
+++ b/src/mono/sample/wasm/browser-profile/README.md
@@ -14,8 +14,8 @@
```
await createDotnetRuntime(() => ({
onConfigLoaded: () => {
- if (config.enable_profiler) {
- config.aot_profiler_options = {
+ if (config.enableProfiler) {
+ config.aotProfilerOptions = {
write_at: "",
send_to: "System.Runtime.InteropServices.JavaScript.JavaScriptExports::DumpAotProfileData"
}
@@ -28,14 +28,14 @@ await createDotnetRuntime(() => ({
`BINDING.bind_static_method("<[ProjectName] Namespace.Class::StopProfile">)();`
-When the `write_at` method is called, the `send_to` method `DumpAotProfileData` stores the profile data into `INTERNAL.aot_profile_data`
+When the `write_at` method is called, the `send_to` method `DumpAotProfileData` stores the profile data into `INTERNAL.aotProfileData`
-4. Download `INTERNAL.aot_profile_data` in JS, using something similar to:
+4. Download `INTERNAL.aotProfileData` in JS, using something similar to:
```
function saveProfile() {
var a = document.createElement('a');
- var blob = new Blob([INTERNAL.aot_profile_data]);
+ var blob = new Blob([INTERNAL.aotProfileData]);
a.href = URL.createObjectURL(blob);
a.download = "data.aotprofile";
// Append anchor to body.
diff --git a/src/mono/sample/wasm/browser-profile/Wasm.BrowserProfile.Sample.csproj b/src/mono/sample/wasm/browser-profile/Wasm.BrowserProfile.Sample.csproj
index b78cf693141..f6508c948e4 100644
--- a/src/mono/sample/wasm/browser-profile/Wasm.BrowserProfile.Sample.csproj
+++ b/src/mono/sample/wasm/browser-profile/Wasm.BrowserProfile.Sample.csproj
@@ -7,7 +7,7 @@
-
+
diff --git a/src/mono/sample/wasm/browser-profile/main.js b/src/mono/sample/wasm/browser-profile/main.js
index 6431b3628a6..29e6be1e3af 100644
--- a/src/mono/sample/wasm/browser-profile/main.js
+++ b/src/mono/sample/wasm/browser-profile/main.js
@@ -12,12 +12,12 @@ function wasm_exit(exit_code, reason) {
console.log(`WASM EXIT ${exit_code}`);
}
-function saveProfile(aot_profile_data) {
- if (!aot_profile_data) {
- throw new Error("aot_profile_data not set")
+function saveProfile(aotProfileData) {
+ if (!aotProfileData) {
+ throw new Error("aotProfileData not set")
}
const a = document.createElement('a');
- const blob = new Blob([aot_profile_data]);
+ const blob = new Blob([aotProfileData]);
a.href = URL.createObjectURL(blob);
a.download = "data.aotprofile";
// Append anchor to body.
@@ -32,11 +32,11 @@ try {
const { MONO, BINDING, INTERNAL } = await createDotnetRuntime(({ MONO }) => ({
configSrc: "./mono-config.json",
disableDotnet6Compatibility: true,
- onConfigLoaded: () => {
- if (MONO.config.enable_profiler) {
- MONO.config.aot_profiler_options = {
- write_at: "Sample.Test::StopProfile",
- send_to: "System.Runtime.InteropServices.JavaScript.JavaScriptExports::DumpAotProfileData"
+ onConfigLoaded: (config) => {
+ if (config.enableProfiler) {
+ config.aotProfilerOptions = {
+ writeAt: "Sample.Test::StopProfile",
+ sendTo: "System.Runtime.InteropServices.JavaScript.JavaScriptExports::DumpAotProfileData"
}
}
},
@@ -49,9 +49,9 @@ try {
document.getElementById("out").innerHTML = ret;
console.debug(`ret: ${ret}`);
- if (MONO.config.enable_profiler) {
+ if (MONO.config.enableProfiler) {
stopProfile();
- saveProfile(INTERNAL.aot_profile_data);
+ saveProfile(INTERNAL.aotProfileData);
}
let exit_code = ret == 42 ? 0 : 1;
diff --git a/src/mono/sample/wasm/browser-webpack/Wasm.Browser.WebPack.Sample.csproj b/src/mono/sample/wasm/browser-webpack/Wasm.Browser.WebPack.Sample.csproj
index 7c9c4da09e1..7eb6e7ac4f8 100644
--- a/src/mono/sample/wasm/browser-webpack/Wasm.Browser.WebPack.Sample.csproj
+++ b/src/mono/sample/wasm/browser-webpack/Wasm.Browser.WebPack.Sample.csproj
@@ -12,11 +12,13 @@
+
diff --git a/src/mono/sample/wasm/browser/Program.cs b/src/mono/sample/wasm/browser/Program.cs
index eb2506e0f21..2f8cabacea1 100644
--- a/src/mono/sample/wasm/browser/Program.cs
+++ b/src/mono/sample/wasm/browser/Program.cs
@@ -15,10 +15,10 @@ namespace Sample
return 0;
}
- [JSImport("Sample.Test.add")]
+ [JSImport("Sample.Test.add", "main.js")]
internal static partial int Add(int a, int b);
- [JSImport("Sample.Test.sub")]
+ [JSImport("Sample.Test.sub", "main.js")]
internal static partial int Sub(int a, int b);
[JSExport]
diff --git a/src/mono/sample/wasm/browser/main.js b/src/mono/sample/wasm/browser/main.js
index 4945a5cb67f..82561c74e22 100644
--- a/src/mono/sample/wasm/browser/main.js
+++ b/src/mono/sample/wasm/browser/main.js
@@ -12,6 +12,11 @@ function wasm_exit(exit_code, reason) {
console.log(`WASM EXIT ${exit_code}`);
}
+/**
+ * @type {import('../../../wasm/runtime/dotnet').CreateDotnetRuntimeType}
+ */
+const createDotnetRuntimeTyped = createDotnetRuntime;
+
function add(a, b) {
return a + b;
}
@@ -19,36 +24,55 @@ function add(a, b) {
function sub(a, b) {
return a - b;
}
-
try {
- const { MONO, RuntimeBuildInfo, IMPORTS } = await createDotnetRuntime(() => {
- console.log('user code in createDotnetRuntime callback');
+ const { runtimeBuildInfo, setModuleImports, getAssemblyExports, runMain } = await createDotnetRuntimeTyped(() => {
+ // this callback usually needs no statements, the API objects are only empty shells here and are populated later
return {
configSrc: "./mono-config.json",
+ onConfigLoaded: (config) => {
+ // This is called during emscripten `dotnet.wasm` instantiation, after we fetched config.
+ console.log('user code Module.onConfigLoaded');
+ // config is loaded and could be tweaked before the rest of the runtime startup sequence
+ config.environmentVariables["MONO_LOG_LEVEL"] = "debug"
+ },
preInit: () => { console.log('user code Module.preInit'); },
preRun: () => { console.log('user code Module.preRun'); },
- onRuntimeInitialized: () => { console.log('user code Module.onRuntimeInitialized'); },
+ onRuntimeInitialized: () => {
+ console.log('user code Module.onRuntimeInitialized');
+ // here we could use API passed into this callback
+ // Module.FS.chdir("/");
+ },
+ onDotnetReady: () => {
+ // This is called after all assets are loaded.
+ console.log('user code Module.onDotnetReady');
+ },
postRun: () => { console.log('user code Module.postRun'); },
}
});
+ // at this point both emscripten and monoVM are fully initialized.
+ // we could use the APIs returned and resolved from createDotnetRuntime promise
+ // both exports are receiving the same object instances
console.log('user code after createDotnetRuntime()');
- IMPORTS.Sample = {
- Test: {
- add,
- sub
+ setModuleImports("main.js", {
+ Sample: {
+ Test: {
+ add,
+ sub
+ }
}
- };
+ });
- const exports = await MONO.mono_wasm_get_assembly_exports("Wasm.Browser.Sample.dll");
+ const exports = await getAssemblyExports("Wasm.Browser.Sample.dll");
const meaning = exports.Sample.Test.TestMeaning();
console.debug(`meaning: ${meaning}`);
if (!exports.Sample.Test.IsPrime(meaning)) {
- document.getElementById("out").innerHTML = `${meaning} as computed on dotnet ver ${RuntimeBuildInfo.ProductVersion}`;
+ document.getElementById("out").innerHTML = `${meaning} as computed on dotnet ver ${runtimeBuildInfo.productVersion}`;
console.debug(`ret: ${meaning}`);
}
- let exit_code = await MONO.mono_run_main("Wasm.Browser.Sample.dll", []);
+ let exit_code = await runMain("Wasm.Browser.Sample.dll", []);
wasm_exit(exit_code);
-} catch (err) {
- wasm_exit(2, err);
}
+catch (err) {
+ wasm_exit(2, err);
+}
\ No newline at end of file
diff --git a/src/mono/sample/wasm/console-node-es6/main.mjs b/src/mono/sample/wasm/console-node-es6/main.mjs
index 3cd0598af62..4f29df3284a 100644
--- a/src/mono/sample/wasm/console-node-es6/main.mjs
+++ b/src/mono/sample/wasm/console-node-es6/main.mjs
@@ -1,10 +1,18 @@
+// @ts-check
+// @ts-ignore
import createDotnetRuntime from './dotnet.js'
+import process from 'process'
-const { MONO } = await createDotnetRuntime(() => ({
+/**
+ * @type {import('../../../wasm/runtime/dotnet').CreateDotnetRuntimeType}
+ */
+const createDotnetRuntimeTyped = createDotnetRuntime;
+
+const { runMainAndExit } = await createDotnetRuntimeTyped(() => ({
disableDotnet6Compatibility: true,
configSrc: "./mono-config.json",
}));
const app_args = process.argv.slice(2);
const dllName = "Wasm.Console.Node.Sample.dll";
-await MONO.mono_run_main_and_exit(dllName, app_args);
+await runMainAndExit(dllName, app_args);
diff --git a/src/mono/sample/wasm/console-node-ts/Wasm.Console.Node.TS.Sample.csproj b/src/mono/sample/wasm/console-node-ts/Wasm.Console.Node.TS.Sample.csproj
index 842dc7ddecb..10369cb62c1 100644
--- a/src/mono/sample/wasm/console-node-ts/Wasm.Console.Node.TS.Sample.csproj
+++ b/src/mono/sample/wasm/console-node-ts/Wasm.Console.Node.TS.Sample.csproj
@@ -10,9 +10,11 @@
-->
+
diff --git a/src/mono/sample/wasm/console-v8-es6/main.mjs b/src/mono/sample/wasm/console-v8-es6/main.mjs
index 11d9ce8f19b..3283d9bc421 100644
--- a/src/mono/sample/wasm/console-v8-es6/main.mjs
+++ b/src/mono/sample/wasm/console-v8-es6/main.mjs
@@ -4,8 +4,8 @@ const dllName = "Wasm.Console.V8.Sample.dll";
const app_args = Array.from(arguments);
async function main() {
- const { MONO } = await createDotnetRuntime();
- await MONO.mono_run_main_and_exit(dllName, app_args);
+ const { runMainAndExit } = await createDotnetRuntime();
+ await runMainAndExit(dllName, app_args);
}
main();
\ No newline at end of file
diff --git a/src/mono/sample/wasm/console-v8-es6/v8shim.cjs b/src/mono/sample/wasm/console-v8-es6/v8shim.cjs
index f8c2a61fe87..81f6fd12753 100644
--- a/src/mono/sample/wasm/console-v8-es6/v8shim.cjs
+++ b/src/mono/sample/wasm/console-v8-es6/v8shim.cjs
@@ -1,14 +1,3 @@
-if (typeof globalThis.URL === 'undefined') {
- globalThis.URL = class URL {
- constructor(url) {
- this.url = url;
- }
- toString() {
- return this.url;
- }
- };
-}
-
import('./main.mjs').catch(err => {
console.log(err);
console.log(err.stack);
diff --git a/src/mono/sample/wasm/node-webpack/Wasm.Node.WebPack.Sample.csproj b/src/mono/sample/wasm/node-webpack/Wasm.Node.WebPack.Sample.csproj
index 7c0c3da238e..c8e021906c4 100644
--- a/src/mono/sample/wasm/node-webpack/Wasm.Node.WebPack.Sample.csproj
+++ b/src/mono/sample/wasm/node-webpack/Wasm.Node.WebPack.Sample.csproj
@@ -7,11 +7,13 @@
+
diff --git a/src/mono/wasm/build/WasmApp.targets b/src/mono/wasm/build/WasmApp.targets
index 0a03189f69e..d9a5f1f06ed 100644
--- a/src/mono/wasm/build/WasmApp.targets
+++ b/src/mono/wasm/build/WasmApp.targets
@@ -17,7 +17,7 @@
- $(RunAOTCompilation) - Defaults to false.
- $(WasmDebugLevel)
- > 0 enables debugging and sets the debug log level to debug_level
+ > 0 enables debugging and sets the debug log level to debugLevel
== 0 disables debugging and enables interpreter optimizations
< 0 enabled debugging and disables debug logging.
@@ -75,7 +75,7 @@
- @(WasmNativeAsset) - Native files to be added to `NativeAssets` in the bundle.
- @(WasmExtraConfig) - json elements to add to `mono-config.json`
- Eg.
+ Eg.
- Value attribute can have a number, bool, quoted string, or json string
diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html b/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html
index 5c6917121db..33c6f7e01db 100644
--- a/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html
+++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-driver.html
@@ -7,14 +7,14 @@
var App = {
static_method_table: {},
init: function () {
- this.int_add = App.BINDING.bind_static_method("[debugger-test] Math:IntAdd");
- this.use_complex = App.BINDING.bind_static_method("[debugger-test] Math:UseComplex");
- this.delegates_test = App.BINDING.bind_static_method("[debugger-test] Math:DelegatesTest");
- this.generic_types_test = App.BINDING.bind_static_method("[debugger-test] Math:GenericTypesTest");
- this.outer_method = App.BINDING.bind_static_method("[debugger-test] Math:OuterMethod");
- this.async_method = App.BINDING.bind_static_method("[debugger-test] Math/NestedInMath:AsyncTest");
- this.method_with_structs = App.BINDING.bind_static_method("[debugger-test] DebuggerTests.ValueTypesTest:MethodWithLocalStructs");
- this.run_all = App.BINDING.bind_static_method("[debugger-test] DebuggerTest:run_all");
+ this.int_add = App.runtime.BINDING.bind_static_method("[debugger-test] Math:IntAdd");
+ this.use_complex = App.runtime.BINDING.bind_static_method("[debugger-test] Math:UseComplex");
+ this.delegates_test = App.runtime.BINDING.bind_static_method("[debugger-test] Math:DelegatesTest");
+ this.generic_types_test = App.runtime.BINDING.bind_static_method("[debugger-test] Math:GenericTypesTest");
+ this.outer_method = App.runtime.BINDING.bind_static_method("[debugger-test] Math:OuterMethod");
+ this.async_method = App.runtime.BINDING.bind_static_method("[debugger-test] Math/NestedInMath:AsyncTest");
+ this.method_with_structs = App.runtime.BINDING.bind_static_method("[debugger-test] DebuggerTests.ValueTypesTest:MethodWithLocalStructs");
+ this.run_all = App.runtime.BINDING.bind_static_method("[debugger-test] DebuggerTest:run_all");
this.static_method_table = {};
console.log ("ready");
},
@@ -22,7 +22,7 @@
function invoke_static_method (method_name, ...args) {
var method = App.static_method_table [method_name];
if (method == undefined)
- method = App.static_method_table[method_name] = App.BINDING.bind_static_method(method_name);
+ method = App.static_method_table[method_name] = App.runtime.BINDING.bind_static_method(method_name);
return method (...args);
}
@@ -30,7 +30,7 @@
async function invoke_static_method_async (method_name, ...args) {
var method = App.static_method_table [method_name];
if (method == undefined) {
- method = App.static_method_table[method_name] = App.BINDING.bind_static_method(method_name);
+ method = App.static_method_table[method_name] = App.runtime.BINDING.bind_static_method(method_name);
}
return await method (...args);
diff --git a/src/mono/wasm/debugger/tests/debugger-test/debugger-main.js b/src/mono/wasm/debugger/tests/debugger-test/debugger-main.js
index 19dc0175e26..29b23b79e2d 100644
--- a/src/mono/wasm/debugger/tests/debugger-test/debugger-main.js
+++ b/src/mono/wasm/debugger/tests/debugger-test/debugger-main.js
@@ -6,14 +6,14 @@
import createDotnetRuntime from './dotnet.js'
try {
- const { BINDING } = await createDotnetRuntime(({ INTERNAL }) => ({
+ const runtime = await createDotnetRuntime(({ INTERNAL }) => ({
configSrc: "./mono-config.json",
onConfigLoaded: (config) => {
- config.environment_variables["DOTNET_MODIFIABLE_ASSEMBLIES"] = "debug";
+ config.environmentVariables["DOTNET_MODIFIABLE_ASSEMBLIES"] = "debug";
/* For custom logging patch the functions below
- config.diagnostic_tracing = true;
- config.environment_variables["MONO_LOG_LEVEL"] = "debug";
- config.environment_variables["MONO_LOG_MASK"] = "all";
+ config.diagnosticTracing = true;
+ config.environmentVariables["MONO_LOG_LEVEL"] = "debug";
+ config.environmentVariables["MONO_LOG_MASK"] = "all";
INTERNAL.logging = {
trace: (domain, log_level, message, isFatal, dataPtr) => console.log({ domain, log_level, message, isFatal, dataPtr }),
debugger: (level, message) => console.log({ level, message }),
@@ -21,7 +21,7 @@ try {
*/
},
}));
- App.BINDING = BINDING;
+ App.runtime = runtime;
App.init()
} catch (err) {
console.log(`WASM ERROR ${err}`);
diff --git a/src/mono/wasm/debugger/tests/debugger-test/wasm-page-without-assets.html b/src/mono/wasm/debugger/tests/debugger-test/wasm-page-without-assets.html
index 992e9bac68a..9e62a550b22 100644
--- a/src/mono/wasm/debugger/tests/debugger-test/wasm-page-without-assets.html
+++ b/src/mono/wasm/debugger/tests/debugger-test/wasm-page-without-assets.html
@@ -1,15 +1,15 @@
-
-
-
+
+
+
+
+
@@ -17,5 +17,6 @@
Stuff goes here
-
-
+
+
+