From 4c72bbfc0e0fc1410bc6cf38d4cb7bacbe848db8 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Sun, 17 Dec 2023 22:58:09 +0100 Subject: [PATCH] Added InAppBrowser.onMainWindowWillClose event, Added WindowType.WINDOW for InAppWebViewSettings.windowType, fix #1738, Fixed InAppWebViewController.callAsyncJavaScript Android-issue when the last line of the functionBody parameter includes a code comment --- LICENSE | 2 +- .../LICENSE | 2 +- flutter_inappwebview/CHANGELOG.md | 14 ++++++++++++- flutter_inappwebview/LICENSE | 2 +- .../in_app_webview/on_received_icon.dart | 4 +++- .../lib/in_app_browser_example.screen.dart | 4 ++++ .../lib/in_app_webiew_example.screen.dart | 2 +- .../src/in_app_browser/in_app_browser.dart | 3 +++ flutter_inappwebview/pubspec.yaml | 12 +++++------ flutter_inappwebview_android/CHANGELOG.md | 6 ++++++ flutter_inappwebview_android/LICENSE | 2 +- .../plugin_scripts_js/ConsoleLogJS.java | 20 +++++++++---------- .../plugin_scripts_js/PluginScriptsUtil.java | 2 +- flutter_inappwebview_android/pubspec.yaml | 4 ++-- flutter_inappwebview_ios/CHANGELOG.md | 4 ++++ flutter_inappwebview_ios/LICENSE | 2 +- flutter_inappwebview_ios/pubspec.yaml | 4 ++-- flutter_inappwebview_macos/CHANGELOG.md | 7 ++++++- flutter_inappwebview_macos/LICENSE | 2 +- .../src/in_app_browser/in_app_browser.dart | 4 ++++ .../InAppBrowserChannelDelegate.swift | 5 +++++ .../InAppBrowser/InAppBrowserManager.swift | 4 +++- .../InAppBrowser/InAppBrowserSettings.swift | 2 +- .../InAppBrowser/InAppBrowserWindow.swift | 12 +++++++---- .../Types/InAppBrowserWindowType.swift | 1 + flutter_inappwebview_macos/pubspec.yaml | 4 ++-- .../CHANGELOG.md | 5 +++++ .../LICENSE | 2 +- .../in_app_browser_settings.dart | 2 +- .../in_app_browser_settings.g.dart | 2 +- .../platform_in_app_browser.dart | 6 ++++++ .../lib/src/in_app_localhost_server.dart | 4 ++-- .../lib/src/types/window_type.dart | 4 ++++ .../lib/src/types/window_type.g.dart | 15 ++++++++++++++ .../pubspec.yaml | 2 +- flutter_inappwebview_web/CHANGELOG.md | 10 +++++++--- flutter_inappwebview_web/LICENSE | 2 +- flutter_inappwebview_web/pubspec.yaml | 4 ++-- 38 files changed, 137 insertions(+), 51 deletions(-) diff --git a/LICENSE b/LICENSE index 4dada16d..6ccd8da4 100755 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 Lorenzo Pichilli + Copyright 2023 Lorenzo Pichilli Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/dev_packages/flutter_inappwebview_internal_annotations/LICENSE b/dev_packages/flutter_inappwebview_internal_annotations/LICENSE index 4dada16d..6ccd8da4 100755 --- a/dev_packages/flutter_inappwebview_internal_annotations/LICENSE +++ b/dev_packages/flutter_inappwebview_internal_annotations/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 Lorenzo Pichilli + Copyright 2023 Lorenzo Pichilli Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index 8a28555a..190396e0 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -1,3 +1,15 @@ +## 6.0.0-rc.1 + +- Updated minimum platform interface and implementation versions +- Added `InAppBrowser.onMainWindowWillClose` event +- Added `WindowType.WINDOW` for `InAppWebViewSettings.windowType` +- Fixed "Cloudflare Turnstile failure" [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) +- Fixed `InAppWebViewController.callAsyncJavaScript` Android-issue when the last line of the `functionBody` parameter includes a code comment + +### BREAKING CHANGES + +- Default value of `InAppWebViewSettings.windowType` is `WindowType.WINDOW` + ## 6.0.0-beta.32 - Updated minimum platform interface and implementation versions @@ -17,7 +29,7 @@ - Fixed "onClosed not considering back navigation or up button / close button in ChromeSafariBrowser when using noHistory: true" [#1882](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1882) - Merged "Fixed error in InterceptAjaxRequestJS 'Failed to set responseType property'" [#1904](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1904) (thanks to [EArminjon](https://github.com/EArminjon)) -### BREAKING CHANGE +### BREAKING CHANGES - Due to Flutter platform channels async nature, using `useShouldInterceptAjaxRequest: true` would break sync ajax requests, so that the `XMLHttpRequest.send()` will not wait for the response. To fix this issue, the default value of `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests` is `true`. To intercept also sync ajax requests, this value should be `false`. diff --git a/flutter_inappwebview/LICENSE b/flutter_inappwebview/LICENSE index 4dada16d..6ccd8da4 100755 --- a/flutter_inappwebview/LICENSE +++ b/flutter_inappwebview/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 Lorenzo Pichilli + Copyright 2023 Lorenzo Pichilli Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/flutter_inappwebview/example/integration_test/in_app_webview/on_received_icon.dart b/flutter_inappwebview/example/integration_test/in_app_webview/on_received_icon.dart index 22d6c5c1..70fdb401 100644 --- a/flutter_inappwebview/example/integration_test/in_app_webview/on_received_icon.dart +++ b/flutter_inappwebview/example/integration_test/in_app_webview/on_received_icon.dart @@ -26,7 +26,9 @@ void onReceivedIcon() { pageLoaded.complete(); }, onReceivedIcon: (controller, icon) { - onReceivedIconCompleter.complete(icon); + if (!onReceivedIconCompleter.isCompleted) { + onReceivedIconCompleter.complete(icon); + } }, ), ), diff --git a/flutter_inappwebview/example/lib/in_app_browser_example.screen.dart b/flutter_inappwebview/example/lib/in_app_browser_example.screen.dart index 11ee9852..15f2bd7b 100755 --- a/flutter_inappwebview/example/lib/in_app_browser_example.screen.dart +++ b/flutter_inappwebview/example/lib/in_app_browser_example.screen.dart @@ -61,6 +61,10 @@ class MyInAppBrowser extends InAppBrowser { print("\n\nOverride ${navigationAction.request.url}\n\n"); return NavigationActionPolicy.ALLOW; } + + void onMainWindowWillClose() { + close(); + } } class InAppBrowserExampleScreen extends StatefulWidget { diff --git a/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart b/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart index 79dc016f..13e630ea 100755 --- a/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart +++ b/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart @@ -116,7 +116,7 @@ class _InAppWebViewExampleScreenState extends State { InAppWebView( key: webViewKey, initialUrlRequest: - URLRequest(url: WebUri('https://flutter.dev')), + URLRequest(url: WebUri('https://google.com')), // initialUrlRequest: // URLRequest(url: WebUri(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')), // initialFile: "assets/index.html", diff --git a/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart b/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart index cb6a1a68..3393cafd 100755 --- a/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart +++ b/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart @@ -538,4 +538,7 @@ class InAppBrowser implements PlatformInAppBrowserEvents { NavigationAction navigationAction) { return null; } + + @override + void onMainWindowWillClose() {} } diff --git a/flutter_inappwebview/pubspec.yaml b/flutter_inappwebview/pubspec.yaml index 18e5d456..026818d0 100755 --- a/flutter_inappwebview/pubspec.yaml +++ b/flutter_inappwebview/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. -version: 6.0.0-beta.32 +version: 6.0.0-rc.1 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -18,11 +18,11 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.0.6 - flutter_inappwebview_android: ^1.0.8 - flutter_inappwebview_ios: ^1.0.9 - flutter_inappwebview_macos: ^1.0.7 - flutter_inappwebview_web: ^1.0.4 + flutter_inappwebview_platform_interface: ^1.0.7 + flutter_inappwebview_android: ^1.0.9 + flutter_inappwebview_ios: ^1.0.10 + flutter_inappwebview_macos: ^1.0.8 + flutter_inappwebview_web: ^1.0.5 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index 185da823..023d7325 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.0.9 + +- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.7` +- Fixed "Cloudflare Turnstile failure" [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) +- Fixed `InAppWebViewController.callAsyncJavaScript` issue when the last line of the `functionBody` parameter includes a code comment + ## 1.0.8 - Implemented `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests` diff --git a/flutter_inappwebview_android/LICENSE b/flutter_inappwebview_android/LICENSE index 4dada16d..6ccd8da4 100644 --- a/flutter_inappwebview_android/LICENSE +++ b/flutter_inappwebview_android/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 Lorenzo Pichilli + Copyright 2023 Lorenzo Pichilli Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/ConsoleLogJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/ConsoleLogJS.java index 479f89bd..acc64087 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/ConsoleLogJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/ConsoleLogJS.java @@ -15,6 +15,15 @@ public class ConsoleLogJS { ); public static final String CONSOLE_LOG_JS_SOURCE = "(function(console) {" + + " function _buildMessage(args) {" + + " var message = '';" + + " for (var i in args) {" + + " try {" + + " message += message === '' ? args[i] : ' ' + args[i];" + + " } catch(ignored) {}" + + " }" + + " return message;" + + " }" + " var oldLogs = {" + " 'log': console.log," + " 'debug': console.debug," + @@ -25,16 +34,7 @@ public class ConsoleLogJS { " for (var k in oldLogs) {" + " (function(oldLog) {" + " console[oldLog] = function() {" + - " var message = '';" + - " for (var i in arguments) {" + - " if (message == '') {" + - " message += arguments[i];" + - " }" + - " else {" + - " message += ' ' + arguments[i];" + - " }" + - " }" + - " oldLogs[oldLog].call(console, message);" + + " oldLogs[oldLog].call(console, _buildMessage(arguments));" + " }" + " })(k);" + " }" + diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PluginScriptsUtil.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PluginScriptsUtil.java index e00820d3..91af1fdd 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PluginScriptsUtil.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PluginScriptsUtil.java @@ -18,7 +18,7 @@ public class PluginScriptsUtil { public static final String CALL_ASYNC_JAVA_SCRIPT_WRAPPER_JS_SOURCE = "(function(obj) {" + " (async function(" + VAR_FUNCTION_ARGUMENT_NAMES + ") {" + - " " + VAR_FUNCTION_BODY + + " \n" + VAR_FUNCTION_BODY + "\n" + " })(" + VAR_FUNCTION_ARGUMENT_VALUES + ").then(function(value) {" + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('callAsyncJavaScript', {'value': value, 'error': null, 'resultUuid': '" + VAR_RESULT_UUID + "'});" + " }).catch(function(error) {" + diff --git a/flutter_inappwebview_android/pubspec.yaml b/flutter_inappwebview_android/pubspec.yaml index 0e28a3cc..a3f16328 100644 --- a/flutter_inappwebview_android/pubspec.yaml +++ b/flutter_inappwebview_android/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_android description: Android implementation of the flutter_inappwebview plugin. -version: 1.0.8 +version: 1.0.9 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_android issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -18,7 +18,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.0.6 + flutter_inappwebview_platform_interface: ^1.0.7 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_ios/CHANGELOG.md b/flutter_inappwebview_ios/CHANGELOG.md index 451fcaac..deaedb77 100644 --- a/flutter_inappwebview_ios/CHANGELOG.md +++ b/flutter_inappwebview_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.0.10 + +- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.7` + ## 1.0.9 - Implemented `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests` diff --git a/flutter_inappwebview_ios/LICENSE b/flutter_inappwebview_ios/LICENSE index 4dada16d..6ccd8da4 100644 --- a/flutter_inappwebview_ios/LICENSE +++ b/flutter_inappwebview_ios/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 Lorenzo Pichilli + Copyright 2023 Lorenzo Pichilli Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/flutter_inappwebview_ios/pubspec.yaml b/flutter_inappwebview_ios/pubspec.yaml index b266ca03..2a48a708 100644 --- a/flutter_inappwebview_ios/pubspec.yaml +++ b/flutter_inappwebview_ios/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_ios description: iOS implementation of the flutter_inappwebview plugin. -version: 1.0.9 +version: 1.0.10 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_ios issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -18,7 +18,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.0.6 + flutter_inappwebview_platform_interface: ^1.0.7 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_macos/CHANGELOG.md b/flutter_inappwebview_macos/CHANGELOG.md index 95339a67..20914bcc 100644 --- a/flutter_inappwebview_macos/CHANGELOG.md +++ b/flutter_inappwebview_macos/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.0.8 + +- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.7` +- Implemented `InAppBrowser.onMainWindowWillClose` event + ## 1.0.7 - Implemented `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests` @@ -29,7 +34,7 @@ ## 1.0.1 - Added `PlatformPrintJobController.onComplete` setter -- Updated `flutter_inappwebview_platform_interface` version dependency to `1.0.2` +- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.2` ## 1.0.0 diff --git a/flutter_inappwebview_macos/LICENSE b/flutter_inappwebview_macos/LICENSE index 4dada16d..6ccd8da4 100644 --- a/flutter_inappwebview_macos/LICENSE +++ b/flutter_inappwebview_macos/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 Lorenzo Pichilli + Copyright 2023 Lorenzo Pichilli Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/flutter_inappwebview_macos/lib/src/in_app_browser/in_app_browser.dart b/flutter_inappwebview_macos/lib/src/in_app_browser/in_app_browser.dart index f6f6f18a..8aa55e1f 100755 --- a/flutter_inappwebview_macos/lib/src/in_app_browser/in_app_browser.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_browser/in_app_browser.dart @@ -122,6 +122,10 @@ class MacOSInAppBrowser extends PlatformInAppBrowser with ChannelController { } } break; + case "onMainWindowWillClose": + _debugLog(call.method, call.arguments); + eventHandler?.onMainWindowWillClose(); + break; case "onExit": _debugLog(call.method, call.arguments); _isOpened = false; diff --git a/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserChannelDelegate.swift b/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserChannelDelegate.swift index 7896c2f7..f9728882 100644 --- a/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserChannelDelegate.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserChannelDelegate.swift @@ -25,6 +25,11 @@ public class InAppBrowserChannelDelegate : ChannelDelegate { channel?.invokeMethod("onMenuItemClicked", arguments: arguments) } + public func onMainWindowWillClose() { + let arguments: [String: Any?] = [:] + channel?.invokeMethod("onMainWindowWillClose", arguments: arguments) + } + public func onExit() { let arguments: [String: Any?] = [:] channel?.invokeMethod("onExit", arguments: arguments) diff --git a/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserManager.swift b/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserManager.swift index b1c21de2..b15564d1 100755 --- a/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserManager.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserManager.swift @@ -86,8 +86,10 @@ public class InAppBrowserManager: ChannelDelegate { if #available(macOS 10.12, *), browserSettings.windowType == .tabbed { NSApplication.shared.mainWindow?.addTabbedWindow(window, ordered: .above) - } else { + } else if browserSettings.windowType == .child { NSApplication.shared.mainWindow?.addChildWindow(window, ordered: .above) + } else { + window.windowController?.showWindow(self) } if browserSettings.hidden { diff --git a/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserSettings.swift b/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserSettings.swift index 25077894..6f01e97d 100755 --- a/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserSettings.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserSettings.swift @@ -16,7 +16,7 @@ public class InAppBrowserSettings: ISettings { var hideUrlBar = false var hideProgressBar = false var toolbarTopFixedTitle: String? - var windowType = InAppBrowserWindowType.child + var windowType = InAppBrowserWindowType.window var windowAlphaValue = 1.0 var _windowStyleMask: NSNumber? var windowStyleMask: NSWindow.StyleMask? { diff --git a/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserWindow.swift b/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserWindow.swift index 7ef610c2..4347e393 100644 --- a/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserWindow.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppBrowser/InAppBrowserWindow.swift @@ -62,7 +62,7 @@ public class InAppBrowserWindow : NSWindow, NSWindowDelegate, NSToolbarDelegate, delegate = self NotificationCenter.default.addObserver(self, - selector: #selector(onMainWindowClose(_:)), + selector: #selector(onMainWindowWillClose(_:)), name: NSWindow.willCloseNotification, object: NSApplication.shared.mainWindow) @@ -348,13 +348,17 @@ public class InAppBrowserWindow : NSWindow, NSWindowDelegate, NSToolbarDelegate, dispose() } - @objc func onMainWindowClose(_ notification: Notification) { - close() + @objc func onMainWindowWillClose(_ notification: Notification) { + if let webViewController = contentViewController as? InAppBrowserWebViewController { + webViewController.channelDelegate?.onMainWindowWillClose() + } } - public func dispose() { delegate = nil + NotificationCenter.default.removeObserver(self, + name: NSWindow.willCloseNotification, + object: NSApplication.shared.mainWindow) if let webViewController = contentViewController as? InAppBrowserWebViewController { webViewController.dispose() } diff --git a/flutter_inappwebview_macos/macos/Classes/Types/InAppBrowserWindowType.swift b/flutter_inappwebview_macos/macos/Classes/Types/InAppBrowserWindowType.swift index 9ab3f3d8..9650e2b9 100644 --- a/flutter_inappwebview_macos/macos/Classes/Types/InAppBrowserWindowType.swift +++ b/flutter_inappwebview_macos/macos/Classes/Types/InAppBrowserWindowType.swift @@ -8,6 +8,7 @@ import Foundation public enum InAppBrowserWindowType: String { + case window = "WINDOW" case child = "CHILD" case tabbed = "TABBED" } diff --git a/flutter_inappwebview_macos/pubspec.yaml b/flutter_inappwebview_macos/pubspec.yaml index 67647532..44eb0d99 100644 --- a/flutter_inappwebview_macos/pubspec.yaml +++ b/flutter_inappwebview_macos/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_macos description: macOS implementation of the flutter_inappwebview plugin. -version: 1.0.7 +version: 1.0.8 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_macos issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -18,7 +18,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.0.6 + flutter_inappwebview_platform_interface: ^1.0.7 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_platform_interface/CHANGELOG.md b/flutter_inappwebview_platform_interface/CHANGELOG.md index c149ce72..1d7588d5 100644 --- a/flutter_inappwebview_platform_interface/CHANGELOG.md +++ b/flutter_inappwebview_platform_interface/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.0.7 + +- Added `InAppBrowser.onMainWindowWillClose` event +- Added `WindowType.WINDOW` for `InAppWebViewSettings.windowType` + ## 1.0.6 - Added `InAppWebViewSettings.interceptOnlyAsyncAjaxRequests` [#1905](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1905) diff --git a/flutter_inappwebview_platform_interface/LICENSE b/flutter_inappwebview_platform_interface/LICENSE index 4dada16d..6ccd8da4 100644 --- a/flutter_inappwebview_platform_interface/LICENSE +++ b/flutter_inappwebview_platform_interface/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 Lorenzo Pichilli + Copyright 2023 Lorenzo Pichilli Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart index b2f1c106..038f8358 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart @@ -254,7 +254,7 @@ class InAppBrowserSettings_ ModalTransitionStyle_? transitionStyle; ///How the browser window should be added to the main window. - ///The default value is [WindowType.CHILD]. + ///The default value is [WindowType.WINDOW]. /// ///**Officially Supported Platforms/Implementations**: ///- MacOS diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart index 75eedc8c..87a3b780 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart @@ -195,7 +195,7 @@ class InAppBrowserSettings WindowTitlebarSeparatorStyle? windowTitlebarSeparatorStyle; ///How the browser window should be added to the main window. - ///The default value is [WindowType.CHILD]. + ///The default value is [WindowType.WINDOW]. /// ///**Officially Supported Platforms/Implementations**: ///- MacOS diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart index f57e69aa..999b92a3 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart @@ -497,6 +497,12 @@ abstract class PlatformInAppBrowserEvents { ///- MacOS void onExit() {} + ///Event fired when the main window is about to close. + /// + ///**Officially Supported Platforms/Implementations**: + ///- MacOS + void onMainWindowWillClose() {} + ///Event fired when the [PlatformInAppBrowser] starts to load an [url]. /// ///**Officially Supported Platforms/Implementations**: diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart index fff3757d..f1805c10 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart @@ -74,7 +74,7 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { } this._started = true; - var completer = Completer(); + final completer = Completer(); runZonedGuarded(() { HttpServer.bind('127.0.0.1', _port, shared: _shared).then((server) { @@ -108,7 +108,7 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { var contentType = ContentType('text', 'html', charset: 'utf-8'); if (!request.requestedUri.path.endsWith('/') && request.requestedUri.pathSegments.isNotEmpty) { - var mimeType = MimeTypeResolver.lookup(request.requestedUri.path); + final mimeType = MimeTypeResolver.lookup(request.requestedUri.path); if (mimeType != null) { contentType = _getContentTypeFromMimeType(mimeType); } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/window_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/window_type.dart index fe502bba..2d49b9c9 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/window_type.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/window_type.dart @@ -11,6 +11,10 @@ class WindowType_ { const WindowType_._internal(this._value); + ///Adds the new browser window as a separate new window from the main window. + @EnumSupportedPlatforms(platforms: [EnumMacOSPlatform(value: 'WINDOW')]) + static const WINDOW = const WindowType_._internal('WINDOW'); + ///Adds the new browser window as a child window of the main window. @EnumSupportedPlatforms(platforms: [EnumMacOSPlatform(value: 'CHILD')]) static const CHILD = const WindowType_._internal('CHILD'); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/window_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/window_type.g.dart index 172174b4..b9be001c 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/window_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/window_type.g.dart @@ -44,10 +44,25 @@ class WindowType { return null; }); + ///Adds the new browser window as a separate new window from the main window. + /// + ///**Officially Supported Platforms/Implementations**: + ///- MacOS + static final WINDOW = WindowType._internalMultiPlatform('WINDOW', () { + switch (defaultTargetPlatform) { + case TargetPlatform.macOS: + return 'WINDOW'; + default: + break; + } + return null; + }); + ///Set of all values of [WindowType]. static final Set values = [ WindowType.CHILD, WindowType.TABBED, + WindowType.WINDOW, ].toSet(); ///Gets a possible [WindowType] instance from [String] value. diff --git a/flutter_inappwebview_platform_interface/pubspec.yaml b/flutter_inappwebview_platform_interface/pubspec.yaml index ab199835..920fb721 100644 --- a/flutter_inappwebview_platform_interface/pubspec.yaml +++ b/flutter_inappwebview_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_platform_interface description: A common platform interface for the flutter_inappwebview plugin. -version: 1.0.6 +version: 1.0.7 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_platform_interface issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues diff --git a/flutter_inappwebview_web/CHANGELOG.md b/flutter_inappwebview_web/CHANGELOG.md index a6b2f027..b220715c 100644 --- a/flutter_inappwebview_web/CHANGELOG.md +++ b/flutter_inappwebview_web/CHANGELOG.md @@ -1,6 +1,10 @@ +## 1.0.5 + +- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.7` + ## 1.0.4 -- Updated `flutter_inappwebview_platform_interface` version dependency to `1.0.6` +- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.6` - Updated `CookieManager` methods return value ## 1.0.3 @@ -10,11 +14,11 @@ ## 1.0.2 -- Updated `flutter_inappwebview_platform_interface` version dependency to `1.0.5` +- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.5` ## 1.0.1 -- Updated `flutter_inappwebview_platform_interface` version dependency to `1.0.2` +- Updated `flutter_inappwebview_platform_interface` version dependency to `^1.0.2` ## 1.0.0 diff --git a/flutter_inappwebview_web/LICENSE b/flutter_inappwebview_web/LICENSE index 4dada16d..6ccd8da4 100644 --- a/flutter_inappwebview_web/LICENSE +++ b/flutter_inappwebview_web/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright 2022 Lorenzo Pichilli + Copyright 2023 Lorenzo Pichilli Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/flutter_inappwebview_web/pubspec.yaml b/flutter_inappwebview_web/pubspec.yaml index 893cd69c..5b47eb5a 100644 --- a/flutter_inappwebview_web/pubspec.yaml +++ b/flutter_inappwebview_web/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_web description: Web implementation of the flutter_inappwebview plugin. -version: 1.0.4 +version: 1.0.5 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_web issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -21,7 +21,7 @@ dependencies: flutter_web_plugins: sdk: flutter js: ^0.6.4 - flutter_inappwebview_platform_interface: ^1.0.6 + flutter_inappwebview_platform_interface: ^1.0.7 dev_dependencies: flutter_test: