A Kotlin binding to webview, a tiny cross-platform webview library, supports Java and Native.

Overview

webviewko

Kotlin Kotlin license

release Gradle CI GitHub last commit JitPack

English | 中文(简体) | 中文(繁體)

webviewko provides a Kotlin/JVM and a Kotlin/Native(experimental) binding to webview, a tiny cross-platform webview library to build modern cross-platform GUIs using WebView2, WebKit and WebKitGTK.

screenshot

Getting Started

1. Import webviewko

If you're using a build system like Gradle or Maven, see webviewko in JitPack.io or GitHub Packages

If you want to use jar files, see GitHub Release

2. Use webviewko

For Kotlin/JVM and Kotlin/Native:

import com.github.winterreisender.webviewko.WebviewKo

WebviewKo().run {
    title("Title")
    size(800, 600)
    url("https://example.com")
    show()
}

For Java:

import com.github.winterreisender.webviewko.WebviewKo;

WebviewKo webview = new WebviewKo(0);
webview.title("Test");
webview.size(1024,768,WebviewKo.WindowHint.None);
webview.url("https://example.com");
webview.show();

3. Interact with webview

You can use bind,init,dispatch and eval to interact with your webview:

Tap me
You tapped 0 time(s).
""".trimIndent()) show() }">
import com.github.winterreisender.webviewko.WebviewKo

WebviewKo().run {
    title("Test")
    init("""console.log("Hello, from  init")""")
    bind("increment") {
        val r :Int = Regex("""\["(\d+)"]""").find(it!!)!!.groupValues[1].toInt() + 1
        println(r.toString())
        if(r==8) terminate()
        "{count: $r}"
    }
  
    html("""
        
You tapped 0 time(s).
""".trimIndent()) show() }

Documentation

Demos

A commandline interface: Winterreisender/webviewkoCLI

Contribution

All suggestions, pull requests, issues and other contributions are welcome and appreciated.

Credits

Project License
wiverson/webviewjar MIT
webview_csharp MIT
webview MIT
JNA LGPL-2.1-or-later OR Apache-2.0
Microsoft Webview2 See the License
Kotlin & kotlinx Apache-2.0

License

Copyright 2022 Winterreisender and other contributors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.

SPDX short identifier: Apache-2.0

OSI Approved

You might also like...
A tiny Android app that can receive WhatsApp group message export files and parse message history stats.

A tiny Android app that can receive WhatsApp group message export files and parse message history stats.

📲💬 react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in android and iOS devices.
📲💬 react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in android and iOS devices.

React Native Fontext react-native-fontext is a lightweight library to integrate fonts in your React Native application that works seamlessly in androi

android-trinity is tiny proactive framework with much of the scaffolding code  required to start a new Android Application.
android-trinity is tiny proactive framework with much of the scaffolding code required to start a new Android Application.

android-trinity This is tiny framework with much of the scaffolding code (with some nice utilities and prepared source code) required to start a new A

Clipeus - Tiny app to clean clipboard
Clipeus - Tiny app to clean clipboard

Clipeus Clipboard cleaner. Tiny app to clean clipboard. No UI. Click on the app

Tiny app to monitor permission changes.
Tiny app to monitor permission changes.

Catcher Permission monitor. Tiny app to monitor permission changes. If any app will get INTERNET permission after an update you will get a notificatio

A blogging mobile application built with Kotlin using MVC design pattern and Take some advantage of Jetpack , View & Data Binding It's a mimic for Tumblr application , But a little prettier than him 😉
A blogging mobile application built with Kotlin using MVC design pattern and Take some advantage of Jetpack , View & Data Binding It's a mimic for Tumblr application , But a little prettier than him 😉

A blogging mobile application built with Kotlin using MVC design pattern and Take some advantage of Jetpack , View & Data Binding It's a mimic for Tum

NativeScript empowers you to access native platform APIs from JavaScript directly. Angular, Capacitor, Ionic, React, Svelte, Vue and you name it compatible.
NativeScript empowers you to access native platform APIs from JavaScript directly. Angular, Capacitor, Ionic, React, Svelte, Vue and you name it compatible.

NativeScript empowers you to access native APIs from JavaScript directly. The framework currently provides iOS and Android runtimes for rich mobile de

A Python native extension written in Kotlin Native

Kotlin Python Ext This is a proof of concept for a Python extension in Kotlin. It is recommended to read the Official Python C API Documentation befor

OSGeo4A is a build environment to cross-compile opensource GIS software for android devices

OSGeo4A This provides a set of scripts to build opensource geo tools for Android. This is Experimental Dependencies instructions you need a JDK v8 or

Comments
  • No matching variant of com.github.winterreisender.webviewko:webviewko-js:0.5.0 was found.

    No matching variant of com.github.winterreisender.webviewko:webviewko-js:0.5.0 was found.

    When adding the following to my dependencies:

    repositories {
        jcenter()
        maven {
            url "https://jitpack.io/"
        }
        mavenCentral()
        maven {
            url = uri("https://maven.pkg.github.com/Winterreisender/webviewko")
            credentials {
                username = local.get("username")
                password = local.get("token")
            }
        }
    }
    
    ...
    // Include is a custom config i've made that jar in jars dependencies, ignore.
    implementation include("com.github.winterreisender:webviewko:0.5.0")
    implementation include("com.github.winterreisender:webviewko-jvm:0.5.0")
    

    I get the following error when running build:

    Execution failed for task ':compileJava'.
    > Could not resolve all files for configuration ':compileClasspath'.
       > Could not resolve com.github.winterreisender.webviewko:webviewko-js:0.5.0.
         Required by:
             project : > com.github.winterreisender:webviewko:0.5.0
          > No matching variant of com.github.winterreisender.webviewko:webviewko-js:0.5.0 was found. The consumer was configured to find an API of a library compatible with Java 17, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally but:
              - Variant 'jsApiElements-published' capability com.github.winterreisender.webviewko:webviewko-js:0.5.0 declares a library:
                  - Incompatible because this component declares a usage of 'kotlin-api' of a component and the consumer needed an API of a component
                  - Other compatible attributes:
                      - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                      - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                      - Doesn't say anything about its target Java version (required compatibility with Java 17)
                      - Doesn't say anything about its elements (required them preferably in the form of class files)
              - Variant 'jsRuntimeElements-published' capability com.github.winterreisender.webviewko:webviewko-js:0.5.0 declares a library:
                  - Incompatible because this component declares a usage of 'kotlin-runtime' of a component and the consumer needed an API of a component
                  - Other compatible attributes:
                      - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                      - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                      - Doesn't say anything about its target Java version (required compatibility with Java 17)
                      - Doesn't say anything about its elements (required them preferably in the form of class files)
       > Could not resolve com.github.winterreisender.webviewko:webviewko-linuxx64:0.5.0.
         Required by:
             project : > com.github.winterreisender:webviewko:0.5.0
          > No matching variant of com.github.winterreisender.webviewko:webviewko-linuxx64:0.5.0 was found. The consumer was configured to find an API of a library compatible with Java 17, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally but:
              - Variant 'nativeApiElements-published' capability com.github.winterreisender.webviewko:webviewko-linuxx64:0.5.0 declares a library:
                  - Incompatible because this component declares a usage of 'kotlin-api' of a component and the consumer needed an API of a component
                  - Other compatible attributes:
                      - Doesn't say anything about how its dependencies are found (required its dependencies declared externally)
                      - Doesn't say anything about its target Java environment (preferred optimized for standard JVMs)
                      - Doesn't say anything about its target Java version (required compatibility with Java 17)
                      - Doesn't say anything about its elements (required them preferably in the form of class files)
    
    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.
    
    bug 
    opened by mineblock11 2
  • Exception happens when switching to Kotlin/JS IR compiler

    Exception happens when switching to Kotlin/JS IR compiler

    The Kotlin/JS LEGACY compiler we're using, is deprecated and should be replaced to new IR compiler. But a strange issue happens when compilering:

    Module "com.github.winterreisender:webviewko" has a reference to symbol com.github.winterreisender.webviewko/WebviewKo.WindowHint|null[1]. Neither the module itself nor its dependencies contain such declaration.
    
    This could happen if the required dependency is missing in the project. Or if there is a dependency of "com.github.winterreisender:webviewko" that has a different version in the project than the version that "com.github.winterreisender:webviewko" was initially compiled with. Please check that the project configuration is correct and has consistent versions of all required dependencies.
    
    The list of "com.github.winterreisender:webviewko" dependencies that may lead to conflicts:
    1. "kotlin" (a library with unknown version)
    2. "org.jetbrains.kotlinx:kotlinx-serialization-core" (a library with unknown version)
    3. "org.jetbrains.kotlinx:kotlinx-serialization-json" (a library with unknown version)
    
    Project dependencies:
    +--- kotlin
    +--- kotlin-test
    |    \--- kotlin
    +--- com.github.winterreisender:webviewko
    |    ^^^ This module requires symbol com.github.winterreisender.webviewko/WebviewKo.WindowHint|null[1].
    |    +--- kotlin
    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core
    |    |    \--- kotlin
    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json
    |         +--- kotlin
    |         \--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
    +--- com.github.winterreisender:webviewko_test
    |    +--- kotlin
    |    +--- kotlin-test (*)
    |    +--- com.github.winterreisender:webviewko (*)
    |    |    ^^^ This module requires symbol com.github.winterreisender.webviewko/WebviewKo.WindowHint|null[1].
    |    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
    |    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
    +--- org.jetbrains.kotlinx:kotlinx-serialization-core (*)
    \--- org.jetbrains.kotlinx:kotlinx-serialization-json (*)
    
    (*) - dependencies omitted (listed previously)
    
    bug help wanted 
    opened by Winterreisender 0
  • Use static lib in Kotlin/Native

    Use static lib in Kotlin/Native

    Since currently webviewko is using dynamic lib, it's quite difficult for users to compile and link. We need try to solve issues during compilitation via Kotlin/Native.

    enhancement 
    opened by Winterreisender 1
  • Use official Java backend

    Use official Java backend

    Since webview now have a new official Java binding, it's probably the time to shift our own Kotlin/JVM binding to the offical one, in order to reduce our burden. We'll focus on Kotlin/Native and Kotlin/JS and try to contribute to the Java binding.

    We need make a decision:

    • [ ] Continue to use pure Kotlin/JVM binding
    • [ ] Use official Java binding

    If I have time... . I'm really busy currently.

    enhancement discussing 
    opened by Winterreisender 0
Releases(0.5.0)
  • 0.5.0(Sep 15, 2022)

    Common

    • add: libPath
    • add: start
    • add: destroy

    Native

    • remove cDispatch and cBind

    JVM

    • add: Apple M1 support from webview_deno

    JS

    • initial Kotlin/JS support
    • fix: wrong usage of isError
    Source code(tar.gz)
    Source code(zip)
  • v0.4.0(Aug 22, 2022)

    v0.4.0 [ Radio Waves ]

    GitHub release (by tag)

    Highlights

    Common

    • add json parameter for JSRejectException

    JVM

    • add support for Windows ARM64, Windows x86 (Only x64 are tested)

    Native

    • add support for concurrent mutability. Now you can use bind,dispatch freely in multi thread applications
    • mark cBind and cDispatch as Deprecated since concurrent mutability is supported

    Download

    • dll/so/dylib: https://github.com/Winterreisender/webviewko/tree/4e61c26d8d978daa69a5a2ebb406004aa512ab84/src/nativeMain/nativeInterop/cinterop/webview
    • GitLab Packages: https://gitlab.com/Winterreisender/webviewko/-/packages/
    • GitHub Packages: https://github.com/Winterreisender?tab=packages&repo_name=webviewko
    Source code(tar.gz)
    Source code(zip)
    webviewko-0.4.0-all.jar(4.22 MB)
  • 0.3.0(Jul 27, 2022)

    v0.3.0「Flying Circus」

    GitHub release (by tag)

    Highlights

    Common

    • Update Kotlin to 1.7.10
    • Update webview to commit2022.7.26-8409184
    • Use -static-libgcc and -static-libstdc++ during compilation so that it doesn't rely on libgcc_s_seh.dll and libstdc++-6.dll on Windows anymore
    • Throw Exception when failed to create webview instead of NullPointerException
    • Add JSRejectException which will be caught by bind and thrown to JS (reject the Promise)
    • Migrate to GitLab Packages so that users won't need authentication anymore.

    JVM

    • Remove deprecated getInstance
    • Fix invalid memory access when failed to create webview. https://github.com/webview/webview/issues/799

    Native

    • Add cBind and cDispatch providing a C API for Kotlin/Native
    • Fix crash when failed to create webview. https://github.com/webview/webview/issues/799
    • Prevent memory leak by adding disposeList for bind and dispose directly for dispatch
    • call initRuntimeIfNeeded() in bind and dispatch for better C-interop

    Known Issues

    -

    Download

    dll/so/dylib: https://github.com/Winterreisender/webviewko/tree/4e61c26d8d978daa69a5a2ebb406004aa512ab84/src/nativeMain/nativeInterop/cinterop/webview

    GitLab Packages: https://gitlab.com/Winterreisender/webviewko/-/packages/

    Source code(tar.gz)
    Source code(zip)
    webviewko-0.3.0-docs.zip(355.30 KB)
    webviewko-0.3.0-licenses.zip(6.29 KB)
    webviewko-0.3.0.jar(3.78 MB)
    webviewko-mavenLocal-0.3.0.zip(377.37 KB)
  • 0.2.0(Jul 7, 2022)

    v0.2.0 「WhiteBox」

    GitHub release (by tag)

    Highlights

    • Update webview
    • Add Kotlin/Native support for Windows and Linux

    Full Changelog: https://github.com/Winterreisender/webviewko/compare/0.1.1...0.2.0

    Known Issues

    • When failed to create webview,for example the webview2 runtime is not installed, it won't throw an exception in Kotlin/Native and throw invalid memory access in Kotlin/JVM. We have feedback this issue to webview with a solution https://github.com/webview/webview/issues/799. Update: This is fixed in https://github.com/Winterreisender/webviewko/commit/3aa6fef768c3aecc533fad68ea6699256c9da200
    • Need libgcc_s_seh-1.dll and libstdc++-6.dll to works on Windows. These dependencies will be removed in the next version

    Upstream

    Source code(tar.gz)
    Source code(zip)
    webviewko-0.2.0-all.jar(3.93 MB)
    webviewko-0.2.0-maven-packages.zip(553.13 KB)
    webviewko-kdoc-0.2.0.zip(330.52 KB)
  • 0.2.0-dev.2(Jul 3, 2022)

    • add Kotlin/Native/Linux support

    For JVM and Kotlin/Native/Linux, see JitPack.io for build systems instructions.
    Since JitPack.io dose not support Windows, You need compiled yourself by cloning and gradle publishToMavenLocal

    An example for Gradle (Kotlin DSL):

    repositories {
        maven {
            url = uri("https://jitpack.io")
            content {
                includeGroup("com.github.Winterreisender.webviewko")
            }
        }
    }
    dependencies {
        implementation("com.github.Winterreisender.webviewko:webviewko:0.2.0-dev.2")          //For Kotlin Multiplatform
        implementation("com.github.Winterreisender.webviewko:webviewko-jvm:0.2.0-dev.2")      //For Kotlin/JVM and Java
        implementation("com.github.Winterreisender.webviewko:webviewko-linuxX64:0.2.0-dev.2") //For Kotlin/Native/Linux
        //implementation("com.github.Winterreisender.webviewko:webviewko-mingwX64:0.2.0-dev.2") //For Kotlin/Native/Windows
    }
    

    You also need to copy the libwebview.dll or libwebview.so to the same folder as you program.

    Source code(tar.gz)
    Source code(zip)
    JVM-and-Linux-Maven.zip(536.71 KB)
  • v0.2.0-dev.1(Jul 2, 2022)

    Because JitPack.io does not support Winodws for building Kotlin/Native Mingw and GitHub Maven service doesn’t allow for unauthorized access (see How to allow unauthorised read access to GitHub packages maven repository? ), you can either import jars and klibs manually or authorise with GitHub

    • Add Kotlin/Native MingwX64 support
    • Move to GitHub Packages
    • remove: initJS, replaced with init

    Full Changelog: https://github.com/Winterreisender/webviewko/compare/0.1.0-dev.2...v0.2.0-dev.1

    Source code(tar.gz)
    Source code(zip)
  • 0.1.1(Jun 29, 2022)

  • 0.1.0-dev.2(Jun 29, 2022)

Owner
Winterreisender
A C/C++ and Kotlin/Java amateur.
Winterreisender
Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in the official package.

@mccsoft/react-native-matomo Matomo wrapper for React-Native. Supports Android and iOS. Fixed issues for native platforms build that are present in th

MCC Soft 4 Dec 29, 2022
Tonomy ID is the cross-platform mobile wallet (Android and iOS) for public and private EOSIO blockchains

Tonomy ID is the cross-platform mobile wallet (Android and iOS) for public and private EOSIO blockchains. This application allows you to sign transactions on the block chain, share your DID and Verifiable Credentials containing your identity with others in a consensual way and log into web2 and web3 applications. If you lose your phone several mechanisms exist to allow you to recover your account without trusting anyone with custody of your private keys.

null 7 Dec 24, 2022
Money Manager Ex is a free, open-source, cross-platform, easy-to-use personal finance software

Money Manager Ex is a free, open-source, cross-platform, easy-to-use personal finance software. It primarily helps organize one's finances and keeps track of where, when and how the money goes.

Money Manager EX 1.2k Dec 31, 2022
CoolReader 3 - cross platform open source e-book reader

CoolReader 3 - cross platform open source e-book reader (c) Vadim Lopatin, 1998-2018 Development is moved to GitHub https://github.com/buggins/coo

Vadim Lopatin 302 Jan 4, 2023
An easy, cross-platform method of keeping track of other people's timezones

TimezoneDB TimezoneDB is an easy, cross-platform method of keeping track of others' timezones. This project is inspired by PronounDB, and we'd like to

Synapse Technologies, LLC 13 Nov 16, 2022
CMPLR Technologies 8 Apr 5, 2022
A Android Web IDE supports code auto-completion and highlight, plugin (Supports Html, Css, JS, Json, Php etc)

WebDevOps A Android Web IDE supports code auto-completion and highlight, plugin (Supports Html, Css, JS, Json, Php etc) Join us QQ group number: 10314

SuMuCheng 22 Jan 3, 2023
Native-loader - Safely load native libraries in Java

Native Loader ??️ Safe native loading in Java based off of the native-loader use

Mixtape 1 Oct 19, 2022
A multi-platform Collins Dictionary client, supports for Desktop(Windows/Linux/MacOS) and Android.

Collins Dictionary This is a multi-platform Collins Dictionary client, supports for Desktop(Windows/Linux/MacOS) and Android. For Linux and MacOS, ple

KonYaco 57 Dec 30, 2022
To Do List App is built in Kotlin using Material 3, Data Binding, Navigation Component Graphs, Room persistence library, Kotlin coroutines, LiveData, Dagger Hilt, and Notifications following MVVM Architecture.

ToDoListApp ToDoList App demonstrates modern Android development with Hilt, Coroutines, LiveData, Jetpack (Room, ViewModel), and Material 3 Design bas

Naman Garg 10 Jan 8, 2023