wƒWebFront C++23
FR ↗GitHub ↗

CHAPTER 02 / WEBFRONT

Open a window

Register a function and load the tools.

Register the C++ function

This programme reuses Life.hpp and LifeFrontend.hpp from the example. app retains the registered function; bootstrap loads the verified developer environment; show opens the window. The life-project path identifies the interface sources. Use this code in the example project, with its supporting headers.

C++23
#include "Life.hpp"
#include "LifeFrontend.hpp"
#include <webfront/WebFront.hpp>

int main() {
    webfront::demo::LifeApp app{"life-project"};
    app.cppFunction("life.step", &webfront::demo::nextLife);
    app.bootstrap("developer");
    app.show();
}

A window for the platform

From build, run examples/WebFrontLifeDeveloper (examples\Debug\WebFrontLifeDeveloper.exe with Visual Studio). The examples detect WebView2 on Windows, WKWebView on macOS 13.3+ and WebKitGTK 6.0 on Linux when their dependencies are present. Otherwise, they open the system browser. webfront::WebFront always uses the system browser; NativeApp selects a native window. Create and show native windows on the main thread.

A trusted local environment

The first bootstrap downloads a pinned version and checks its SHA-512 integrity. Subsequent launches use the cache. The built-in terminal needs neither Node.js nor a package manager on the host. The environment has project access: it is not a sandbox for untrusted code.

Question

When is network access needed?