Ztron supports two ways to create windows: declarative (configuration-driven,
applied as startup state by AppBuilder.fromConfig at app launch) and runtime
(created/destroyed programmatically via WebviewWindow).
A dual-window config from examples/hello/ztron.conf.json — the main window
loads the Vite frontend via the url: "frontend" placeholder, while the
conf-second window inlines HTML directly:
The fields align with Tauri's WindowConfig startup state; url: "frontend"
resolves to the dev server / build output in the dev flow, any other string
loads as an absolute URL, and omitting it falls back to inline HTML.
Verification anchor: CONF_WINDOW_OK:From Config (P14).
@zturnlibs/ztron-api provides the WebviewWindow class for creating and
destroying windows while the app runs (the multiwin example uses it for a
10x create/destroy stress test). Runtime-created windows likewise enter the
host's webview registry, with label routing, per-window events, and registry
cleanup on close. Verification anchors:
SECOND_WINDOW_OK label=second — the hello example really created and
destroyed a runtime window during the run (P9)MULTI_WINDOW_OK (P6) — multi-window architecture: host webview registry
WebviewWindowWindow state (size/position/min-size constraints/minimizable, etc.),
opacity, transparency, decoration, titleBarStyle, dock progress/badge,
setTheme, monitor queries (availableMonitors etc.), and all 13 window
events are available (see Events & Channel); key
verification anchors: WIN_STATE_OK, WIN_EVENT_OK, WIN_V2_EXTRAS_OK,
MONITORS_OK.
Runtime multi-window creation is unlocked on macOS, but the webview library
has a history of blocking second-webview creation in the run loop; the fix
(including a lib patch for an engine-destruction UAF) is recorded in
DESIGN.md §75.
适用版本:ztron 0.3.1