diff --git a/CHANGELOG.md b/CHANGELOG.md index 451997e5..bf48d2e3 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,8 +16,9 @@ ### BREAKING CHANGES -- On Android, the `InAppWebView` widget uses hybrid composition by default (`useHybridComposition: true`). -- All properties of `GeolocationPermissionShowPromptResponse` cannot be `null`; +- On Android, the `InAppWebView` widget uses hybrid composition by default (`useHybridComposition: true`) +- All properties of `GeolocationPermissionShowPromptResponse` cannot be `null` +- Removed `URLProtectionSpace.iosIsProxy` property ## 5.4.3+7 diff --git a/dev_packages/generators/lib/src/exchangeable_object_generator.dart b/dev_packages/generators/lib/src/exchangeable_object_generator.dart index 5e67f491..56844ae7 100644 --- a/dev_packages/generators/lib/src/exchangeable_object_generator.dart +++ b/dev_packages/generators/lib/src/exchangeable_object_generator.dart @@ -119,7 +119,7 @@ class ExchangeableObjectGenerator var defaultValueCode = parameter.defaultValueCode?.replaceFirst("_.", "."); var constructorField = - '${!isNullable && defaultValueCode == null ? 'required ' : ''}$parameterType $parameterName${defaultValueCode != null ? ' = $defaultValueCode' : ''}'; + '${!isNullable && defaultValueCode == null ? 'required ' : ''}${parameterType.toString().replaceFirst("_", "")} $parameterName${defaultValueCode != null ? ' = $defaultValueCode' : ''}'; if (parameter.hasDeprecated) { deprecatedFields.add(parameter); constructorField = @@ -157,6 +157,7 @@ class ExchangeableObjectGenerator classBuffer.writeln(constructorBody .toString() .replaceAll(className, extClassName) + .replaceAll("_.", ".") .replaceAll("@ExchangeableObjectConstructor()", "")); } } else if (constructorFields.length > 0) { @@ -192,37 +193,39 @@ class ExchangeableObjectGenerator .replaceFirst("Use ", "") .replaceFirst(" instead", "") .trim(); - final fieldElement = visitor.fields[fieldName]!; - final fieldTypeElement = fieldElement.type.element; - final deprecatedFieldTypeElement = deprecatedField.type.element; + final fieldElement = visitor.fields[fieldName]; + if (fieldElement != null) { + final fieldTypeElement = fieldElement.type.element; + final deprecatedFieldTypeElement = deprecatedField.type.element; - classBuffer.write('$fieldName = $fieldName ?? '); - if (fieldTypeElement != null && deprecatedFieldTypeElement != null) { - final isNullable = Util.typeIsNullable(fieldElement.type); - final deprecatedIsNullable = Util.typeIsNullable(deprecatedField.type); - final hasFromMap = hasFromMapMethod(fieldTypeElement); - final hasFromNativeValue = hasFromNativeValueMethod(fieldTypeElement); - final hasFromValue = hasFromValueMethod(fieldTypeElement); - final deprecatedHasToMap = hasFromMapMethod(deprecatedFieldTypeElement); - final deprecatedHasToNativeValue = hasToNativeValueMethod(deprecatedFieldTypeElement); - final deprecatedHasToValue = hasToValueMethod(deprecatedFieldTypeElement); - if (hasFromMap && deprecatedHasToMap) { - final hasNullableFromMap = hasNullableFromMapFactory(fieldTypeElement); - classBuffer.write(fieldTypeElement.name!.replaceFirst("_", "") + - ".fromMap($deprecatedFieldName${deprecatedIsNullable ? '?' : ''}.toMap())${!isNullable && hasNullableFromMap ? '!' : ''}"); - } else if (hasFromNativeValue && deprecatedHasToNativeValue) { - classBuffer.write(fieldTypeElement.name!.replaceFirst("_", "") + - '.fromNativeValue($deprecatedFieldName${deprecatedIsNullable ? '?' : ''}.toNativeValue())${!isNullable ? '!' : ''}'); - } else if (hasFromValue && deprecatedHasToValue) { - classBuffer.write(fieldTypeElement.name!.replaceFirst("_", "") + - '.fromValue($deprecatedFieldName${deprecatedIsNullable ? '?' : ''}.toValue())${!isNullable ? '!' : ''}'); + classBuffer.write('$fieldName = $fieldName ?? '); + if (fieldTypeElement != null && deprecatedFieldTypeElement != null) { + final isNullable = Util.typeIsNullable(fieldElement.type); + final deprecatedIsNullable = Util.typeIsNullable(deprecatedField.type); + final hasFromMap = hasFromMapMethod(fieldTypeElement); + final hasFromNativeValue = hasFromNativeValueMethod(fieldTypeElement); + final hasFromValue = hasFromValueMethod(fieldTypeElement); + final deprecatedHasToMap = hasFromMapMethod(deprecatedFieldTypeElement); + final deprecatedHasToNativeValue = hasToNativeValueMethod(deprecatedFieldTypeElement); + final deprecatedHasToValue = hasToValueMethod(deprecatedFieldTypeElement); + if (hasFromMap && deprecatedHasToMap) { + final hasNullableFromMap = hasNullableFromMapFactory(fieldTypeElement); + classBuffer.write(fieldTypeElement.name!.replaceFirst("_", "") + + ".fromMap($deprecatedFieldName${deprecatedIsNullable ? '?' : ''}.toMap())${!isNullable && hasNullableFromMap ? '!' : ''}"); + } else if (hasFromNativeValue && deprecatedHasToNativeValue) { + classBuffer.write(fieldTypeElement.name!.replaceFirst("_", "") + + '.fromNativeValue($deprecatedFieldName${deprecatedIsNullable ? '?' : ''}.toNativeValue())${!isNullable ? '!' : ''}'); + } else if (hasFromValue && deprecatedHasToValue) { + classBuffer.write(fieldTypeElement.name!.replaceFirst("_", "") + + '.fromValue($deprecatedFieldName${deprecatedIsNullable ? '?' : ''}.toValue())${!isNullable ? '!' : ''}'); + } else { + classBuffer.write(deprecatedFieldName); + } } else { classBuffer.write(deprecatedFieldName); } - } else { - classBuffer.write(deprecatedFieldName); + classBuffer.writeln(';'); } - classBuffer.writeln(';'); } classBuffer.writeln('}'); } else if (!hasCustomConstructor) { diff --git a/dev_packages/test_gen/lib/src/types/test_class.dart b/dev_packages/test_gen/lib/src/types/test_class.dart index b0c19e6c..9f5556d1 100644 --- a/dev_packages/test_gen/lib/src/types/test_class.dart +++ b/dev_packages/test_gen/lib/src/types/test_class.dart @@ -6,7 +6,7 @@ import 'test_enum.dart'; part 'test_class.g.dart'; ///Custom docs -@ExchangeableObject() +// @ExchangeableObject() @SupportedPlatforms(platforms: [ AndroidPlatform( apiName: "TestClass", @@ -20,7 +20,7 @@ part 'test_class.g.dart'; ), WebPlatform(), ]) -class TestClass_ extends TestClass3 { +class TestClass_ extends TestClass3_ { ///Docs 1 String test1; ///Docs 2 @@ -51,10 +51,125 @@ class TestClass_ extends TestClass3 { } -class TestClass3 { +@ExchangeableObject() +class TestClass3_ { String asd; - TestClass3({required this.asd}); + TestClass3_({required this.asd}); +} + +///Class that represents the navigation request used by the [WebView.onCreateWindow] event. +@ExchangeableObject() +class CreateWindowAction_ extends NavigationAction_ { + ///The window id. Used by [WebView] to create a new WebView. + int windowId; + + ///Use [isDialog] instead. + @Deprecated("Use isDialog instead") + bool? androidIsDialog; + + ///Indicates if the new window should be a dialog, rather than a full-size window. + @SupportedPlatforms( + platforms: [ + AndroidPlatform() + ] + ) + bool? isDialog; + + CreateWindowAction_( + {required this.windowId, + @Deprecated('Use isDialog instead') + this.androidIsDialog, + this.isDialog, + required bool isForMainFrame, + @Deprecated('Use hasGesture instead') + bool? androidHasGesture, + @Deprecated('Use isRedirect instead') + bool? androidIsRedirect, + bool? hasGesture, + bool? isRedirect, + @Deprecated('Use navigationType instead') + // ignore: deprecated_member_use_from_same_package + TestClass3_? iosWKNavigationType, + TestClass3_? navigationType}) : super( + isForMainFrame: isForMainFrame, + hasGesture: hasGesture, + isRedirect: isRedirect, + navigationType: navigationType + ); +} + +///An object that contains information about an action that causes navigation to occur. +@ExchangeableObject() +class NavigationAction_ { + ///Indicates whether the request was made for the main frame. + /// + ///**NOTE for Android**: If the request is associated to the [WebView.onCreateWindow] event, this is always `true`. + ///Also, on Android < 21, this is always `true`. + bool isForMainFrame; + + ///Use [hasGesture] instead. + @Deprecated('Use hasGesture instead') + bool? androidHasGesture; + + ///Gets whether a gesture (such as a click) was associated with the request. + ///For security reasons in certain situations this method may return `false` even though + ///the sequence of events which caused the request to be created was initiated by a user + ///gesture. + @SupportedPlatforms( + platforms: [ + AndroidPlatform( + available: "21", + apiName: "WebResourceRequest.hasGesture", + apiUrl: "https://developer.android.com/reference/android/webkit/WebResourceRequest#hasGesture()", + note: "On Android < 21, this is always `false`" + ) + ] + ) + bool? hasGesture; + + ///Use [isRedirect] instead. + @Deprecated('Use isRedirect instead') + bool? androidIsRedirect; + + ///Gets whether the request was a result of a server-side redirect. + /// + ///**NOTE**: If the request is associated to the [WebView.onCreateWindow] event, this is always `false`. + ///Also, on Android < 21, this is always `false`. + @SupportedPlatforms( + platforms: [ + AndroidPlatform( + available: "21", + apiName: "WebResourceRequest.isRedirect", + apiUrl: "https://developer.android.com/reference/android/webkit/WebResourceRequest#isRedirect()" + ) + ] + ) + bool? isRedirect; + + ///Use [navigationType] instead. + @Deprecated("Use navigationType instead") + TestClass3_? iosWKNavigationType; + + ///The type of action triggering the navigation. + /// + ///**NOTE**: available only on iOS. + TestClass3_? navigationType; + + ///A value indicating whether the web content used a download attribute to indicate that this should be downloaded. + /// + ///**NOTE**: available only on iOS. + bool? shouldPerformDownload; + + NavigationAction_( + {required this.isForMainFrame, + @Deprecated('Use hasGesture instead') this.androidHasGesture, + this.hasGesture, + @Deprecated('Use isRedirect instead') this.androidIsRedirect, + this.isRedirect, + @Deprecated("Use navigationType instead") this.iosWKNavigationType, + this.navigationType, + this.shouldPerformDownload}); } class Util { diff --git a/ios/Classes/Types/URLProtectionSpace.swift b/ios/Classes/Types/URLProtectionSpace.swift index 33c03847..75557e17 100644 --- a/ios/Classes/Types/URLProtectionSpace.swift +++ b/ios/Classes/Types/URLProtectionSpace.swift @@ -57,7 +57,6 @@ extension URLProtectionSpace { "authenticationMethod": authenticationMethod, "distinguishedNames": distinguishedNames, "receivesCredentialSecurely": receivesCredentialSecurely, - "isProxy": isProxy(), "proxyType": proxyType ] } diff --git a/lib/src/types/client_cert_response.dart b/lib/src/types/client_cert_response.dart index 1cee42fa..10c3219f 100644 --- a/lib/src/types/client_cert_response.dart +++ b/lib/src/types/client_cert_response.dart @@ -1,11 +1,15 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../in_app_webview/webview.dart'; import 'client_cert_response_action.dart'; +part 'client_cert_response.g.dart'; + ///Class that represents the response used by the [WebView.onReceivedClientCertRequest] event. -class ClientCertResponse { +@ExchangeableObject() +class ClientCertResponse_ { ///The file path of the certificate to use. String certificatePath; @@ -17,48 +21,28 @@ class ClientCertResponse { String? androidKeyStoreType; ///An Android-specific property used by Java [KeyStore](https://developer.android.com/reference/java/security/KeyStore) class to get the instance. + @SupportedPlatforms(platforms: [ + AndroidPlatform() + ]) String? keyStoreType; ///Indicate the [ClientCertResponseAction] to take in response of the client certificate challenge. - ClientCertResponseAction? action; + ClientCertResponseAction_? action; - ClientCertResponse( + @ExchangeableObjectConstructor() + ClientCertResponse_( {required this.certificatePath, this.certificatePassword = "", @Deprecated('Use keyStoreType instead') this.androidKeyStoreType = "PKCS12", this.keyStoreType = "PKCS12", - this.action = ClientCertResponseAction.CANCEL}) { - if (this.action == ClientCertResponseAction.PROCEED) + this.action = ClientCertResponseAction_.CANCEL}) { + if (this.action == ClientCertResponseAction_.PROCEED) assert(certificatePath.isNotEmpty); - // ignore: deprecated_member_use_from_same_package this.keyStoreType = this.keyStoreType ?? this.androidKeyStoreType; if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) assert(this.keyStoreType != null); } - - ///Converts instance to a map. - Map toMap() { - return { - "certificatePath": certificatePath, - "certificatePassword": certificatePassword, - // ignore: deprecated_member_use_from_same_package - "androidKeyStoreType": keyStoreType ?? androidKeyStoreType, - // ignore: deprecated_member_use_from_same_package - "keyStoreType": keyStoreType ?? androidKeyStoreType, - "action": action?.toValue() - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/client_cert_response.g.dart b/lib/src/types/client_cert_response.g.dart new file mode 100644 index 00000000..dc1f21f2 --- /dev/null +++ b/lib/src/types/client_cert_response.g.dart @@ -0,0 +1,77 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'client_cert_response.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the response used by the [WebView.onReceivedClientCertRequest] event. +class ClientCertResponse { + ///The file path of the certificate to use. + String certificatePath; + + ///The certificate password. + String? certificatePassword; + + ///Use [keyStoreType] instead. + @Deprecated('Use keyStoreType instead') + String? androidKeyStoreType; + + ///An Android-specific property used by Java [KeyStore](https://developer.android.com/reference/java/security/KeyStore) class to get the instance. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + String? keyStoreType; + + ///Indicate the [ClientCertResponseAction] to take in response of the client certificate challenge. + ClientCertResponseAction? action; + ClientCertResponse( + {required this.certificatePath, + this.certificatePassword = "", + @Deprecated('Use keyStoreType instead') + this.androidKeyStoreType = "PKCS12", + this.keyStoreType = "PKCS12", + this.action = ClientCertResponseAction.CANCEL}) { + if (this.action == ClientCertResponseAction.PROCEED) + assert(certificatePath.isNotEmpty); + this.keyStoreType = this.keyStoreType ?? this.androidKeyStoreType; + if (!kIsWeb && defaultTargetPlatform == TargetPlatform.android) + assert(this.keyStoreType != null); + } + + ///Gets a possible [ClientCertResponse] instance from a [Map] value. + static ClientCertResponse? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = ClientCertResponse( + certificatePath: map['certificatePath'], + ); + instance.certificatePassword = map['certificatePassword']; + instance.androidKeyStoreType = map['keyStoreType']; + instance.keyStoreType = map['keyStoreType']; + instance.action = ClientCertResponseAction.fromNativeValue(map['action']); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "certificatePath": certificatePath, + "certificatePassword": certificatePassword, + "keyStoreType": keyStoreType, + "action": action?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'ClientCertResponse{certificatePath: $certificatePath, certificatePassword: $certificatePassword, keyStoreType: $keyStoreType, action: $action}'; + } +} diff --git a/lib/src/types/client_cert_response_action.dart b/lib/src/types/client_cert_response_action.dart index 44683331..7d606567 100644 --- a/lib/src/types/client_cert_response_action.dart +++ b/lib/src/types/client_cert_response_action.dart @@ -1,25 +1,22 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'client_cert_response.dart'; +part 'client_cert_response_action.g.dart'; + ///Class used by [ClientCertResponse] class. -class ClientCertResponseAction { +@ExchangeableEnum() +class ClientCertResponseAction_ { + // ignore: unused_field final int _value; - - const ClientCertResponseAction._internal(this._value); - - ///Gets [int] value. - int toValue() => _value; + const ClientCertResponseAction_._internal(this._value); ///Cancel this request. - static const CANCEL = const ClientCertResponseAction._internal(0); + static const CANCEL = const ClientCertResponseAction_._internal(0); ///Proceed with the specified certificate. - static const PROCEED = const ClientCertResponseAction._internal(1); + static const PROCEED = const ClientCertResponseAction_._internal(1); ///Ignore the request for now. - static const IGNORE = const ClientCertResponseAction._internal(2); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const IGNORE = const ClientCertResponseAction_._internal(2); } \ No newline at end of file diff --git a/lib/src/types/client_cert_response_action.g.dart b/lib/src/types/client_cert_response_action.g.dart new file mode 100644 index 00000000..a934d2a1 --- /dev/null +++ b/lib/src/types/client_cert_response_action.g.dart @@ -0,0 +1,85 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'client_cert_response_action.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used by [ClientCertResponse] class. +class ClientCertResponseAction { + final int _value; + final int _nativeValue; + const ClientCertResponseAction._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ClientCertResponseAction._internalMultiPlatform( + int value, Function nativeValue) => + ClientCertResponseAction._internal(value, nativeValue()); + + ///Cancel this request. + static const CANCEL = ClientCertResponseAction._internal(0, 0); + + ///Proceed with the specified certificate. + static const PROCEED = ClientCertResponseAction._internal(1, 1); + + ///Ignore the request for now. + static const IGNORE = ClientCertResponseAction._internal(2, 2); + + ///Set of all values of [ClientCertResponseAction]. + static final Set values = [ + ClientCertResponseAction.CANCEL, + ClientCertResponseAction.PROCEED, + ClientCertResponseAction.IGNORE, + ].toSet(); + + ///Gets a possible [ClientCertResponseAction] instance from [int] value. + static ClientCertResponseAction? fromValue(int? value) { + if (value != null) { + try { + return ClientCertResponseAction.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ClientCertResponseAction] instance from a native value. + static ClientCertResponseAction? fromNativeValue(int? value) { + if (value != null) { + try { + return ClientCertResponseAction.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'CANCEL'; + case 1: + return 'PROCEED'; + case 2: + return 'IGNORE'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/compress_format.dart b/lib/src/types/compress_format.dart index ed82b464..da05cb92 100644 --- a/lib/src/types/compress_format.dart +++ b/lib/src/types/compress_format.dart @@ -1,52 +1,29 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'compress_format.g.dart'; + ///Class that represents the known formats a bitmap can be compressed into. -class CompressFormat { +@ExchangeableEnum() +class CompressFormat_ { + // ignore: unused_field final String _value; - - const CompressFormat._internal(this._value); - - ///Set of all values of [CompressFormat]. - static final Set values = [ - CompressFormat.JPEG, - CompressFormat.PNG, - CompressFormat.WEBP, - CompressFormat.WEBP_LOSSY, - CompressFormat.WEBP_LOSSLESS, - ].toSet(); - - ///Gets a possible [CompressFormat] instance from a [String] value. - static CompressFormat? fromValue(String? value) { - if (value != null) { - try { - return CompressFormat.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - @override - String toString() => _value; + const CompressFormat_._internal(this._value); ///Compress to the `PNG` format. ///PNG is lossless, so `quality` is ignored. - static const PNG = const CompressFormat._internal("PNG"); + static const PNG = const CompressFormat_._internal("PNG"); ///Compress to the `JPEG` format. ///Quality of `0` means compress for the smallest size. ///`100` means compress for max visual quality. - static const JPEG = const CompressFormat._internal("JPEG"); + static const JPEG = const CompressFormat_._internal("JPEG"); ///Compress to the `WEBP` lossy format. ///Quality of `0` means compress for the smallest size. ///`100` means compress for max visual quality. /// ///**NOTE**: available only on Android. - static const WEBP = const CompressFormat._internal("WEBP"); + static const WEBP = const CompressFormat_._internal("WEBP"); ///Compress to the `WEBP` lossy format. ///Quality of `0` means compress for the smallest size. @@ -55,7 +32,7 @@ class CompressFormat { ///**NOTE**: available only on Android. /// ///**NOTE for Android**: available on Android 30+. - static const WEBP_LOSSY = const CompressFormat._internal("WEBP_LOSSY"); + static const WEBP_LOSSY = const CompressFormat_._internal("WEBP_LOSSY"); ///Compress to the `WEBP` lossless format. ///Quality refers to how much effort to put into compression. @@ -65,10 +42,5 @@ class CompressFormat { ///**NOTE**: available only on Android. /// ///**NOTE for Android**: available on Android 30+. - static const WEBP_LOSSLESS = const CompressFormat._internal("WEBP_LOSSLESS"); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const WEBP_LOSSLESS = const CompressFormat_._internal("WEBP_LOSSLESS"); } \ No newline at end of file diff --git a/lib/src/types/compress_format.g.dart b/lib/src/types/compress_format.g.dart new file mode 100644 index 00000000..ab68248a --- /dev/null +++ b/lib/src/types/compress_format.g.dart @@ -0,0 +1,107 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'compress_format.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that represents the known formats a bitmap can be compressed into. +class CompressFormat { + final String _value; + final String _nativeValue; + const CompressFormat._internal(this._value, this._nativeValue); +// ignore: unused_element + factory CompressFormat._internalMultiPlatform( + String value, Function nativeValue) => + CompressFormat._internal(value, nativeValue()); + + ///Compress to the `PNG` format. + ///PNG is lossless, so `quality` is ignored. + static const PNG = CompressFormat._internal('PNG', 'PNG'); + + ///Compress to the `JPEG` format. + ///Quality of `0` means compress for the smallest size. + ///`100` means compress for max visual quality. + static const JPEG = CompressFormat._internal('JPEG', 'JPEG'); + + ///Compress to the `WEBP` lossy format. + ///Quality of `0` means compress for the smallest size. + ///`100` means compress for max visual quality. + /// + ///**NOTE**: available only on Android. + static const WEBP = CompressFormat._internal('WEBP', 'WEBP'); + + ///Compress to the `WEBP` lossy format. + ///Quality of `0` means compress for the smallest size. + ///`100` means compress for max visual quality. + /// + ///**NOTE**: available only on Android. + /// + ///**NOTE for Android**: available on Android 30+. + static const WEBP_LOSSY = + CompressFormat._internal('WEBP_LOSSY', 'WEBP_LOSSY'); + + ///Compress to the `WEBP` lossless format. + ///Quality refers to how much effort to put into compression. + ///A value of `0` means to compress quickly, resulting in a relatively large file size. + ///`100` means to spend more time compressing, resulting in a smaller file. + /// + ///**NOTE**: available only on Android. + /// + ///**NOTE for Android**: available on Android 30+. + static const WEBP_LOSSLESS = + CompressFormat._internal('WEBP_LOSSLESS', 'WEBP_LOSSLESS'); + + ///Set of all values of [CompressFormat]. + static final Set values = [ + CompressFormat.PNG, + CompressFormat.JPEG, + CompressFormat.WEBP, + CompressFormat.WEBP_LOSSY, + CompressFormat.WEBP_LOSSLESS, + ].toSet(); + + ///Gets a possible [CompressFormat] instance from [String] value. + static CompressFormat? fromValue(String? value) { + if (value != null) { + try { + return CompressFormat.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [CompressFormat] instance from a native value. + static CompressFormat? fromNativeValue(String? value) { + if (value != null) { + try { + return CompressFormat.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/console_message.dart b/lib/src/types/console_message.dart index 403a3c51..33dcbea7 100644 --- a/lib/src/types/console_message.dart +++ b/lib/src/types/console_message.dart @@ -1,45 +1,23 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'console_message_level.dart'; +part 'console_message.g.dart'; + ///Class representing a JavaScript console message from WebCore. ///This could be a issued by a call to one of the console logging functions (e.g. console.log('...')) or a JavaScript error on the page. /// ///To receive notifications of these messages, use the [WebView.onConsoleMessage] event. -class ConsoleMessage { +@ExchangeableObject() +class ConsoleMessage_ { ///Console message String message; ///Console messsage level - ConsoleMessageLevel messageLevel; + ConsoleMessageLevel_ messageLevel; - ConsoleMessage( - {this.message = "", this.messageLevel = ConsoleMessageLevel.LOG}); - - ///Gets a possible [ConsoleMessage] instance from a [Map] value. - static ConsoleMessage? fromMap(Map? map) { - if (map == null) { - return null; - } - return ConsoleMessage( - message: map["message"], - messageLevel: ConsoleMessageLevel.fromValue(map["messageLevel"]) ?? - ConsoleMessageLevel.LOG, - ); - } - - ///Converts instance to a map. - Map toMap() { - return {"message": message, "messageLevel": messageLevel.toValue()}; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + ConsoleMessage_( + {this.message = "", this.messageLevel = ConsoleMessageLevel_.LOG}); } \ No newline at end of file diff --git a/lib/src/types/console_message.g.dart b/lib/src/types/console_message.g.dart new file mode 100644 index 00000000..4573e448 --- /dev/null +++ b/lib/src/types/console_message.g.dart @@ -0,0 +1,51 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'console_message.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class representing a JavaScript console message from WebCore. +///This could be a issued by a call to one of the console logging functions (e.g. console.log('...')) or a JavaScript error on the page. +/// +///To receive notifications of these messages, use the [WebView.onConsoleMessage] event. +class ConsoleMessage { + ///Console message + String message; + + ///Console messsage level + ConsoleMessageLevel messageLevel; + ConsoleMessage( + {this.message = "", this.messageLevel = ConsoleMessageLevel.LOG}); + + ///Gets a possible [ConsoleMessage] instance from a [Map] value. + static ConsoleMessage? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = ConsoleMessage(); + instance.message = map['message']; + instance.messageLevel = + ConsoleMessageLevel.fromNativeValue(map['messageLevel'])!; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "message": message, + "messageLevel": messageLevel.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'ConsoleMessage{message: $message, messageLevel: $messageLevel}'; + } +} diff --git a/lib/src/types/console_message_level.dart b/lib/src/types/console_message_level.dart index 89219449..96858121 100644 --- a/lib/src/types/console_message_level.dart +++ b/lib/src/types/console_message_level.dart @@ -1,68 +1,26 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'console_message_level.g.dart'; + ///Class representing the level of a console message. -class ConsoleMessageLevel { +@ExchangeableEnum() +class ConsoleMessageLevel_ { + // ignore: unused_field final int _value; - - const ConsoleMessageLevel._internal(this._value); - - ///Set of all values of [ConsoleMessageLevel]. - static final Set values = [ - ConsoleMessageLevel.TIP, - ConsoleMessageLevel.LOG, - ConsoleMessageLevel.WARNING, - ConsoleMessageLevel.ERROR, - ConsoleMessageLevel.DEBUG, - ].toSet(); - - ///Gets a possible [ConsoleMessageLevel] instance from an [int] value. - static ConsoleMessageLevel? fromValue(int? value) { - if (value != null) { - try { - return ConsoleMessageLevel.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [int] value. - int toValue() => _value; - - @override - String toString() { - switch (_value) { - case 0: - return "TIP"; - case 2: - return "WARNING"; - case 3: - return "ERROR"; - case 4: - return "DEBUG"; - case 1: - default: - return "LOG"; - } - } + const ConsoleMessageLevel_._internal(this._value); ///Console TIP level - static const TIP = const ConsoleMessageLevel._internal(0); + static const TIP = const ConsoleMessageLevel_._internal(0); ///Console LOG level - static const LOG = const ConsoleMessageLevel._internal(1); + static const LOG = const ConsoleMessageLevel_._internal(1); ///Console WARNING level - static const WARNING = const ConsoleMessageLevel._internal(2); + static const WARNING = const ConsoleMessageLevel_._internal(2); ///Console ERROR level - static const ERROR = const ConsoleMessageLevel._internal(3); + static const ERROR = const ConsoleMessageLevel_._internal(3); ///Console DEBUG level - static const DEBUG = const ConsoleMessageLevel._internal(4); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + static const DEBUG = const ConsoleMessageLevel_._internal(4); } \ No newline at end of file diff --git a/lib/src/types/console_message_level.g.dart b/lib/src/types/console_message_level.g.dart new file mode 100644 index 00000000..c221ebae --- /dev/null +++ b/lib/src/types/console_message_level.g.dart @@ -0,0 +1,97 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'console_message_level.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class representing the level of a console message. +class ConsoleMessageLevel { + final int _value; + final int _nativeValue; + const ConsoleMessageLevel._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ConsoleMessageLevel._internalMultiPlatform( + int value, Function nativeValue) => + ConsoleMessageLevel._internal(value, nativeValue()); + + ///Console TIP level + static const TIP = ConsoleMessageLevel._internal(0, 0); + + ///Console LOG level + static const LOG = ConsoleMessageLevel._internal(1, 1); + + ///Console WARNING level + static const WARNING = ConsoleMessageLevel._internal(2, 2); + + ///Console ERROR level + static const ERROR = ConsoleMessageLevel._internal(3, 3); + + ///Console DEBUG level + static const DEBUG = ConsoleMessageLevel._internal(4, 4); + + ///Set of all values of [ConsoleMessageLevel]. + static final Set values = [ + ConsoleMessageLevel.TIP, + ConsoleMessageLevel.LOG, + ConsoleMessageLevel.WARNING, + ConsoleMessageLevel.ERROR, + ConsoleMessageLevel.DEBUG, + ].toSet(); + + ///Gets a possible [ConsoleMessageLevel] instance from [int] value. + static ConsoleMessageLevel? fromValue(int? value) { + if (value != null) { + try { + return ConsoleMessageLevel.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ConsoleMessageLevel] instance from a native value. + static ConsoleMessageLevel? fromNativeValue(int? value) { + if (value != null) { + try { + return ConsoleMessageLevel.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [int] value. + int toValue() => _value; + + ///Gets [int] native value. + int toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + switch (_value) { + case 0: + return 'TIP'; + case 1: + return 'LOG'; + case 2: + return 'WARNING'; + case 3: + return 'ERROR'; + case 4: + return 'DEBUG'; + } + return _value.toString(); + } +} diff --git a/lib/src/types/content_blocker_action_type.dart b/lib/src/types/content_blocker_action_type.dart index c6530acf..11b7e057 100644 --- a/lib/src/types/content_blocker_action_type.dart +++ b/lib/src/types/content_blocker_action_type.dart @@ -1,52 +1,26 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../content_blocker.dart'; +part 'content_blocker_action_type.g.dart'; + ///Class that represents the kind of action that can be used with a [ContentBlockerTrigger]. -class ContentBlockerActionType { +@ExchangeableEnum() +class ContentBlockerActionType_ { + // ignore: unused_field final String _value; - - const ContentBlockerActionType._internal(this._value); - - ///Set of all values of [ContentBlockerActionType]. - static final Set values = [ - ContentBlockerActionType.BLOCK, - ContentBlockerActionType.CSS_DISPLAY_NONE, - ContentBlockerActionType.MAKE_HTTPS, - ].toSet(); - - ///Gets a possible [ContentBlockerActionType] instance from a [String] value. - static ContentBlockerActionType? fromValue(String? value) { - if (value != null) { - try { - return ContentBlockerActionType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - @override - String toString() => _value; + const ContentBlockerActionType_._internal(this._value); ///Stops loading of the resource. If the resource was cached, the cache is ignored. - static const BLOCK = const ContentBlockerActionType._internal('block'); + static const BLOCK = const ContentBlockerActionType_._internal('block'); ///Hides elements of the page based on a CSS selector. A selector field contains the selector list. Any matching element has its display property set to none, which hides it. /// ///**NOTE**: on Android, JavaScript must be enabled. static const CSS_DISPLAY_NONE = - const ContentBlockerActionType._internal('css-display-none'); + const ContentBlockerActionType_._internal('css-display-none'); ///Changes a URL from http to https. URLs with a specified (nondefault) port and links using other protocols are unaffected. static const MAKE_HTTPS = - const ContentBlockerActionType._internal('make-https'); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + const ContentBlockerActionType_._internal('make-https'); } \ No newline at end of file diff --git a/lib/src/types/content_blocker_action_type.g.dart b/lib/src/types/content_blocker_action_type.g.dart new file mode 100644 index 00000000..45b202ec --- /dev/null +++ b/lib/src/types/content_blocker_action_type.g.dart @@ -0,0 +1,81 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'content_blocker_action_type.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that represents the kind of action that can be used with a [ContentBlockerTrigger]. +class ContentBlockerActionType { + final String _value; + final String _nativeValue; + const ContentBlockerActionType._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ContentBlockerActionType._internalMultiPlatform( + String value, Function nativeValue) => + ContentBlockerActionType._internal(value, nativeValue()); + + ///Stops loading of the resource. If the resource was cached, the cache is ignored. + static const BLOCK = ContentBlockerActionType._internal('block', 'block'); + + ///Hides elements of the page based on a CSS selector. A selector field contains the selector list. Any matching element has its display property set to none, which hides it. + /// + ///**NOTE**: on Android, JavaScript must be enabled. + static const CSS_DISPLAY_NONE = ContentBlockerActionType._internal( + 'css-display-none', 'css-display-none'); + + ///Changes a URL from http to https. URLs with a specified (nondefault) port and links using other protocols are unaffected. + static const MAKE_HTTPS = + ContentBlockerActionType._internal('make-https', 'make-https'); + + ///Set of all values of [ContentBlockerActionType]. + static final Set values = [ + ContentBlockerActionType.BLOCK, + ContentBlockerActionType.CSS_DISPLAY_NONE, + ContentBlockerActionType.MAKE_HTTPS, + ].toSet(); + + ///Gets a possible [ContentBlockerActionType] instance from [String] value. + static ContentBlockerActionType? fromValue(String? value) { + if (value != null) { + try { + return ContentBlockerActionType.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ContentBlockerActionType] instance from a native value. + static ContentBlockerActionType? fromNativeValue(String? value) { + if (value != null) { + try { + return ContentBlockerActionType.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/content_blocker_trigger_load_type.dart b/lib/src/types/content_blocker_trigger_load_type.dart index 992499b0..0c6c5123 100644 --- a/lib/src/types/content_blocker_trigger_load_type.dart +++ b/lib/src/types/content_blocker_trigger_load_type.dart @@ -1,46 +1,21 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../content_blocker.dart'; +part 'content_blocker_trigger_load_type.g.dart'; + ///Class that represents the possible load type for a [ContentBlockerTrigger]. -class ContentBlockerTriggerLoadType { +@ExchangeableEnum() +class ContentBlockerTriggerLoadType_ { + // ignore: unused_field final String _value; - - const ContentBlockerTriggerLoadType._internal(this._value); - - ///Set of all values of [ContentBlockerTriggerLoadType]. - static final Set values = [ - ContentBlockerTriggerLoadType.FIRST_PARTY, - ContentBlockerTriggerLoadType.THIRD_PARTY, - ].toSet(); - - ///Gets a possible [ContentBlockerTriggerLoadType] instance from a [String] value. - static ContentBlockerTriggerLoadType? fromValue(String? value) { - if (value != null) { - try { - return ContentBlockerTriggerLoadType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - @override - String toString() => _value; + const ContentBlockerTriggerLoadType_._internal(this._value); ///FIRST_PARTY is triggered only if the resource has the same scheme, domain, and port as the main page resource. static const FIRST_PARTY = - const ContentBlockerTriggerLoadType._internal('first-party'); + const ContentBlockerTriggerLoadType_._internal('first-party'); ///THIRD_PARTY is triggered if the resource is not from the same domain as the main page resource. static const THIRD_PARTY = - const ContentBlockerTriggerLoadType._internal('third-party'); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; + const ContentBlockerTriggerLoadType_._internal('third-party'); } \ No newline at end of file diff --git a/lib/src/types/content_blocker_trigger_load_type.g.dart b/lib/src/types/content_blocker_trigger_load_type.g.dart new file mode 100644 index 00000000..8821e70a --- /dev/null +++ b/lib/src/types/content_blocker_trigger_load_type.g.dart @@ -0,0 +1,75 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'content_blocker_trigger_load_type.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that represents the possible load type for a [ContentBlockerTrigger]. +class ContentBlockerTriggerLoadType { + final String _value; + final String _nativeValue; + const ContentBlockerTriggerLoadType._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ContentBlockerTriggerLoadType._internalMultiPlatform( + String value, Function nativeValue) => + ContentBlockerTriggerLoadType._internal(value, nativeValue()); + + ///FIRST_PARTY is triggered only if the resource has the same scheme, domain, and port as the main page resource. + static const FIRST_PARTY = + ContentBlockerTriggerLoadType._internal('first-party', 'first-party'); + + ///THIRD_PARTY is triggered if the resource is not from the same domain as the main page resource. + static const THIRD_PARTY = + ContentBlockerTriggerLoadType._internal('third-party', 'third-party'); + + ///Set of all values of [ContentBlockerTriggerLoadType]. + static final Set values = [ + ContentBlockerTriggerLoadType.FIRST_PARTY, + ContentBlockerTriggerLoadType.THIRD_PARTY, + ].toSet(); + + ///Gets a possible [ContentBlockerTriggerLoadType] instance from [String] value. + static ContentBlockerTriggerLoadType? fromValue(String? value) { + if (value != null) { + try { + return ContentBlockerTriggerLoadType.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ContentBlockerTriggerLoadType] instance from a native value. + static ContentBlockerTriggerLoadType? fromNativeValue(String? value) { + if (value != null) { + try { + return ContentBlockerTriggerLoadType.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/content_blocker_trigger_resource_type.dart b/lib/src/types/content_blocker_trigger_resource_type.dart index f9945fba..cd232bce 100644 --- a/lib/src/types/content_blocker_trigger_resource_type.dart +++ b/lib/src/types/content_blocker_trigger_resource_type.dart @@ -1,61 +1,31 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../content_blocker.dart'; +part 'content_blocker_trigger_resource_type.g.dart'; + ///Class that represents the possible resource type defined for a [ContentBlockerTrigger]. -class ContentBlockerTriggerResourceType { +@ExchangeableEnum() +class ContentBlockerTriggerResourceType_ { + // ignore: unused_field final String _value; - - const ContentBlockerTriggerResourceType._internal(this._value); - - ///Set of all values of [ContentBlockerTriggerResourceType]. - static final Set values = [ - ContentBlockerTriggerResourceType.DOCUMENT, - ContentBlockerTriggerResourceType.IMAGE, - ContentBlockerTriggerResourceType.STYLE_SHEET, - ContentBlockerTriggerResourceType.SCRIPT, - ContentBlockerTriggerResourceType.FONT, - ContentBlockerTriggerResourceType.MEDIA, - ContentBlockerTriggerResourceType.SVG_DOCUMENT, - ContentBlockerTriggerResourceType.RAW, - ].toSet(); - - ///Gets a possible [ContentBlockerTriggerResourceType] instance from a [String] value. - static ContentBlockerTriggerResourceType? fromValue(String? value) { - if (value != null) { - try { - return ContentBlockerTriggerResourceType.values - .firstWhere((element) => element.toValue() == value); - } catch (e) { - return null; - } - } - return null; - } - - ///Gets [String] value. - String toValue() => _value; - - @override - String toString() => _value; + const ContentBlockerTriggerResourceType_._internal(this._value); static const DOCUMENT = - const ContentBlockerTriggerResourceType._internal('document'); + const ContentBlockerTriggerResourceType_._internal('document'); static const IMAGE = - const ContentBlockerTriggerResourceType._internal('image'); + const ContentBlockerTriggerResourceType_._internal('image'); static const STYLE_SHEET = - const ContentBlockerTriggerResourceType._internal('style-sheet'); + const ContentBlockerTriggerResourceType_._internal('style-sheet'); static const SCRIPT = - const ContentBlockerTriggerResourceType._internal('script'); - static const FONT = const ContentBlockerTriggerResourceType._internal('font'); + const ContentBlockerTriggerResourceType_._internal('script'); + static const FONT = + const ContentBlockerTriggerResourceType_._internal('font'); static const MEDIA = - const ContentBlockerTriggerResourceType._internal('media'); + const ContentBlockerTriggerResourceType_._internal('media'); static const SVG_DOCUMENT = - const ContentBlockerTriggerResourceType._internal('svg-document'); + const ContentBlockerTriggerResourceType_._internal('svg-document'); ///Any untyped load - static const RAW = const ContentBlockerTriggerResourceType._internal('raw'); - - bool operator ==(value) => value == _value; - - @override - int get hashCode => _value.hashCode; -} \ No newline at end of file + static const RAW = const ContentBlockerTriggerResourceType_._internal('raw'); +} diff --git a/lib/src/types/content_blocker_trigger_resource_type.g.dart b/lib/src/types/content_blocker_trigger_resource_type.g.dart new file mode 100644 index 00000000..3dadda51 --- /dev/null +++ b/lib/src/types/content_blocker_trigger_resource_type.g.dart @@ -0,0 +1,91 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'content_blocker_trigger_resource_type.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class that represents the possible resource type defined for a [ContentBlockerTrigger]. +class ContentBlockerTriggerResourceType { + final String _value; + final String _nativeValue; + const ContentBlockerTriggerResourceType._internal( + this._value, this._nativeValue); +// ignore: unused_element + factory ContentBlockerTriggerResourceType._internalMultiPlatform( + String value, Function nativeValue) => + ContentBlockerTriggerResourceType._internal(value, nativeValue()); + static const DOCUMENT = + ContentBlockerTriggerResourceType._internal('document', 'document'); + static const IMAGE = + ContentBlockerTriggerResourceType._internal('image', 'image'); + static const STYLE_SHEET = + ContentBlockerTriggerResourceType._internal('style-sheet', 'style-sheet'); + static const SCRIPT = + ContentBlockerTriggerResourceType._internal('script', 'script'); + static const FONT = + ContentBlockerTriggerResourceType._internal('font', 'font'); + static const MEDIA = + ContentBlockerTriggerResourceType._internal('media', 'media'); + static const SVG_DOCUMENT = ContentBlockerTriggerResourceType._internal( + 'svg-document', 'svg-document'); + + ///Any untyped load + static const RAW = ContentBlockerTriggerResourceType._internal('raw', 'raw'); + + ///Set of all values of [ContentBlockerTriggerResourceType]. + static final Set values = [ + ContentBlockerTriggerResourceType.DOCUMENT, + ContentBlockerTriggerResourceType.IMAGE, + ContentBlockerTriggerResourceType.STYLE_SHEET, + ContentBlockerTriggerResourceType.SCRIPT, + ContentBlockerTriggerResourceType.FONT, + ContentBlockerTriggerResourceType.MEDIA, + ContentBlockerTriggerResourceType.SVG_DOCUMENT, + ContentBlockerTriggerResourceType.RAW, + ].toSet(); + + ///Gets a possible [ContentBlockerTriggerResourceType] instance from [String] value. + static ContentBlockerTriggerResourceType? fromValue(String? value) { + if (value != null) { + try { + return ContentBlockerTriggerResourceType.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ContentBlockerTriggerResourceType] instance from a native value. + static ContentBlockerTriggerResourceType? fromNativeValue(String? value) { + if (value != null) { + try { + return ContentBlockerTriggerResourceType.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [String] native value. + String toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/lib/src/types/content_world.dart b/lib/src/types/content_world.dart index 2c86cb38..4607b0fc 100644 --- a/lib/src/types/content_world.dart +++ b/lib/src/types/content_world.dart @@ -24,7 +24,6 @@ class ContentWorld { } ///The default world for clients. - // ignore: non_constant_identifier_names static final ContentWorld DEFAULT_CLIENT = ContentWorld.world(name: "defaultClient"); @@ -32,7 +31,6 @@ class ContentWorld { ///This property contains the content world for scripts that the current webpage executes. ///Be careful when manipulating variables in this content world. ///If you modify a variable with the same name as one the webpage uses, you may unintentionally disrupt the normal operation of that page. - // ignore: non_constant_identifier_names static final ContentWorld PAGE = ContentWorld.world(name: "page"); ///Converts instance to a map. diff --git a/lib/src/types/cookie.dart b/lib/src/types/cookie.dart index 886ee6e7..1e47191c 100644 --- a/lib/src/types/cookie.dart +++ b/lib/src/types/cookie.dart @@ -1,8 +1,13 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../cookie_manager.dart'; import 'http_cookie_same_site_policy.dart'; +part 'cookie.g.dart'; + ///Class that represents a cookie returned by the [CookieManager]. -class Cookie { +@ExchangeableObject() +class Cookie_ { ///The cookie name. String name; @@ -27,7 +32,7 @@ class Cookie { ///The cookie same site policy. /// ///**NOTE**: on Android it will be always `null`. - HTTPCookieSameSitePolicy? sameSite; + HTTPCookieSameSitePolicy_? sameSite; ///Indicates if the cookie is secure or not. /// @@ -44,7 +49,7 @@ class Cookie { ///**NOTE**: on Android it will be always `null`. String? path; - Cookie( + Cookie_( {required this.name, required this.value, this.expiresDate, @@ -54,29 +59,4 @@ class Cookie { this.isSecure, this.isHttpOnly, this.path}); - - ///Converts instance to a map. - Map toMap() { - return { - "name": name, - "value": value, - "expiresDate": expiresDate, - "isSessionOnly": isSessionOnly, - "domain": domain, - "sameSite": sameSite?.toValue(), - "isSecure": isSecure, - "isHttpOnly": isHttpOnly, - "path": path - }; - } - - ///Converts instance to a map. - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } } \ No newline at end of file diff --git a/lib/src/types/cookie.g.dart b/lib/src/types/cookie.g.dart new file mode 100644 index 00000000..6994beb3 --- /dev/null +++ b/lib/src/types/cookie.g.dart @@ -0,0 +1,106 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'cookie.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents a cookie returned by the [CookieManager]. +class Cookie { + ///The cookie name. + String name; + + ///The cookie value. + dynamic value; + + ///The cookie expiration date in milliseconds. + /// + ///**NOTE**: on Android it will be always `null`. + int? expiresDate; + + ///Indicates if the cookie is a session only cookie. + /// + ///**NOTE**: on Android it will be always `null`. + bool? isSessionOnly; + + ///The cookie domain. + /// + ///**NOTE**: on Android it will be always `null`. + String? domain; + + ///The cookie same site policy. + /// + ///**NOTE**: on Android it will be always `null`. + HTTPCookieSameSitePolicy? sameSite; + + ///Indicates if the cookie is secure or not. + /// + ///**NOTE**: on Android it will be always `null`. + bool? isSecure; + + ///Indicates if the cookie is a http only cookie. + /// + ///**NOTE**: on Android it will be always `null`. + bool? isHttpOnly; + + ///The cookie path. + /// + ///**NOTE**: on Android it will be always `null`. + String? path; + Cookie( + {required this.name, + this.value, + this.expiresDate, + this.isSessionOnly, + this.domain, + this.sameSite, + this.isSecure, + this.isHttpOnly, + this.path}); + + ///Gets a possible [Cookie] instance from a [Map] value. + static Cookie? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = Cookie( + name: map['name'], + value: map['value'], + ); + instance.expiresDate = map['expiresDate']; + instance.isSessionOnly = map['isSessionOnly']; + instance.domain = map['domain']; + instance.sameSite = + HTTPCookieSameSitePolicy.fromNativeValue(map['sameSite']); + instance.isSecure = map['isSecure']; + instance.isHttpOnly = map['isHttpOnly']; + instance.path = map['path']; + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "name": name, + "value": value, + "expiresDate": expiresDate, + "isSessionOnly": isSessionOnly, + "domain": domain, + "sameSite": sameSite?.toNativeValue(), + "isSecure": isSecure, + "isHttpOnly": isHttpOnly, + "path": path, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'Cookie{name: $name, value: $value, expiresDate: $expiresDate, isSessionOnly: $isSessionOnly, domain: $domain, sameSite: $sameSite, isSecure: $isSecure, isHttpOnly: $isHttpOnly, path: $path}'; + } +} diff --git a/lib/src/types/create_window_action.dart b/lib/src/types/create_window_action.dart index 11b6e549..33ee7aff 100644 --- a/lib/src/types/create_window_action.dart +++ b/lib/src/types/create_window_action.dart @@ -1,3 +1,5 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import '../in_app_webview/webview.dart'; import 'navigation_action.dart'; import 'window_features.dart'; @@ -5,8 +7,11 @@ import 'url_request.dart'; import 'frame_info.dart'; import 'navigation_type.dart'; +part 'create_window_action.g.dart'; + ///Class that represents the navigation request used by the [WebView.onCreateWindow] event. -class CreateWindowAction extends NavigationAction { +@ExchangeableObject() +class CreateWindowAction_ extends NavigationAction_ { ///The window id. Used by [WebView] to create a new WebView. int windowId; @@ -15,20 +20,29 @@ class CreateWindowAction extends NavigationAction { bool? androidIsDialog; ///Indicates if the new window should be a dialog, rather than a full-size window. - /// - ///**NOTE**: available only on Android. + @SupportedPlatforms( + platforms: [ + AndroidPlatform() + ] + ) bool? isDialog; ///Use [windowFeatures] instead. @Deprecated("Use windowFeatures instead") - IOSWKWindowFeatures? iosWindowFeatures; + IOSWKWindowFeatures_? iosWindowFeatures; ///Window features requested by the webpage. - /// - ///**NOTE**: available only on iOS. - WindowFeatures? windowFeatures; + @SupportedPlatforms( + platforms: [ + IOSPlatform( + apiName: "WKWindowFeatures", + apiUrl: "https://developer.apple.com/documentation/webkit/wkwindowfeatures" + ) + ] + ) + WindowFeatures_? windowFeatures; - CreateWindowAction( + CreateWindowAction_( {required this.windowId, @Deprecated('Use isDialog instead') this.androidIsDialog, @@ -36,7 +50,7 @@ class CreateWindowAction extends NavigationAction { @Deprecated('Use windowFeatures instead') this.iosWindowFeatures, this.windowFeatures, - required URLRequest request, + required URLRequest_ request, required bool isForMainFrame, @Deprecated('Use hasGesture instead') bool? androidHasGesture, @@ -46,113 +60,27 @@ class CreateWindowAction extends NavigationAction { bool? isRedirect, @Deprecated('Use navigationType instead') // ignore: deprecated_member_use_from_same_package - IOSWKNavigationType? iosWKNavigationType, - NavigationType? navigationType, + IOSWKNavigationType_? iosWKNavigationType, + NavigationType_? navigationType, @Deprecated('Use sourceFrame instead') // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo? iosSourceFrame, - FrameInfo? sourceFrame, + IOSWKFrameInfo_? iosSourceFrame, + FrameInfo_? sourceFrame, @Deprecated('Use targetFrame instead') // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo? iosTargetFrame, - FrameInfo? targetFrame}) + IOSWKFrameInfo_? iosTargetFrame, + FrameInfo_? targetFrame}) : super( request: request, isForMainFrame: isForMainFrame, - // ignore: deprecated_member_use_from_same_package - androidHasGesture: hasGesture ?? androidHasGesture, - hasGesture: hasGesture ?? androidHasGesture, - // ignore: deprecated_member_use_from_same_package - androidIsRedirect: isRedirect ?? androidIsRedirect, - isRedirect: isRedirect ?? androidIsRedirect, - // ignore: deprecated_member_use_from_same_package - iosWKNavigationType: - // ignore: deprecated_member_use_from_same_package - IOSWKNavigationType.fromValue(navigationType?.toValue()) ?? - iosWKNavigationType, - navigationType: navigationType ?? - NavigationType.fromValue(iosWKNavigationType?.toValue()), - // ignore: deprecated_member_use_from_same_package - iosSourceFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(sourceFrame?.toMap()) ?? iosSourceFrame, - sourceFrame: - sourceFrame ?? FrameInfo.fromMap(iosSourceFrame?.toMap()), - // ignore: deprecated_member_use_from_same_package - iosTargetFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(targetFrame?.toMap()) ?? iosTargetFrame, - targetFrame: - targetFrame ?? FrameInfo.fromMap(iosTargetFrame?.toMap())) { - // ignore: deprecated_member_use_from_same_package - this.isDialog = this.isDialog ?? this.androidIsDialog; - this.windowFeatures = this.windowFeatures ?? - // ignore: deprecated_member_use_from_same_package - WindowFeatures.fromMap(this.iosWindowFeatures?.toMap()); - } - - ///Gets a possible [CreateWindowAction] instance from a [Map] value. - static CreateWindowAction? fromMap(Map? map) { - if (map == null) { - return null; - } - return CreateWindowAction( - windowId: map["windowId"], - // ignore: deprecated_member_use_from_same_package - androidIsDialog: map["isDialog"] ?? map["androidIsDialog"], - isDialog: map["isDialog"] ?? map["androidIsDialog"], - // ignore: deprecated_member_use_from_same_package - iosWindowFeatures: IOSWKWindowFeatures.fromMap( - map["windowFeatures"]?.cast()), - windowFeatures: WindowFeatures.fromMap( - map["windowFeatures"]?.cast()), - request: URLRequest.fromMap(map["request"].cast())!, - isForMainFrame: map["isForMainFrame"], - // ignore: deprecated_member_use_from_same_package - androidHasGesture: map["hasGesture"], - hasGesture: map["hasGesture"], - // ignore: deprecated_member_use_from_same_package - androidIsRedirect: map["isRedirect"], - isRedirect: map["isRedirect"], - // ignore: deprecated_member_use_from_same_package - iosWKNavigationType: - // ignore: deprecated_member_use_from_same_package - IOSWKNavigationType.fromValue(map["navigationType"]), - navigationType: NavigationType.fromValue(map["navigationType"]), - // ignore: deprecated_member_use_from_same_package - iosSourceFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(map["sourceFrame"]?.cast()), - sourceFrame: - FrameInfo.fromMap(map["sourceFrame"]?.cast()), - // ignore: deprecated_member_use_from_same_package - iosTargetFrame: - // ignore: deprecated_member_use_from_same_package - IOSWKFrameInfo.fromMap(map["targetFrame"]?.cast()), - targetFrame: - FrameInfo.fromMap(map["targetFrame"]?.cast())); - } - - @override - Map toMap() { - var createWindowActionMap = super.toMap(); - createWindowActionMap.addAll({ - "windowId": windowId, - // ignore: deprecated_member_use_from_same_package - "androidIsDialog": isDialog ?? androidIsDialog, - // ignore: deprecated_member_use_from_same_package - "isDialog": isDialog ?? androidIsDialog, - "iosWindowFeatures": - // ignore: deprecated_member_use_from_same_package - windowFeatures?.toMap() ?? iosWindowFeatures?.toMap(), - // ignore: deprecated_member_use_from_same_package - "windowFeatures": windowFeatures?.toMap() ?? iosWindowFeatures?.toMap(), - }); - return createWindowActionMap; - } - - @override - String toString() { - return toMap().toString(); - } + androidHasGesture: androidHasGesture, + hasGesture: hasGesture, + androidIsRedirect: androidIsRedirect, + isRedirect: isRedirect, + iosWKNavigationType: iosWKNavigationType, + navigationType: navigationType, + iosSourceFrame: iosSourceFrame, + sourceFrame: sourceFrame, + iosTargetFrame: iosTargetFrame, + targetFrame: targetFrame); } \ No newline at end of file diff --git a/lib/src/types/create_window_action.g.dart b/lib/src/types/create_window_action.g.dart new file mode 100644 index 00000000..d1a4ecdc --- /dev/null +++ b/lib/src/types/create_window_action.g.dart @@ -0,0 +1,140 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'create_window_action.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///Class that represents the navigation request used by the [WebView.onCreateWindow] event. +class CreateWindowAction extends NavigationAction { + ///The window id. Used by [WebView] to create a new WebView. + int windowId; + + ///Use [isDialog] instead. + @Deprecated('Use isDialog instead') + bool? androidIsDialog; + + ///Indicates if the new window should be a dialog, rather than a full-size window. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + bool? isDialog; + + ///Use [windowFeatures] instead. + @Deprecated('Use windowFeatures instead') + IOSWKWindowFeatures? iosWindowFeatures; + + ///Window features requested by the webpage. + /// + ///**Supported Platforms/Implementations**: + ///- iOS ([Official API - WKWindowFeatures](https://developer.apple.com/documentation/webkit/wkwindowfeatures)) + WindowFeatures? windowFeatures; + CreateWindowAction( + {required this.windowId, + @Deprecated('Use isDialog instead') + this.androidIsDialog, + this.isDialog, + @Deprecated('Use windowFeatures instead') + this.iosWindowFeatures, + this.windowFeatures, + required URLRequest request, + required bool isForMainFrame, + @Deprecated('Use hasGesture instead') + bool? androidHasGesture, + bool? hasGesture, + @Deprecated('Use isRedirect instead') + bool? androidIsRedirect, + bool? isRedirect, + @Deprecated('Use navigationType instead') + IOSWKNavigationType? iosWKNavigationType, + NavigationType? navigationType, + @Deprecated('Use sourceFrame instead') + IOSWKFrameInfo? iosSourceFrame, + FrameInfo? sourceFrame, + @Deprecated('Use targetFrame instead') + IOSWKFrameInfo? iosTargetFrame, + FrameInfo? targetFrame, + bool? shouldPerformDownload}) + : super( + request: request, + isForMainFrame: isForMainFrame, + androidHasGesture: androidHasGesture, + hasGesture: hasGesture, + androidIsRedirect: androidIsRedirect, + isRedirect: isRedirect, + iosWKNavigationType: iosWKNavigationType, + navigationType: navigationType, + iosSourceFrame: iosSourceFrame, + sourceFrame: sourceFrame, + iosTargetFrame: iosTargetFrame, + targetFrame: targetFrame, + shouldPerformDownload: shouldPerformDownload) { + isDialog = isDialog ?? androidIsDialog; + windowFeatures = + windowFeatures ?? WindowFeatures.fromMap(iosWindowFeatures?.toMap()); + } + + ///Gets a possible [CreateWindowAction] instance from a [Map] value. + static CreateWindowAction? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = CreateWindowAction( + request: URLRequest.fromMap(map['request']?.cast())!, + isForMainFrame: map['isForMainFrame'], + windowId: map['windowId'], + ); + instance.androidHasGesture = map['hasGesture']; + instance.hasGesture = map['hasGesture']; + instance.androidIsRedirect = map['isRedirect']; + instance.isRedirect = map['isRedirect']; + instance.iosWKNavigationType = + IOSWKNavigationType.fromNativeValue(map['navigationType']); + instance.navigationType = + NavigationType.fromNativeValue(map['navigationType']); + instance.iosSourceFrame = + IOSWKFrameInfo.fromMap(map['sourceFrame']?.cast()); + instance.sourceFrame = + FrameInfo.fromMap(map['sourceFrame']?.cast()); + instance.iosTargetFrame = + IOSWKFrameInfo.fromMap(map['targetFrame']?.cast()); + instance.targetFrame = + FrameInfo.fromMap(map['targetFrame']?.cast()); + instance.shouldPerformDownload = map['shouldPerformDownload']; + instance.androidIsDialog = map['isDialog']; + instance.isDialog = map['isDialog']; + instance.iosWindowFeatures = IOSWKWindowFeatures.fromMap( + map['windowFeatures']?.cast()); + instance.windowFeatures = + WindowFeatures.fromMap(map['windowFeatures']?.cast()); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "request": request.toMap(), + "isForMainFrame": isForMainFrame, + "hasGesture": hasGesture, + "isRedirect": isRedirect, + "navigationType": navigationType?.toNativeValue(), + "sourceFrame": sourceFrame?.toMap(), + "targetFrame": targetFrame?.toMap(), + "shouldPerformDownload": shouldPerformDownload, + "windowId": windowId, + "isDialog": isDialog, + "windowFeatures": windowFeatures?.toMap(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'CreateWindowAction{request: $request, isForMainFrame: $isForMainFrame, hasGesture: $hasGesture, isRedirect: $isRedirect, navigationType: $navigationType, sourceFrame: $sourceFrame, targetFrame: $targetFrame, shouldPerformDownload: $shouldPerformDownload, windowId: $windowId, isDialog: $isDialog, windowFeatures: $windowFeatures}'; + } +} diff --git a/lib/src/types/cross_origin.dart b/lib/src/types/cross_origin.dart index a24a3248..b0084dcd 100644 --- a/lib/src/types/cross_origin.dart +++ b/lib/src/types/cross_origin.dart @@ -1,47 +1,22 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + import 'script_html_tag_attributes.dart'; import 'css_link_html_tag_attributes.dart'; +part 'cross_origin.g.dart'; + ///Class that represents the `crossorigin` content attribute on media elements, which is a CORS settings attribute. ///It could be used with [ScriptHtmlTagAttributes] and [CSSLinkHtmlTagAttributes] ///when fetching a resource `` or a `