Search guides and the APICtrl K
  1. API reference
  2. Web editor bridge

webview_win32.h

The Windows webview backend (Edge WebView2).

#include <sonore/webview_win32.h>
On this page

Design notes

Creates a child HWND the host can embed, hosts a WebView2 inside it, injects the window.sonore bridge before any page script runs, and pumps parameter and meter updates into the page on a timer.

Design notes that are load-bearing:

  • WebView2 comes up ASYNCHRONOUSLY (environment -> controller -> webview, each via a COM completion handler). Every public method therefore has to work BEFORE the webview exists: HTML, size and pending updates are stored and applied on arrival. A DAW opens and closes editors far faster than Edge initialises, so "not ready yet" is the normal case, not an edge one.
  • The runtime may be ABSENT (older Windows without the Edge WebView2 Runtime). That degrades to a plain message in the child window, never a failed plugin load, and never a silent black rectangle.
  • The webview is created with a per-plugin user-data folder under %LOCALAPPDATA%. Without an explicit folder WebView2 tries to write beside the host EXE, which fails in Program Files and takes the whole editor down with it.
  • The page is served from memory, as the answer to a request for an address of the plugin's own that never leaves the process (https://<plugin>.sonore.invalid/editor.html, loadPage), so a generated UI is entirely self-contained, reloads like any page, and has an origin of its own: localStorage works and is kept per plugin. And it STAYS the page: every navigation away from it is cancelled (webviewMayNavigate in gui.h), in the page and in its frames, and window.open opens nothing. Before, a link or a script could take the view to a remote site, which then held window.sonore and set parameters; and a window.open popup was a top-level Edge window that outlived the editor.

Types 2

template <typename Interface, typename Arg1, typename Arg2> class ComCallback final : public Interface

One-method COM callback, refcounted. WebView2's creation API hands results back through these; a template keeps the three we need to one implementation.

A webview embedded in a child window.

Lifetime: create() makes the HWND immediately (so the host can embed it right away) and kicks off WebView2 creation; the page arrives later. destroy() tears everything down in the reverse order.

Functions 7

Aliases 8

↑↓ to move↵ to openEvery public name in the headers, and every guide