Builtin Commands
zero-native provides built-in bridge commands for window management, layered WebViews, and native dialogs. These are controlled by the builtin_bridge policy in RuntimeOptions, separate from app-defined commands.
Window commands
| Command | Required permission | Description |
|---|---|---|
zero-native.window.list | window | List all open windows |
zero-native.window.create | window | Create a new window |
zero-native.window.focus | window | Focus a window by ID |
zero-native.window.close | window | Close a window by ID |
Window commands are available through window.zero.windows.* when js_window_api is true, but the runtime still checks the request origin and the window permission when permissions are configured. Use an explicit builtin_bridge policy when you want per-command origin lists.
WebView Commands
| Command | Required permission | Description |
|---|---|---|
zero-native.webview.create | window | Create a named WebView in a window |
zero-native.webview.list | window | List WebViews in the calling window |
zero-native.webview.setFrame | window | Move or resize a WebView |
zero-native.webview.navigate | window | Navigate a WebView |
zero-native.webview.setZoom | window | Set page zoom from 0.25 to 5.0 |
zero-native.webview.setLayer | window | Change native stack order |
zero-native.webview.close | window | Close a WebView |
WebView commands are available through window.zero.webviews.* when js_window_api is true. They use the same origin and window permission checks as window commands. WebView URLs are also checked against security.navigation.allowed_origins. Backend-specific gaps reject with invalid_request and an actionable unsupported-backend message.
If windowId is omitted, the runtime uses the window that sent the bridge message. If provided, windowId must match that same calling window. Child WebViews are isolated by default and receive window.zero only when created with bridge: true. The startup WebView is always listed as main; that label is reserved and cannot be used for child WebView creation.
Dialog commands
| Command | Description |
|---|---|
zero-native.dialog.openFile | Show a file open dialog |
zero-native.dialog.saveFile | Show a file save dialog |
zero-native.dialog.showMessage | Show a message dialog |
Dialog commands are always default-deny and require an explicit builtin_bridge policy.
Enabling builtin commands
const app_permissions = [_][]const u8{zero_native.security.permission_window};
.security = .{
.permissions = &app_permissions,
.navigation = .{ .allowed_origins = &.{ "zero://app" } },
},
.builtin_bridge = .{
.enabled = true,
.commands = &.{
.{ .name = "zero-native.window.list", .permissions = .{ "window" }, .origins = .{ "zero://app" } },
.{ .name = "zero-native.window.create", .permissions = .{ "window" }, .origins = .{ "zero://app" } },
.{ .name = "zero-native.webview.create", .permissions = .{ "window" }, .origins = .{ "zero://app" } },
.{ .name = "zero-native.webview.list", .permissions = .{ "window" }, .origins = .{ "zero://app" } },
.{ .name = "zero-native.webview.setFrame", .permissions = .{ "window" }, .origins = .{ "zero://app" } },
.{ .name = "zero-native.webview.navigate", .permissions = .{ "window" }, .origins = .{ "zero://app" } },
.{ .name = "zero-native.webview.setZoom", .permissions = .{ "window" }, .origins = .{ "zero://app" } },
.{ .name = "zero-native.webview.setLayer", .permissions = .{ "window" }, .origins = .{ "zero://app" } },
.{ .name = "zero-native.webview.close", .permissions = .{ "window" }, .origins = .{ "zero://app" } },
.{ .name = "zero-native.dialog.openFile", .origins = .{ "zero://app" } },
.{ .name = "zero-native.dialog.showMessage", .origins = .{ "zero://app" } },
},
},JavaScript usage
await window.zero.windows.create({
label: "tools",
title: "Tools",
width: 420,
height: 320,
});
const preview = await window.zero.webviews.create({
label: "preview",
url: "https://example.com",
frame: { x: 24, y: 24, width: 480, height: 320 },
layer: 10,
bridge: false,
});
await preview.setZoom(1.25);
await preview.setLayer(20);
await preview.close();
const files = await window.zero.invoke("zero-native.dialog.openFile", {
title: "Select a file",
allowMultiple: true,
});
const result = await window.zero.invoke("zero-native.dialog.showMessage", {
style: "warning",
title: "Confirm",
message: "Are you sure?",
primaryButton: "Yes",
secondaryButton: "No",
});See also: Multiple WebViews for frame and layer semantics, Dialogs for the full dialog type reference, and Security for policy details.