webview_deno

stars issues ci downloads deno version deno doc license

deno bindings for webview using the webview_rust. Webview is a tiny cross-platform library to render web-based GUIs for desktop applications.


⚠️ This project is still in an early stage of development. Expect breaking changes.


Example Image

Example

import { WebView } from "https://deno.land/x/webview/mod.ts";

const html = `
  <html>
  <body>
    <h1>Hello from deno</h1>
  </body>
  </html>
`;

await new WebView({
  title: "Local webview_deno example",
  url: `data:text/html,${encodeURIComponent(html)}`,
  height: 600,
  resizable: true,
  debug: true,
  frameless: false,
}).run();

you can run this example directly from the web:

$ deno run -A -r --unstable https://deno.land/x/webview/examples/local.ts

or in your development environment:

$ deno run -A -r --unstable app.ts

you can find other examples in the example/ directory.

Documentation

You can find the official documentation here.

Development

Prerequisites

For building webview_deno the same prerequisites as for building deno is required.

Linux dependencies

  • webkit2gtk (to install using apt: sudo apt-get install libwebkit2gtk-4.0-dev)

Building

Building webview_deno can take a nontrivial amount of time depending on your operating system. After the first build most files will be cached so building time will be reduced. Building on Windows requires admin privileges.

For a default build you can use the provided script:

deno run -A scripts/build.ts

which internally runs:

cargo build --release --locked

optionally you can use mshtml:

deno run -A scripts/build.ts mshtml

which internally runs:

cargo build --release --locked --no-default-features

Running

To run webview_deno without automatically downloading the binaries from releases you will need to use the environment variable WEBVIEW_DENO_PLUGIN and set it to the path where the built binaries are located. This is usually file://./target/release. The process of running and using local binaries can be easier to using the dev script:

deno -A scripts/dev.ts [example.ts]

Environment variables

  • WEBVIEW_DENO_PLUGIN - The URL of the plugin
    Due to MSHTML (ie) no longer being enabled by default, the only way to enable it is to set the WEBVIEW_DENO_PLUGIN variable to the path of a binary build built with the --no-default-features flag or using deno -A scripts/build.ts mshtml
  • WEBVIEW_DENO_PLUGIN_BASE - The URL of the plugin except the last part. Ignored if WEBVIEW_DENO_PLUGIN is set.
    When developing locally WEBVIEW_DENO_PLUGIN_BASE should be set to the directory containing the plugin binary, usually file://./target/release. Otherwise, don’t set this.
  • WEBVIEW_DENO_DEBUG - Disable cache and enable logs for deno-plugin-prepare. Used for debugging.

Dependencies

Deno

Rust

Other

Contribution

Pull request, issues and feedback are very welcome. Code style is formatted with denon fmt (which internally runs deno fmt and cargo fmt) and commit messages are done following Conventional Commits spec.

Licence

Copyright 2020-present, the webview_deno team. All rights reserved. MIT license.