-
-
Notifications
You must be signed in to change notification settings - Fork 42
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
Use the .Net browser extension Apis in a zero UI plugin #85
Comments
In this case I am assuming that you are writing these event handlers in background worker JS. This page might help you get started with interop to WASM from JS and you can then use the WebExtensions.Net library to interop with the extensions API without Blazor. It's a lot of work to be done, but it looks like it's achievable. |
Thank you for getting back to me so quickly. I am considering using Blazor because I would still have some modals displayed from the plugin. Just that I want to invoke .Net from JS when the plugin is loaded (onistalled). Anyways, I will check the documentation. |
In the background worker, Blazor is not loaded at all, therefore it would need to be initialized separately but the initialization is very heavy and depends on DOM which is not available in background worker. Currently the only way to use C# in background worker is to initialize the dotnet wasm separately just like how Blazor initializes it. |
I am not able to create dotnet instance from the service worker. Getting this error: |
Dynamic import is not allowed but static import should be allowed in the background worker. You can try to move the import to the top, does that work or is the error coming from the |
The error is from dotnet.js |
In that case, unfortunately it is a lot harder to use WASM in background worker unless the Chrome extensions team allow dynamic import or dotnet team creates a js file with static imports. |
dynamic imports in the service worker not being supported does make it a lot harder. It does not seem likely that they will enable it any time soon.
I wrote code to modify the Blazor _framework javascript files via a post-build event so that they use dynamic import when in a window and importScripts in workers and service worker. Working in a Chrome extension service worker, workers, etc. 👍👍 |
Using C# in background is now supported with the version v1.5.0. |
I want to use this package mainly because of the extension APIs available in C#. However, I can't seem to find an entry point into my C# code without loading a page.
For example, I want to add an event listener for the onclick of the action and also register some other listeners from the onistalled event handler.
The text was updated successfully, but these errors were encountered: