-
Notifications
You must be signed in to change notification settings - Fork 5.6k
[browser] fix loading assets #89687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
pavelsavara
merged 14 commits into
dotnet:main
from
pavelsavara:browser_fix_loading_assets
Aug 2, 2023
Merged
[browser] fix loading assets #89687
Changes from 8 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4115515
fix loading from assets object
pavelsavara 651debd
fix
pavelsavara 0771bc8
minimal config sample
pavelsavara ca5e3bc
Merge branch 'main' into browser_fix_loading_assets
pavelsavara 789b1fb
- make sure that we resolve URLs from loadBootResource to absolute UR…
pavelsavara 4fada2e
fix
pavelsavara 6b3f34a
fix config merge
pavelsavara 534f4d2
fix
pavelsavara a437e6a
fix type
pavelsavara f0cdbda
feedback @kg
pavelsavara 9762a11
gen
pavelsavara 4225eca
fix
pavelsavara e7b6885
Merge branch 'main' into browser_fix_loading_assets
pavelsavara aeb913e
fix test
pavelsavara File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System; | ||
| using System.Runtime.InteropServices.JavaScript; | ||
| using System.Runtime.InteropServices; | ||
|
|
||
| namespace Sample | ||
| { | ||
| public partial class Test | ||
| { | ||
| public static int Main(string[] args) | ||
| { | ||
| Console.WriteLine("Hello minimal config"); | ||
| return 0; | ||
| } | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/mono/sample/wasm/browser-minimal-config/Wasm.Browser.Config.Sample.csproj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <Import Project="..\DefaultBrowserSample.targets" /> | ||
| <ItemGroup> | ||
| <WasmExtraFilesToDeploy Include="main.js" /> | ||
| </ItemGroup> | ||
| </Project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| <!DOCTYPE html> | ||
| <!-- Licensed to the .NET Foundation under one or more agreements. --> | ||
| <!-- The .NET Foundation licenses this file to you under the MIT license. --> | ||
| <html> | ||
|
|
||
| <head> | ||
| <title>Wasm Browser Sample</title> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <script type='module' src="./main.js"></script> | ||
| </head> | ||
|
|
||
| <body> | ||
| <h3 id="header">Wasm Browser Minimal Config Sample</h3> | ||
| </body> | ||
|
|
||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| import { dotnet } from "./_framework/dotnet.js"; | ||
|
|
||
| async function fetchBinary(uri) { | ||
| return new Uint8Array(await (await fetch(uri)).arrayBuffer()); | ||
| } | ||
|
|
||
| const assets = [ | ||
| { | ||
| name: "dotnet.native.js", | ||
| behavior: "js-module-native" | ||
| }, | ||
| { | ||
| name: "dotnet.js", | ||
| behavior: "js-module-dotnet" | ||
| }, | ||
| { | ||
| name: "dotnet.runtime.js", | ||
| behavior: "js-module-runtime" | ||
| }, | ||
| { | ||
| name: "dotnet.native.wasm", | ||
| behavior: "dotnetwasm" | ||
| }, | ||
| { | ||
| name: "System.Private.CoreLib.wasm", | ||
| behavior: "assembly" | ||
| }, | ||
| { | ||
| name: "System.Runtime.InteropServices.JavaScript.wasm", | ||
| behavior: "assembly" | ||
| }, | ||
| { | ||
| name: "Wasm.Browser.Config.Sample.wasm", | ||
| buffer: await fetchBinary("./_framework/Wasm.Browser.Config.Sample.wasm"), | ||
| behavior: "assembly" | ||
| }, | ||
| { | ||
| name: "System.Console.wasm", | ||
| behavior: "assembly" | ||
| }, | ||
| ]; | ||
|
|
||
| const resources = { | ||
| "jsModuleNative": { | ||
| "dotnet.native.js": "" | ||
| }, | ||
| "jsModuleRuntime": { | ||
| "dotnet.runtime.js": "" | ||
| }, | ||
| "wasmNative": { | ||
| "dotnet.native.wasm": "" | ||
| }, | ||
| "assembly": { | ||
| "System.Console.wasm": "", | ||
| "System.Private.CoreLib.wasm": "", | ||
| "System.Runtime.InteropServices.JavaScript.wasm": "", | ||
| "Wasm.Browser.Config.Sample.wasm": "" | ||
| }, | ||
| }; | ||
|
|
||
| const config = { | ||
| "mainAssemblyName": "Wasm.Browser.Config.Sample.dll", | ||
| assets, | ||
| }; | ||
|
|
||
| await dotnet | ||
| .withConfig(config) | ||
| .withElementOnExit() | ||
| .run(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.