Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ FodyWeavers.xsd

# JetBrains Rider
*.sln.iml
/Binary/net7.0
/Binary/net8.0
/Binary
/.idea/.idea.Avalonia.WebView/.idea/indexLayout.xml
/.idea
Expand Down
8 changes: 4 additions & 4 deletions Build/Directory.build.common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

<Project>
<!-- Define NETSTANDARD2_1_OR_GREATER for .NET Standard 2.1 targets and above -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net8.0'">
<DefineConstants>NETSTANDARD2_1_OR_GREATER</DefineConstants>
</PropertyGroup>

<!-- Configure trimming for projects on .NET 6 and above -->
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net7.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net8.0'">
<EnableTrimAnalyzer>true</EnableTrimAnalyzer>
<IsTrimmable>true</IsTrimmable>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net6.0'">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net8.0'">
<PackageReference Include="PolySharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>build; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>

<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net6.0'">
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0' OR '$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net8.0'">
<PolySharpIncludeGeneratedTypes>
System.Diagnostics.CodeAnalysis.DoesNotReturnAttribute;
System.Diagnostics.CodeAnalysis.MaybeNullWhenAttribute;
Expand Down
26 changes: 13 additions & 13 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<AvaloniaVersion>11.0.0</AvaloniaVersion>
<AvaloniaVersion>11.0.10</AvaloniaVersion>
<AntDesignVersion>11.0.0</AntDesignVersion>
<Avalonia_I_Want_To_Use_Private_Apis_In_Nuget_Package_And_Promise_To_Pin_The_Exact_Avalonia_Version_In_Package_Dependency>true</Avalonia_I_Want_To_Use_Private_Apis_In_Nuget_Package_And_Promise_To_Pin_The_Exact_Avalonia_Version_In_Package_Dependency>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="GtkSharp" Version="3.24.24.95" />
<PackageVersion Include="Microsoft.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Abstractions" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Abstractions" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.FileProviders.Physical" Version="8.0.0" />
<PackageVersion Include="Microsoft.Web.WebView2" Version="1.0.1823.32" />
<PackageVersion Include="System.Buffers" Version="4.5.1" />
<PackageVersion Include="System.Runtime.CompilerServices.Unsafe" Version="6.0.0" />
<PackageVersion Include="System.Text.Encodings.Web" Version="7.0.0" />
<PackageVersion Include="System.Text.Encodings.Web" Version="8.0.0" />
<PackageVersion Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<PackageVersion Include="WebkitGtkSharp" Version="3.24.24.95" />
<PackageVersion Include="XamarinMac" Version="1.0.0" />
Expand All @@ -39,36 +39,36 @@
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Skia" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.1" />
<PackageVersion Include="Xamarin.AndroidX.Core.SplashScreen" Version="1.0.1.7" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="DryIoc" Version="5.4.1" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
<PackageVersion Include="DryIoc" Version="5.4.3" />
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
<PackageVersion Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
<PackageVersion Include="System.Memory" Version="4.5.5" />
<PackageVersion Include="System.Runtime" Version="4.3.1" />
<PackageVersion Include="System.Reflection.Emit.ILGeneration" Version="4.3.0" />
<PackageVersion Include="System.Reflection.Emit" Version="4.7.0" />
<PackageVersion Include="System.Reflection.Emit.Lightweight" Version="4.7.0" />
<PackageVersion Include="System.Numerics.Vectors" Version="4.5.0" />
<PackageVersion Include="System.ComponentModel.Annotations" Version="5.0.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="7.0.0" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="AntDesign.Avalonia" Version="$(AntDesignVersion)" />
<PackageVersion Include="AntDesign.Toolkit" Version="$(AntDesignVersion)" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="Masa.Blazor" Version="1.0.0-rc.2" />
<PackageVersion Include="Masa.Blazor" Version="1.5.3" />
</ItemGroup>
<ItemGroup>
<PackageVersion Include="PolySharp" Version="1.13.2" />
<PackageVersion Include="PolySharp" Version="1.14.1" />
<PackageVersion Include="MonoMac.NetStandard" Version="0.0.4" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0' OR '$(TargetFramework)' == 'net7.0-windows'">
<PackageVersion Include="Microsoft.AspNetCore.Components.WebView" Version="7.0.9" />
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0' OR '$(TargetFramework)' == 'net8.0-windows'">
<PackageVersion Include="Microsoft.AspNetCore.Components.WebView" Version="8.0.6" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0' OR '$(TargetFramework)' == 'net6.0-windows'">
<PackageVersion Include="Microsoft.AspNetCore.Components.WebView" Version="6.0.16" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net7.0;net6.0</TargetFrameworks>
<TargetFrameworks>net8.0</TargetFrameworks>
<OutputPath>$(RepositoryDirectory)_blazorwebview\</OutputPath>
</PropertyGroup>

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ English| [简体中文](./README.zh-CN.md)

> use Webkit Webview for Linux (if not please install [sudo apt-get libwebkit2gtk-4-37])

> use Android.Webkit.WebView for Android (this is in Microsoft-Android [net5.0-Android; net6.0-Android; net7.0-Android])
> use Android.Webkit.WebView for Android (this is in Microsoft-Android [net5.0-Android; net6.0-Android; net8.0-Android])

> use WKWebView[UIKit] for iOS (this is in Microsoft-iOS [net5.0-ios; net6.0-ios; net7.0-ios])
> use WKWebView[UIKit] for iOS (this is in Microsoft-iOS [net5.0-ios; net6.0-ios; net8.0-ios])

| Platform | Technologies |
|:-------------------------|:-----------------------|
Expand Down
4 changes: 2 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ WebView for avalonia

> 在 Linux 上使用 Webkit Webview(如果没有,请安装 [sudo apt-get libwebkit2gtk-4-37])

> 在 Android 上使用 Android.Webkit.WebView(这是在 Microsoft-Android 中的 [net5.0-Android; net6.0-Android; net7.0-Android])
> 在 Android 上使用 Android.Webkit.WebView(这是在 Microsoft-Android 中的 [net5.0-Android; net6.0-Android; net8.0-Android])

> 在 iOS 上使用 WKWebView[UIKit](这是在 Microsoft-iOS 中的 [net5.0-ios; net6.0-ios; net7.0-ios])
> 在 iOS 上使用 WKWebView[UIKit](这是在 Microsoft-iOS 中的 [net5.0-ios; net6.0-ios; net8.0-ios])

| 平台 | 技术 |
|:-------------------------|:-----------------------|
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net8.0</TargetFramework>
<RootNamespace>AvaloniaBlazorWebView</RootNamespace>
</PropertyGroup>

Expand Down
4 changes: 3 additions & 1 deletion Source/Avalonia.BlazorWebView/BlazorWebView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace AvaloniaBlazorWebView;
using AvaloniaWebView.Shared.Interfaces;

namespace AvaloniaBlazorWebView;

public sealed partial class BlazorWebView : Control, IVirtualWebView<BlazorWebView>, IWebViewEventHandler, IVirtualWebViewControlCallBack, IWebViewControl, IAsyncDisposable
{
Expand Down
46 changes: 46 additions & 0 deletions Source/Avalonia.WebView/WebView-Cookies.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using WebViewCore.Models;

namespace AvaloniaWebView;

partial class WebView
{
public Task AddCookie(AvaloniaWebViewCookie cookie)
{
if (_platformWebView is null || !_platformWebView.IsInitialized)
{
throw new InvalidOperationException("WebView is not initialized.");
}

return _platformWebView.AddCookie(cookie);
}

public Task<List<AvaloniaWebViewCookie>?> GetCookies(string url)
{
if (_platformWebView is null || !_platformWebView.IsInitialized)
{
throw new InvalidOperationException("WebView is not initialized.");
}

return _platformWebView.GetCookies(url);
}

public Task RemoveCookie(AvaloniaWebViewCookie cookie)
{
if (_platformWebView is null || !_platformWebView.IsInitialized)
{
throw new InvalidOperationException("WebView is not initialized.");
}

return _platformWebView.RemoveCookie(cookie);
}

public Task ClearCookies()
{
if (_platformWebView is null || !_platformWebView.IsInitialized)
{
throw new InvalidOperationException("WebView is not initialized.");
}

return _platformWebView.ClearCookies();
}
}
4 changes: 3 additions & 1 deletion Source/Avalonia.WebView/WebView.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace AvaloniaWebView;
using AvaloniaWebView.Shared.Interfaces;

namespace AvaloniaWebView;

public sealed partial class WebView : Control, IVirtualWebView<WebView>, IEmptyView, IWebViewEventHandler, IVirtualWebViewControlCallBack, IWebViewControl
{
Expand Down
1 change: 1 addition & 0 deletions Source/AvaloniaWebView.Shared/AppBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Avalonia;
using AvaloniaWebView.Shared.Core;
using AvaloniaWebView.Shared.Interfaces;

namespace AvaloniaWebView.Shared;
public static class AppBuilderExtensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace AvaloniaWebView.Shared.Core;
using AvaloniaWebView.Shared.Interfaces;

namespace AvaloniaWebView.Shared.Core;
internal class AvaloniaHandlerCollection : List<Type>, IAvaloniaHandlerCollection
{

Expand Down
1 change: 1 addition & 0 deletions Source/AvaloniaWebView.Shared/Handlers/ViewHandler.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Avalonia.Controls;
using Avalonia.Controls.Platform;
using Avalonia.Platform;
using AvaloniaWebView.Shared.Interfaces;
using System.Runtime.InteropServices;
using WebViewCore;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Collections;

namespace AvaloniaWebView.Shared;
namespace AvaloniaWebView.Shared.Interfaces;
public interface IAvaloniaHandlerCollection : IList<Type>, ICollection<Type>, IEnumerable<Type>, IEnumerable
{

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AvaloniaWebView.Shared;
namespace AvaloniaWebView.Shared.Interfaces;
public static class IAvaloniaHandlerCollectionExtensions
{
public static IAvaloniaHandlerCollection AddHandler<TType, TTypeRender>(this IAvaloniaHandlerCollection handlersCollection)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AvaloniaWebView.Shared;
namespace AvaloniaWebView.Shared.Interfaces;
public interface IPropertyMapper
{
IEnumerable<string> GetKeys();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.ComponentModel;

namespace AvaloniaWebView.Shared;
namespace AvaloniaWebView.Shared.Interfaces;
public interface IPropertyMapper<TVirtualView, TViewHandler> : IPropertyMapper where TVirtualView : INotifyPropertyChanged
{
void Add(string key, Action<TViewHandler, TVirtualView> action);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Avalonia.Controls;
using WebViewCore;

namespace AvaloniaWebView.Shared;
namespace AvaloniaWebView.Shared.Interfaces;

public interface IViewHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using WebViewCore;
using WebViewCore.Configurations;

namespace AvaloniaWebView.Shared;
namespace AvaloniaWebView.Shared.Interfaces;

public interface IViewHandlerProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Avalonia.WebView.Android;
using AvaloniaWebView.Shared.Interfaces;

namespace Avalonia.WebView.Android;

public static class AppBuilderExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0-android</TargetFramework>
<TargetFramework>net8.0-android</TargetFramework>
</PropertyGroup>

<Import Project="$(BuildToolsDirectory)Directory.Packages.targets" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Avalonia.WebView.Android.Core;

public partial class AndroidWebViewCore : IPlatformWebView<AndroidWebViewCore>
{
public Task AddCookie(AvaloniaWebViewCookie cookie)
{
throw new NotImplementedException();
}

public Task RemoveCookie(AvaloniaWebViewCookie cookie)
{
throw new NotImplementedException();
}

public Task ClearCookies()
{
throw new NotImplementedException();
}

public Task GetCookies(String url)
{
throw new NotImplementedException();
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Avalonia.WebView.Android;
using AvaloniaWebView.Shared.Interfaces;

namespace Avalonia.WebView.Android;

internal class ViewHandlerProvider : IViewHandlerProvider
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System.Runtime.InteropServices;
using Avalonia.WebView.Linux;
using Avalonia.WebView.MacCatalyst;
using Avalonia.WebView.Windows;
using System.Runtime.InteropServices;

namespace Avalonia.WebView.Desktop;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Avalonia.WebView.Desktop;
using Avalonia.WebView.Windows;

namespace Avalonia.WebView.DesktopX;
public static class AppBuilderExtensions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Avalonia.WebView.Linux;
using AvaloniaWebView.Shared.Interfaces;
using Linux.WebView.Core;

namespace Avalonia.WebView.Desktop;
namespace Avalonia.WebView.Linux;

public static class AppBuilderExtensions
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using Linux.WebView.Core;

namespace Avalonia.WebView.Linux.Core;

public partial class LinuxWebViewCore : IPlatformWebView<LinuxWebViewCore>
{
public Task AddCookie(AvaloniaWebViewCookie cookie)
{
throw new NotImplementedException();
}

public Task<List<AvaloniaWebViewCookie>?> GetCookies(string url)
{
WebView.Context.CookieManager.GetCookies(url);
var a = WebView.Context.CookieManager.GetCookiesFinish(new GLib.Task());
return Task.FromResult<List<AvaloniaWebViewCookie>?>(null);
}

public Task RemoveCookie(AvaloniaWebViewCookie cookie)
{
WebView.Context.CookieManager.DeleteCookiesForDomain(cookie.Domain);
return Task.CompletedTask;
}

public Task ClearCookies()
{
WebView.Context.CookieManager.DeleteAllCookies();
return Task.CompletedTask;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia.Controls.ApplicationLifetimes;
using AvaloniaWebView.Shared.Interfaces;
using Linux.WebView.Core;

namespace Avalonia.WebView.Linux;
Expand Down
Loading