Blazor.Canvas
Blazor.Canvas copied to clipboard
ToBlobAsync on Canvas
Related to Issue #158.
I have started by implementing the primary features to solve the issue.
I still need to:
- [x] Decide whether or not to implement other parts of the Blob API or just keep it as it is which is to surface the IJSObjectReference.
- [x] Write an example as part of the TestProject (probably very similar to the ToDataURL example).
Thanks for the initial work! Looks like it's on the right track to me :-)
Hi @KristofferStrube,
Sorry for not interacting with this for a while. Is this ready for review now?
Thanks Stefan
Hi @stefanloerwald,
I wanted to give a last shot at getting the sample to work in the Blazor Server sample and then also maybe simply some of the Interop, even more, using IJSObjectReference
s as you had suggested earlier.
Would it be a deal-breaker for the feature if the sample doesn't work in Blazor Server?
I don't think it's 100% a deal-breaker if it doesn't work in Blazor Server, but I'd like to understand why. If it's just a payload limit then I'd love to see whether we can deliver the payload in a different way (or in chunks), to make it work (basically, how much effort is this?).
If it's not going to work reliably with Blazor Server, can we make sure it fails gracefully (i.e. if we know it's executed server-side, can we throw an appropriate exception)?
It is a problem with the sample itself and sending too big payloads. It can handle up to about 200x200 canvases. It just fails in an ugly way currently. Should I just change the sample to a smaller canvas and make some notes about it not working for bigger canvases because of payload limits. Don't know if there is some general issue or MS Doc site that we could also link to to justify the limitation.
I suppose it might be limited by the SignalR connection: https://docs.microsoft.com/en-us/aspnet/core/signalr/configuration?view=aspnetcore-3.0&WT.mc_id=DOP-MVP-38654&tabs=dotnet#configure-server-options
Maybe it's better to deactivate this method entirely for server-side?
I don't know if there is a way to limit whether or not a method is visible in Blazor Server.
It doesn't need to be that strict. We can just throw a PlatformNotSupportedException whenever we're in Blazor Server. I think that's sufficient. I don't expect this API to be super popular, so as long as it serves your use case, I'm fine with being a bit more restrictive than necessary for cases where the limit can be a pain.
Hey @stefanloerwald sorry for the long wait.
I didn't really like the solution I came up with since it was somewhat cumbersome to make the callback. Since this, I have worked a lot on JSInterop. I found the method DotNet.createJSObjectReference
which can be used to create object references from JS which was one of the things I was missing.
So I have made those changes and I think the PR is ready for review now.
Thank you @KristofferStrube! This looks all good now. I'll merge and release a new version soon.
This should now be available as version 3.2.0. Thanks again for the contribution.