npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cordova-plugin-webviewselector

v0.3.2

Published

plugin allowing developers that are using cordova-plugin-crosswalk-webview to switch dynamically between Crosswalk webview and system one

Downloads

4

Readme

cordova-plugin-webviewselector

This plugin is designed to allow developers that are using Crosswalk with cordova-plugin-crosswalk-webview to be able to switch dynamically between Crosswalk webview and default system webview (on Android).

Why anyone would want that?

Crosswalk being not maintained anymore, the future is in the use of system's webview. But on older devices you may want to keep a well working older version of Chromium. You may also want to let your application's users to switch themselves between engines for some reasons, like if your heuristic to select the best engine automatically depending on their device is not perfect.

How is it working?

This plugin is only changing Cordova's webview setting dynamically before the creation of the webview.

Compatibility

Currently tested with:

  • Cordova Android Engine 4.1.1.
  • Cordova CLI 6.5.0.

TODO: test on more recent versions.

Prerequisites

You need to have cordova-plugin-crosswalk-webview installed in your project.

Installation

After having added the plugin to your project, you can add the following line in your config.xml (optional):

<preference name="webviewselector-xwalkMaxSdkVersion" value="23" />

This controls which webview engine will be used by default based on Android API level. Up to this preference's value, Crosswalk will be used. Above, it will be system's webview.

If you omit this setting, default value is 23: Crosswalk will be used on all devices up to Android 6.0 and system webview starting with Android 7.0.

Possible permission conflict with other plugins

This plugin requires the WRITE_EXTERNAL_STORAGE permission on Android 4.3 (SDK version 18) and less (further versions are allowing an application to write in its own application-specific directories without it):

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" android:maxSdkVersion="18"/>

If you are using another plugin requiring the same permission but without (or different) condition, Cordova is not able to merge them alone, you have to manually keep the one with the larger scope. More information here.

Usage

WebViewSelector is available on: window.cordova.plugins.WebViewSelector.

WebViewType

Contains available engine ids:

WebViewType.SYSTEM
WebViewType.CROSSWALK

currentEngine

Contains id of current engine:

var ws = window.cordova.plugins.WebViewSelector;
if (ws.currentEngine === ws.WebViewType.CROSSWALK) {
	// ...
}

availableEngines

Array of available engines ids. If Crosswalk is not installed it will only contain WebViewType.SYSTEM.

var ws = window.cordova.plugins.WebViewSelector;
if (ws.availableEngines.length > 1) {
	// we have at least 2 engines available
}

setEngine

Change webview engine. Application needs to be restarted for change to take effect, window.location.reload() being not enough for that. It's possible to kill the application programmatically with navigator.app.exitApp().

var ws = window.cordova.plugins.WebViewSelector;
ws.setEngine(ws.WebViewType.SYSTEM, function (error) {
	if (error) {
		return console.error(error);
	}
	alert('Kill and restart application for change to take effect.');
});

Manual switch

In addition to javascript interface, user can connect his phone to a computer and drop a file named webview.txt containg 0 for system webview or 1 for Crosswalk inside Internal storage/Android/data/yourAppId/files/. This setting will prevail over any other (TODO: it should have an effect only during the first restart and be automatically deleted).