SteveSandersonMS / WebWindow

.NET Core library to open native OS windows containing web UI on Windows, Mac, and Linux. Experimental.
Apache License 2.0
1.98k stars 215 forks source link

Allow supplying JavaScript to the WebWindow #36

Closed sondreb closed 4 years ago

sondreb commented 4 years ago

During startup of the app/WebWindow, I would like to inject JavaScript code from .NET. Afaik there is no way to do this without also having some initial JavaScript running on the loaded web assets.

Scenario: I have built a library that enables some built-in features for calling between JavaScript and .NET, but I'd like to be able to allow consumers of the library to simply call window.EnableNativeApi() and it should inject not only the .NET handling, but also a small JavaScript that maps the calls. This would avoid having to explain to consumers to copy the JavaScript into their wwwroot folder.

SteveSandersonMS commented 4 years ago

I'd be happy to accept a PR that adds a suitable callback that fires during the initial page load.