Skip to content

Commit

Permalink
Feature native update (#24)
Browse files Browse the repository at this point in the history
* Update to latest dotnet version

* Update webview.yaml

* Add CMakePreset.json

* Update webview.yaml

* Update webview.yaml

* Change windows build

* Update libraries

* Update README.md

* Update CHANGELOG.md
  • Loading branch information
geaz authored Apr 13, 2022
1 parent d779380 commit f9e0550
Show file tree
Hide file tree
Showing 17 changed files with 23,796 additions and 34 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.101
dotnet-version: 6.0.201
- name: Install dependencies
run: dotnet restore src\SharpWebview\SharpWebview.csproj
- name: Build
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/webview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,13 @@ jobs:
- uses: actions/checkout@v2
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev xvfb -y
- name: Build webview native
uses: ashutoshvarma/action-cmake-build@v1
- name: Get CMake
uses: lukka/get-cmake@latest
- name: Run CMake
uses: lukka/run-cmake@v10
with:
build-dir: ./build
configurePreset: 'ninja'
buildPreset: 'ninja'
- name: Upload artifact
uses: actions/[email protected]
with:
Expand All @@ -24,10 +27,13 @@ jobs:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: Build webview native
uses: ashutoshvarma/action-cmake-build@v1
- name: Get CMake
uses: lukka/get-cmake@latest
- name: Run CMake
uses: lukka/run-cmake@v10
with:
build-dir: ./build
configurePreset: 'ninja'
buildPreset: 'ninja'
- name: Upload artifact
uses: actions/[email protected]
with:
Expand All @@ -38,10 +44,14 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Build webview native
uses: ashutoshvarma/action-cmake-build@v1
- uses: GuillaumeFalourd/[email protected]
- name: Get CMake
uses: lukka/get-cmake@latest
- name: Run CMake
uses: lukka/run-cmake@v10
with:
build-dir: ./build
configurePreset: 'windows'
buildPreset: 'windows'
- name: Upload artifact
uses: actions/[email protected]
with:
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.7.0] - 2022-04-13
### Fixed
- Update to latest webview version

## [0.6.1] - 2020-07-11
### Fixed
- Dispatch delegates pinned until execution
Expand Down
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ endif()
include(FetchContent)
FetchContent_Declare(
webviewNative
GIT_REPOSITORY https://github.com/geaz/webview
GIT_TAG 13a11cfee9be94608ee3add8df05d4f740a320d9
GIT_REPOSITORY https://github.com/webview/webview
GIT_TAG 5d72732c9f5c94241d9a983b512e5fc5698bd1e0
)
FetchContent_Populate(webviewNative)

include_directories(
"${webviewnative_SOURCE_DIR}"
"${webviewnative_SOURCE_DIR}/script/microsoft.web.webview2.0.9.488/build/native/include"
"${CMAKE_CURRENT_SOURCE_DIR}/libs/include"
)
link_directories("${webviewnative_SOURCE_DIR}/script/microsoft.web.webview2.0.9.488/build/native/x64")
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/libs")

add_library(webview SHARED "${webviewnative_SOURCE_DIR}/webview.cc")

if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
target_compile_definitions(webview PRIVATE "WEBVIEW_API=__declspec(dllexport)")
target_link_libraries(webview WebView2Loader.dll.lib)
configure_file(${webviewnative_SOURCE_DIR}/script/microsoft.web.webview2.0.9.488/build/x64/WebView2Loader.dll WebView2Loader.dll COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libs/WebView2Loader.dll WebView2Loader.dll COPYONLY)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_link_libraries(webview PkgConfig::gtk3 PkgConfig::webkit2)
endif()
38 changes: 38 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"version": 3,
"cmakeMinimumRequired": {
"major": 3,
"minor": 21,
"patch": 0
},
"configurePresets": [
{
"name": "ninja",
"displayName": "Ninja Configure Settings",
"description": "Sets build and install directories",
"binaryDir": "${sourceDir}/build",
"generator": "Ninja"
},
{
"name": "windows",
"displayName": "Windows Configure Settings",
"description": "Sets build and install directories",
"binaryDir": "${sourceDir}/build",
"generator": "Visual Studio 17 2022"
}
],
"buildPresets": [
{
"name": "ninja",
"configurePreset": "ninja",
"displayName": "Build with Ninja",
"description": "Build with Ninja"
},
{
"name": "windows",
"configurePreset": "windows",
"displayName": "Build with Visual Studio",
"description": "Build with Visual Studio"
}
]
}
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
[![ReleaseBuild](https://github.com/geaz/sharpWebview/workflows/ReleaseBuild/badge.svg)](https://github.com/geaz/sharpWebview/actions?query=workflow%3AReleaseBuild)
[![WebviewNative](https://github.com/geaz/sharpWebview/workflows/WebviewNative/badge.svg)](https://github.com/geaz/sharpWebview/actions?query=workflow%3AWebviewNative)
[![ReleaseBuild](https://github.com/webview/sharpWebview/workflows/ReleaseBuild/badge.svg)](https://github.com/webview/sharpWebview/actions?query=workflow%3AReleaseBuild)
[![WebviewNative](https://github.com/webview/sharpWebview/workflows/WebviewNative/badge.svg)](https://github.com/webview/sharpWebview/actions?query=workflow%3AWebviewNative)
[![Nuget](https://img.shields.io/nuget/v/SharpWebview?color=green)](https://www.nuget.org/packages/SharpWebview/)
[![Webview Org Chat](https://img.shields.io/badge/chat-on%20discord-7289da.svg)](https://discord.gg/grzBQBP)

# sharpWebview

This repository contains battery included C# bindings for [zserge/webview](https://github.com/zserge/webview). **It only supports x64 systems.**
This repository contains battery included C# bindings for [webview](https://github.com/webview/webview). **It only supports x64 systems.**

# Webview

[zserge/webview](https://github.com/zserge/webview) is a small C/C++ header only library for a cross platform access of a webview control.
[webview](https://github.com/webview/webview) is a small C/C++ header only library for a cross platform access of a webview control.
It uses Edge Chromium, with fallback to the 'old' Edge, on Windows, GTK Webkit on Linux and Cocoa Webkit on macOS.
*sharpWebview* ships precompiled libraries for each system, ready to be used in your next C# project. This repository contains a cmake file to compile webview via *Github Actions* [![WebviewNative](https://github.com/geaz/sharpWebview/workflows/WebviewNative/badge.svg)](https://github.com/geaz/sharpWebview/actions?query=workflow%3AWebviewNative).
*sharpWebview* ships precompiled libraries for each system, ready to be used in your next C# project. This repository contains a cmake file to compile webview via *Github Actions* [![WebviewNative](https://github.com/webview/sharpWebview/workflows/WebviewNative/badge.svg)](https://github.com/webview/sharpWebview/actions?query=workflow%3AWebviewNative).

You are always able to see which webview version *sharpWebview* uses by looking into the [CMakeLists.txt](https://github.com/geaz/sharpWebview/blob/master/CMakeLists.txt) (GIT_TAG option in the *FetchContent_Declare* command). You can find all compiled libraries and used patches in the [libs](https://github.com/geaz/sharpWebview/tree/master/libs) folder of this repository.
You are always able to see which webview version *sharpWebview* uses by looking into the [CMakeLists.txt](https://github.com/webview/sharpWebview/blob/master/CMakeLists.txt) (GIT_TAG option in the *FetchContent_Declare* command). You can find all compiled libraries and used patches in the [libs](https://github.com/webview/sharpWebview/tree/master/libs) folder of this repository.

All patches are also contributed back to [zserge/webview](https://github.com/zserge/webview).

*REMARK:* The nuget uses this [fork](https://github.com/geaz/webview) at the moment, because the work on upstream is stalled at the moment. Because of the many patches it was not possible to maintain it without a fork.
All patches are also contributed back to [webview](https://github.com/webview/webview).

# Get started

Expand Down Expand Up @@ -71,14 +69,14 @@ using(var webview = new Webview())
}
```

The [examples](https://github.com/geaz/sharpWebview/tree/master/examples) folder contains two basic projects. The [*Minimal*](https://github.com/geaz/sharpWebview/tree/master/examples/Minimal) projects shows you a basic example on how to create a cross platform webview and how to open a URL in it.
Please have a look into the documented [*Program.cs*](https://github.com/geaz/sharpWebview/blob/master/examples/Minimal/Program.cs). You are also able to use the *HtmlContent* to provide some HTML which the webview will render.
The [examples](https://github.com/webview/sharpWebview/tree/master/examples) folder contains two basic projects. The [*Minimal*](https://github.com/webview/sharpWebview/tree/master/examples/Minimal) projects shows you a basic example on how to create a cross platform webview and how to open a URL in it.
Please have a look into the documented [*Program.cs*](https://github.com/webview/sharpWebview/blob/master/examples/Minimal/Program.cs). You are also able to use the *HtmlContent* to provide some HTML which the webview will render.

## Run a webserver to serve a javascript application

Besides the *UrlContent* and *HtmlContent*, *sharpWebview* also provides a *HostedContent*. This content type creates a webserver to which the webview will automatically navigate.

To use this content it is necessary to create a *app* folder in your project. Every file you put into this folder will be served by the *HostedContent*. The [*DesktopApp*](https://github.com/geaz/sharpWebview/tree/master/examples/DesktopApp) project is an example of the usage of this content type.
To use this content it is necessary to create a *app* folder in your project. Every file you put into this folder will be served by the *HostedContent*. The [*DesktopApp*](https://github.com/webview/sharpWebview/tree/master/examples/DesktopApp) project is an example of the usage of this content type.
Don't forget to set the files in the *app* folder to *copy always* (see project file for an example).

### HostedContent on Windows systems
Expand All @@ -94,12 +92,12 @@ This adds the Edge Webview Host to the exception list of this limitation. Your b
# Application Distribution
## Windows

The [*DesktopApp*](https://github.com/geaz/sharpWebview/tree/master/examples/DesktopApp) example contains a simple script to create a MSI installer. You are able to take the *wix.bat* and *DesktopApp.wix* files as a starting point for your application. To use the *wix.bat* you need to install the WIX Toolset.
The [*DesktopApp*](https://github.com/webview/sharpWebview/tree/master/examples/DesktopApp) example contains a simple script to create a MSI installer. You are able to take the *wix.bat* and *DesktopApp.wix* files as a starting point for your application. To use the *wix.bat* you need to install the WIX Toolset.

I highly recommend to use [scoop](https://scoop.sh/) to install it. Scoop is a command line installer for easy installation of many different applications. Just run

```
scoop install wixtoolset
```

to install WIX. After this you should be able to execute the *wix.bat* to create a basic installer for the example [*DesktopApp*](https://github.com/geaz/sharpWebview/tree/master/examples/DesktopApp).
to install WIX. After this you should be able to execute the *wix.bat* to create a basic installer for the example [*DesktopApp*](https://github.com/webview/sharpWebview/tree/master/examples/DesktopApp).
2 changes: 1 addition & 1 deletion examples/DesktopApp/DesktopApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions examples/Minimal/Minimal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon>icon.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SharpWebview" Version="0.6.1" />
<PackageReference Include="SharpWebview" Version="0.7.0" />
</ItemGroup>
<ItemGroup>
<None Update="icon.ico">
Expand Down
Binary file modified libs/WebView2Loader.dll
Binary file not shown.
Binary file added libs/WebView2Loader.dll.lib
Binary file not shown.
Binary file added libs/WebView2LoaderStatic.lib
Binary file not shown.
Loading

0 comments on commit f9e0550

Please sign in to comment.