Skip to content

Commit

Permalink
[browser] Resolve asset URL only once (#93275)
Browse files Browse the repository at this point in the history
  • Loading branch information
maraf authored Oct 13, 2023
1 parent 9b7c52f commit b9acf73
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
5 changes: 3 additions & 2 deletions src/mono/wasm/runtime/dotnet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,12 @@ type MonoConfig = {
[name: string]: any;
};
/**
* This is current working directory for the runtime on the virtual file system. Default is "/".
* This is initial working directory for the runtime on the virtual file system. Default is "/".
*/
virtualWorkingDirectory?: string;
/**
* This is the arguments to the Main() method of the program. Default is [].
* This is the arguments to the Main() method of the program when called with dotnet.run() Default is [].
* Note: RuntimeAPI.runMain() and RuntimeAPI.runMainAndExit() will replace this value, if they provide it.
*/
applicationArguments?: string[];
};
Expand Down
26 changes: 14 additions & 12 deletions src/mono/wasm/runtime/loader/assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,21 @@ function get_single_asset(behavior: SingleAssetBehaviors): AssetEntryInternal {

export function resolve_single_asset_path(behavior: SingleAssetBehaviors): AssetEntryInternal {
const asset = get_single_asset(behavior);
asset.resolvedUrl = loaderHelpers.locateFile(asset.name);

if (jsRuntimeModulesAssetTypes[asset.behavior]) {
// give loadBootResource chance to override the url for JS modules with 'dotnetjs' type
const customLoadResult = invokeLoadBootResource(asset);
if (customLoadResult) {
mono_assert(typeof customLoadResult === "string", "loadBootResource response for 'dotnetjs' type should be a URL string");
asset.resolvedUrl = customLoadResult;
} else {
asset.resolvedUrl = appendUniqueQuery(asset.resolvedUrl, asset.behavior);
if (!asset.resolvedUrl) {
asset.resolvedUrl = loaderHelpers.locateFile(asset.name);

if (jsRuntimeModulesAssetTypes[asset.behavior]) {
// give loadBootResource chance to override the url for JS modules with 'dotnetjs' type
const customLoadResult = invokeLoadBootResource(asset);
if (customLoadResult) {
mono_assert(typeof customLoadResult === "string", "loadBootResource response for 'dotnetjs' type should be a URL string");
asset.resolvedUrl = customLoadResult;
} else {
asset.resolvedUrl = appendUniqueQuery(asset.resolvedUrl, asset.behavior);
}
} else if (asset.behavior !== "dotnetwasm") {
throw new Error(`Unknown single asset behavior ${behavior}`);
}
} else if (asset.behavior !== "dotnetwasm") {
throw new Error(`Unknown single asset behavior ${behavior}`);
}
return asset;
}
Expand Down

0 comments on commit b9acf73

Please sign in to comment.