MCPcopy Index your code
hub / github.com/blckngm/webview2

github.com/blckngm/webview2 @v0.1.4

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.1.4 ↗ · + Follow
315 symbols 446 edges 12 files 9 documented · 3%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Rust bindings for WebView2:

The Microsoft Edge WebView2 control enables you to embed web technologies (HTML, CSS, and JavaScript) in your native applications. The WebView2 control uses Microsoft Edge (Chromium) as the rendering engine to display the web content in native applications. With WebView2, you may embed web code in different parts of your native application, or build the entire native application within a single WebView. For information on how to start building a WebView2 application, see Get Started.

API

The webview2 crate contains high-level, idiomatic wrappers for the raw COM APIs, which can be found in the webview2-sys crate.

The API mapping should be quite straightforward.

The CreateCoreWebView2EnvironmentWithDetails function does not have a direct equivalent. It is replaced with a nicer EnvironmentBuilder API. The GetAvailableCoreWebView2BrowserVersionString and CompareBrowserVersions functions are also exposed through the builder.

Runtime

The Edge browser from beta, dev or canary channels (>= 86.0.622.0) or the Evergreen WebView2 Runtime need to be installed for this to actually work. Or the build method will return an error.

WebView2Loader

A binary library WebView2Loader from the WebView2 SDK need to be used, either the DLL WebView2Loader.dll or the static library WebView2LoaderStatic.lib. This brings some complexities:

  • When using the gnu toolchain, the static library does not seem to work so the WebView2Loader.dll DLL is used. You need to make sure that the DLL can be loaded at runtime, e.g. by putting it alongside the built exe files.

  • When using the msvc toolchain, the static library is used. Make sure you have the v142 toolset (or visual studio 2019), because the static library seem to be built with visual studio 2019 and could not be correctly linked by earlier versions of the visual studio. See C++ binary compatibility between Visual Studio 2015, 2017, and 2019.

Examples

See the examples directory, especially the heavily commented win32 example.

Extension points exported contracts — how you extend this code

ICoreWebView2EnvironmentOptions (Interface)
(no doc) [1 implementers]
webview2-sys/src/lib.rs
ISequentialStream (Interface)
(no doc)
webview2-sys/src/lib.rs
IStream (Interface)
(no doc)
webview2-sys/src/lib.rs
ICoreWebView2 (Interface)
(no doc)
webview2-sys/src/lib.rs
ICoreWebView2_2 (Interface)
(no doc)
webview2-sys/src/lib.rs

Core symbols most depended-on inside this repo

check_hresult
called by 30
src/lib.rs
get
called by 17
examples/win32.rs
build
called by 11
src/lib.rs
into_inner
called by 11
src/interfaces.rs
write
called by 10
src/lib.rs
set
called by 7
examples/win32.rs
create_controller
called by 6
src/lib.rs
get
called by 6
examples/user_agent.rs

Shape

Interface 107
Class 83
Method 69
Function 36
Enum 20

Languages

Rust100%

Modules by API surface

webview2-sys/src/lib.rs129 symbols
src/interfaces.rs68 symbols
src/lib.rs65 symbols
webview2-sys/idl2rs/src/main.rs18 symbols
examples/win32.rs10 symbols
examples/user_agent.rs10 symbols
examples/background_color.rs9 symbols
examples/capture-preview.rs2 symbols
webview2-sys/tests/test_linking.rs1 symbols
webview2-sys/build.rs1 symbols
examples/winit.rs1 symbols
examples/native-windows-gui.rs1 symbols

For agents

$ claude mcp add webview2 \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact