Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/mono/browser/runtime/dotnet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ interface DotnetHostBuilder {
* Sets application culture. This is a name specified in the BCP 47 format. See https://tools.ietf.org/html/bcp47
*/
withApplicationCulture(applicationCulture?: string): DotnetHostBuilder;
/**
* Sets a callback that is invoked after each resource finishes downloading.
*/
withDownloadResourceProgress(callback?: (resourcesLoaded: number, totalResources: number) => void): DotnetHostBuilder;
/**
* Overrides the built-in boot resource loading mechanism so that boot resources can be fetched
* from a custom source, such as an external CDN.
Expand Down
12 changes: 12 additions & 0 deletions src/mono/browser/runtime/loader/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,18 @@ export class HostBuilder implements DotnetHostBuilder {
}
}

withDownloadResourceProgress (callback?: (resourcesLoaded: number, totalResources: number) => void): DotnetHostBuilder {
try {
deep_merge_module(emscriptenModule, {
onDownloadResourceProgress: callback
});
return this;
} catch (err) {
mono_exit(1, err);
throw err;
}
}

withResourceLoader (loadBootResource?: LoadBootResourceCallback): DotnetHostBuilder {
try {
loaderHelpers.loadBootResource = loadBootResource;
Expand Down
4 changes: 4 additions & 0 deletions src/mono/browser/runtime/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ export interface DotnetHostBuilder {
* Sets application culture. This is a name specified in the BCP 47 format. See https://tools.ietf.org/html/bcp47
*/
withApplicationCulture(applicationCulture?: string): DotnetHostBuilder;
/**
* Sets a callback that is invoked after each resource finishes downloading.
*/
withDownloadResourceProgress(callback?: (resourcesLoaded: number, totalResources: number) => void): DotnetHostBuilder;
/**
* Overrides the built-in boot resource loading mechanism so that boot resources can be fetched
* from a custom source, such as an external CDN.
Expand Down
10 changes: 4 additions & 6 deletions src/mono/wasm/testassets/WasmBasicTestApp/App/wwwroot/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,10 @@ switch (testCase) {
throw error;
});
}
dotnet.withModuleConfig({
onDownloadResourceProgress: (loaded, total) => {
console.log(`DownloadResourceProgress: ${loaded} / ${total}`);
if (loaded === total && loaded !== 0) {
testOutput("DownloadResourceProgress: Finished");
}
dotnet.withDownloadResourceProgress((loaded, total) => {
console.log(`DownloadResourceProgress: ${loaded} / ${total}`);
if (loaded === total && loaded !== 0) {
testOutput("DownloadResourceProgress: Finished");
}
});
break;
Expand Down
4 changes: 4 additions & 0 deletions src/native/libs/Common/JavaScript/loader/dotnet.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ interface DotnetHostBuilder {
* Sets application culture. This is a name specified in the BCP 47 format. See https://tools.ietf.org/html/bcp47
*/
withApplicationCulture(applicationCulture?: string): DotnetHostBuilder;
/**
* Sets a callback that is invoked after each resource finishes downloading.
*/
withDownloadResourceProgress(callback?: (resourcesLoaded: number, totalResources: number) => void): DotnetHostBuilder;
/**
* Overrides the built-in boot resource loading mechanism so that boot resources can be fetched
* from a custom source, such as an external CDN.
Expand Down
4 changes: 4 additions & 0 deletions src/native/libs/Common/JavaScript/loader/host-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ export class HostBuilder implements DotnetHostBuilder {
});
return this;
}
withDownloadResourceProgress(callback?: (resourcesLoaded: number, totalResources: number) => void): DotnetHostBuilder {
Module.onDownloadResourceProgress = callback;
return this;
}
withResourceLoader(loadBootResource?: LoadBootResourceCallback): DotnetHostBuilder {
setLoadBootResourceCallback(loadBootResource);
return this;
Expand Down
5 changes: 4 additions & 1 deletion src/native/libs/Common/JavaScript/types/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export interface DotnetHostBuilder {
* Sets application culture. This is a name specified in the BCP 47 format. See https://tools.ietf.org/html/bcp47
*/
withApplicationCulture(applicationCulture?: string): DotnetHostBuilder;
/**
* Sets a callback that is invoked after each resource finishes downloading.
*/
withDownloadResourceProgress(callback?: (resourcesLoaded: number, totalResources: number) => void): DotnetHostBuilder;
/**
* Overrides the built-in boot resource loading mechanism so that boot resources can be fetched
* from a custom source, such as an external CDN.
Expand Down Expand Up @@ -739,4 +743,3 @@ export declare const dotnet: DotnetHostBuilder;

export declare const createDotnetRuntime: CreateDotnetRuntimeType;


Loading