Giter VIP home page Giter VIP logo

webview2runtime's Introduction

WebView2Runtime

This package provides the following capabilities for managing and installing the WebView2 runtime:

  • Retrieve version of installed WebView2 runtime
  • Determine if the installed version is older than the required version
  • Download and run the official Microsoft Bootstrapper
  • Run an embedded version of the official Microsoft Bootstrapper
  • Open a browser to the WebView2 download page
  • Utility methods for user notifications and confirmations

Usage

The general workflow should be:

  • Check if there's a version installed using GetInstalledVersion()
  • If so, check it's new enough to support your application using IsOlderThan()
  • Decide what strategy you're comfortable with to inform the user / install the runtime.

Documentation

Please consult the package documentation.

Example

package mypackage

import "github.com/leaanthony/webview2runtime"

func BootstrapRuntime() error {
    var err error
    shouldInstall := true
    message := "The WebView2 runtime is required. Press Ok to install."
    installedVersion := webview2runtime.GetInstalledVersion()
    if installedVersion != nil {
        shouldInstall, err = installedVersion.IsOlderThan("90.0.818.66")
        if err != nil {
            _ = webview2runtime.Error(err.Error(), "Error")
            return err
        }
        if shouldInstall {
            message = "The WebView2 runtime needs updating. Press Ok to install."
        }
    }
    if shouldInstall {
        confirmed, err := webview2runtime.Confirm(message, "Missing Requirements")
        if err != nil {
            return err
        }
        if confirmed {
            installedCorrectly, err := webview2runtime.InstallUsingBootstrapper()
            if err != nil {
                _ = webview2runtime.Error(err.Error(), "Error")
                return err
            }
            if !installedCorrectly {
                err = webview2runtime.Error("The runtime failed to install correctly. Please try again.", "Error")
                return err
            }
        }
    }
    return nil
}

webview2runtime's People

Contributors

fire988 avatar

Stargazers

IceBearG avatar 池边树下 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.