diff --git a/webview/lib/Microsoft.Web.WebView2.Core.dll b/webview/lib/Microsoft.Web.WebView2.Core.dll index f8752368..5d506f2e 100644 Binary files a/webview/lib/Microsoft.Web.WebView2.Core.dll and b/webview/lib/Microsoft.Web.WebView2.Core.dll differ diff --git a/webview/lib/Microsoft.Web.WebView2.WinForms.dll b/webview/lib/Microsoft.Web.WebView2.WinForms.dll index 154ec9c9..3d115b8c 100644 Binary files a/webview/lib/Microsoft.Web.WebView2.WinForms.dll and b/webview/lib/Microsoft.Web.WebView2.WinForms.dll differ diff --git a/webview/lib/arm64/WebView2Loader.dll b/webview/lib/arm64/WebView2Loader.dll new file mode 100644 index 00000000..052bd8cf Binary files /dev/null and b/webview/lib/arm64/WebView2Loader.dll differ diff --git a/webview/lib/x64/WebView2Loader.dll b/webview/lib/x64/WebView2Loader.dll index 7448c76e..5230d045 100644 Binary files a/webview/lib/x64/WebView2Loader.dll and b/webview/lib/x64/WebView2Loader.dll differ diff --git a/webview/lib/x86/WebView2Loader.dll b/webview/lib/x86/WebView2Loader.dll index e9df1fc0..c97f28fb 100644 Binary files a/webview/lib/x86/WebView2Loader.dll and b/webview/lib/x86/WebView2Loader.dll differ diff --git a/webview/platforms/edgechromium.py b/webview/platforms/edgechromium.py index a41b48c9..77caef5b 100644 --- a/webview/platforms/edgechromium.py +++ b/webview/platforms/edgechromium.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """ -(C) 2014-2019 Roman Sirokov and contributors +(C) 2014-2022 Roman Sirokov and contributors Licensed under BSD license http://github.com/r0x0r/pywebview/ @@ -12,12 +12,9 @@ import json import webbrowser from threading import Semaphore -from ctypes import windll -from platform import architecture from webview import _debug, _user_agent -from webview.serving import resolve_url -from webview.util import parse_api_js, interop_dll_path, parse_file_type, inject_base_uri, default_html, js_bridge_call +from webview.util import parse_api_js, interop_dll_path, default_html, js_bridge_call from webview.js import alert from webview.js.css import disable_text_select @@ -29,16 +26,19 @@ clr.AddReference('System.Threading') import System.Windows.Forms as WinForms -from System import IntPtr, Int32, String, Action, Func, Type, Environment, Uri -from System.Threading.Tasks import Task, TaskScheduler, TaskContinuationOptions -from System.Drawing import Size, Point, Icon, Color, ColorTranslator, SizeF +from System import String, Action, Uri +from System.Threading.Tasks import Task, TaskScheduler +from System.Drawing import Color -archpath = 'x64' if architecture()[0] == '64bit' else 'x86' -os.environ['Path'] = interop_dll_path(archpath) + ';' + os.environ['Path'] clr.AddReference(interop_dll_path('Microsoft.Web.WebView2.Core.dll')) clr.AddReference(interop_dll_path('Microsoft.Web.WebView2.WinForms.dll')) + from Microsoft.Web.WebView2.WinForms import WebView2, CoreWebView2CreationProperties -from Microsoft.Web.WebView2.Core import CoreWebView2Environment + + +for platform in ('arm64', 'x64', 'x86'): + os.environ['Path'] += ';' + interop_dll_path(platform) + logger = logging.getLogger('pywebview') @@ -47,7 +47,6 @@ def __init__(self, form, window): self.pywebview_window = window self.web_view = WebView2() props = CoreWebView2CreationProperties() - #props.UserDataFolder = os.path.join(os.getcwd(), 'profile') props.UserDataFolder = os.path.join(os.environ['LOCALAPPDATA'], 'pywebview') self.web_view.CreationProperties = props form.Controls.Add(self.web_view) @@ -77,6 +76,7 @@ def __init__(self, form, window): self.html = default_html self.load_html(default_html, '') + def evaluate_js(self, script, id, callback=None): def _callback(result): if callback is None: @@ -133,6 +133,10 @@ def on_new_window_request(self, _, args): webbrowser.open(str(args.get_Uri())) def on_webview_ready(self, sender, args): + if not args.IsSuccess: + logger.error('WebView2 initialization failed with exception:\n ' + str(args.InitializationException)) + return + sender.CoreWebView2.NewWindowRequested += self.on_new_window_request settings = sender.CoreWebView2.Settings settings.AreDefaultContextMenusEnabled = _debug['mode'] @@ -150,6 +154,7 @@ def on_webview_ready(self, sender, args): if self.html: sender.CoreWebView2.NavigateToString(self.html) + def on_navigation_start(self, sender, args): pass