6 ms·
You can send javascript directly to the WebView2 control [1]. [1] https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.executes
by wila 5y ago
You can send javascript directly to the WebView2 control [1].
[1] https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.executescriptasync?view=webview2-dotnet-1.0.864.35 https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.we...
- DonHopkins 5y ago>public System.Threading.Tasks.Task<string> ExecuteScriptAsync (string javaScript); That's what I mean by sending JSON messages, but I'm asking if there is a way of directly calling native code from the JavaScript interpreter, synchronously passing pointers to JavaScript data structures back and forth, not just copying strings back and forth between separate processes through an asynchronous message queue. Like Microsoft's deprecated COM/OLE/ActiveX, or Apple's Objective C / JavaScript bridge, or what SWIG does for JavaScriptCore, for example: https://steamclock.com/blog/2013/05/apple-objective-c-javascript-bridge/ https://steamclock.com/blog/2013/05/apple-objective-c-javasc... http://www.swig.org/Doc3.0/Javascript.html http://www.swig.org/Doc3.0/Javascript.html For example, how can I get direct read/write access to the pixels of an html canvas or the memory of a JavaScript byte or float array, instead of serializing images as png files or base 64 encoded strings, or buffers of numbers as decimal text json arrays?
- wila 5y agoThere's this [1] and the C++ variant here [2] So far I have not yet investigated what can be done with that. It looks a bit promising (and complicated). Microsoft's deprecated control had the mshtml document interface and that was indeed very powerful. The Async script capabilities give you a lot of power, but I agree that the asynchronous part of it is a huge pain and is causing me extra headaches as it is basically preventing me from creating the API I want to create. [1] https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.webview2.core.corewebview2.addhostobjecttoscript?view=webview2-dotnet-1.0.864.35 https://docs.microsoft.com/en-us/dotnet/api/microsoft.web.we... [2] https://docs.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.864.35#addhostobjecttoscript https://docs.microsoft.com/en-us/microsoft-edge/webview2/ref...