Using Zpl.Viewer in the browser using WASM
Hi, this library is amazing and the docker viewer really helped me on a internal project!
Im trying to pack the viewer inside a WASM module using wasm-tools (from blazor) It was fairly easy to create a module that can be used in the browser directly, but at the moment of actually generating the label a SkiaSharp error is raised (even though the correct SkiaSharp.wasm packages are used)
As im running this behind the WASM packager, the only error that is shown is Uncaught (in promise) ManagedError: TypeInitialization_Type, SkiaSharp.SKObject, I cannot view the full trace.
https://github.com/Fabrizz/ZPLwasm/blob/master/ZPLwasm/Program.cs (Very basic stuff, it just exposes the package in the JS side. It works as the error is while using the Skia renderer)
I dont have much C# experience really, I tried adding: (https://github.com/Fabrizz/ZPLwasm/blob/master/ZPLwasm/ZPLwasm.csproj)
<ItemGroup>
<TrimmerRootAssembly Include="SixLabors.ImageSharp" />
<LinkerDescriptor Include="ILLink.xml" />
</ItemGroup>
To maybe solve the Skia error, but It did nothing.
For testing I load the /bin/release/net8.0/browser-wasm/AppBundle/_framework folder in a vite app, but using the included main.js is enough to test the integration.
Any help appreciated!
Relevant:
- https://www.meziantou.net/using-dotnet-code-from-javascript-using-webassembly.htm
- https://github.com/dotnet/runtime/blob/main/src/mono/wasm/features.md