Skip to content

Latest commit

 

History

History
79 lines (56 loc) · 2.33 KB

README.md

File metadata and controls

79 lines (56 loc) · 2.33 KB

@justbe/webview Deno Client

A light, cross-platform library for building web-based desktop apps with Deno.

Installation

import { createWebView } from "jsr:@justbe/webview";

Example

import { createWebView } from "jsr:@justbe/webview";

using webview = await createWebView({
  title: "Example",
  html: "<h1>Hello, World!</h1>",
  devtools: true,
});

webview.on("started", async () => {
  await webview.openDevTools();
  await webview.eval("console.log('This is printed from eval!')");
});

await webview.waitUntilClosed();

You can run this yourself with:

deno run https://raw.githubusercontent.com/zephraph/webview/refs/heads/main/examples/simple.ts

Check out the examples directory for more examples.

Permissions

When executing this package, it checks to see if you have the required binary for interfacing with the OS's webview. If it doesn't exist, it downloads it to a cache directory and executes it. This yields a few different permission code paths to be aware of.

Binary not in cache

This will be true of a first run of the package. These are the following permission requests you can expect to see:

  • Read HOME env -- Used to locate the cache directory
  • Read /webview/webview- -- Tries to read the binary from cache
  • net to github.com:443 -- Connects to GitHub releases to try to download the binary (will be redirected)
  • net to objects.githubusercontent.com:443 -- GitHub's CDN for the actual download
  • Read /webview/ -- Reads the cache directory
  • Write /webview/webview- -- Writes the binary
  • Run /webview/webview- -- Runs the binary

Binary cached

On subsequent runs you can expect fewer permission requests:

  • Read HOME env -- Use to locate the cache directory
  • Read /deno-webview/deno-webview-
  • Run /deno-webview/deno-webview-

Using a Custom Binary

You can specify a custom binary path using the WEBVIEW_BIN environment variable. When set and allowed, this will bypass the default binary resolution process. In this case, only one permission is needed:

  • Run <WEBVIEW_BIN>

Note that this environment variable will never be explicitly requested. If the script detects it's not allowed to read this env var it just skips this code path altogether.