温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/bun/WebView
点击访问原文链接

Bun.WebView object | API Reference | Bun

Bun.WebView object | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/Bun/WebViewNWebView

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Bun/WebViewNWebView

namespace

WebViewnamespace WebViewinterface ClickOptionsbutton?: 'left' | 'right' | 'middle'
clickCount?: 2 | 1 | 3

Number of clicks (1 = single, 2 = double, 3 = triple).

modifiers?: Modifier[]

Modifier keys to hold during the click.

interface ClickSelectorOptionsbutton?: 'left' | 'right' | 'middle'
clickCount?: 2 | 1 | 3

Number of clicks (1 = single, 2 = double, 3 = triple).

modifiers?: Modifier[]

Modifier keys to hold during the click.

timeout?: number

Maximum time in milliseconds to wait for the element to become actionable (attached, visible, stable for 2 frames, not obscured).

interface ConstructorOptionsbackend?: Backend

Browser backend. Defaults to "webkit" on macOS, throws on other platforms unless "chrome" is specified.

console?: ConsoleCapture

Capture page-side console.* calls. See ConsoleCapture.

dataStore?: 'ephemeral' | { directory: string }

Storage backing for cookies, localStorage, IndexedDB, etc.

"ephemeral" (default): in-memory only, nothing written to disk.{ directory }: persistent storage rooted at the given path. Multiple views with the same directory share state.

Chrome backend: directory is per-Chrome-process (--user-data-dir), not per-view. The first view's directory applies to all views spawned in the same Bun process.

headless?: boolean

Only true (headless) is implemented.

height?: number

Viewport height in pixels. Range: [1, 16384].

url?: string

Initial URL to navigate to. The navigation starts before the constructor returns; await view.navigate(otherUrl) or any other operation will wait for it to complete first.

Equivalent to calling view.navigate(url) immediately after construction.

width?: number

Viewport width in pixels. Range: [1, 16384].

interface PressOptionsmodifiers?: Modifier[]

Modifier keys to hold during the keypress.

interface ScrollToOptionsblock?: 'end' | 'center' | 'start' | 'nearest'

Vertical alignment. "nearest" scrolls minimally (no-op if already in view); "center" snaps the element's center to the viewport center.

timeout?: number

Maximum time in milliseconds to wait for the element to exist.

`." data-algolia-static="false" data-algolia-merged="false" data-type="Type alias">type Backend = 'webkit' | 'chrome' | { type: 'chrome'; url: string } | { argv: string[]; path: string; stderr: 'inherit' | 'ignore'; stdout: 'inherit' | 'ignore'; type: 'chrome'; url: false } | { stderr: 'inherit' | 'ignore'; stdout: 'inherit' | 'ignore'; type: 'webkit' }

Browser backend selection.

"webkit" (default): WKWebView. macOS only. Zero external dependencies — uses the system WebKit.framework."chrome": Chrome/Chromium via DevTools Protocol over --remote-debugging-pipe. Works anywhere Chrome is installed. Auto-detects the binary in standard locations; override with backend.path or the BUN_CHROME_PATH environment variable.

The object form lets you pass extra launch flags. Chrome switches are last-wins for duplicates, so argv can override the defaults.

Chrome is spawned once per process — the first new Bun.WebView() call's path/argv/dataStore.directory win; subsequent views reuse the same Chrome instance via Target.createTarget.

Default flags: --remote-debugging-pipe --headless --no-first-run --no-default-browser-check --disable-gpu --user-data-dir=.

void`: custom callback. `type` is the method name (`"log"` | `"warn"` | `"error"` | `"info"` | `"debug"` | ...). Primitive args unwrap to their raw values; object args arrive as a structured descriptor — for Chrome, the CDP `RemoteObject` with `.type`/`.className`/`.description`/`.preview.properties`; for WebKit, the JSON round-trip of the object (lossy for functions/ circular refs, which stringify to their `String(...)` coercion)." data-algolia-static="false" data-algolia-merged="false" data-type="Type alias">type ConsoleCapture = typeof console | (type: string, ...args: unknown[]) => void

Console capture. Called for each console.* invocation in the page.

globalThis.console: forward directly to the parent's console. console.log("hi") in the page prints hi to stdout with Bun's formatter; console.error goes to stderr. Zero JS overhead per call — dispatches through ConsoleClient directly.(type, ...args) => void: custom callback. type is the method name ("log" | "warn" | "error" | "info" | "debug" | ...). Primitive args unwrap to their raw values; object args arrive as a structured descriptor — for Chrome, the CDP RemoteObject with .type/.className/.description/.preview.properties; for WebKit, the JSON round-trip of the object (lossy for functions/ circular refs, which stringify to their String(...) coercion).
type Modifier = 'Shift' | 'Control' | 'Alt' | 'Meta'type VirtualKey = 'Enter' | 'Tab' | 'Space' | 'Backspace' | 'Delete' | 'Escape' | 'ArrowLeft' | 'ArrowRight' | 'ArrowUp' | 'ArrowDown' | 'Home' | 'End' | 'PageUp' | 'PageDown'

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

Bun.WebView object | API Reference | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for namespace bun.WebView | Bun