From ec2190162de2fcd3a488fca816b39c980f18d1c4 Mon Sep 17 00:00:00 2001 From: thomashii Date: Mon, 21 Jun 2021 13:43:02 +0800 Subject: [PATCH] Updated user_agent --- .../user_agent/angel_user_agent/CHANGELOG.md | 10 +++-- .../user_agent/angel_user_agent/README.md | 14 +++++-- .../angel_user_agent/example/example.dart | 11 +++-- ...user_agent.dart => angel3_user_agent.dart} | 4 +- .../user_agent/angel_user_agent/pubspec.yaml | 19 +++------ packages/user_agent/user_agent/CHANGELOG.md | 4 ++ packages/user_agent/user_agent/README.md | 2 +- .../user_agent/lib/user_agent_analyzer.dart | 42 +++++++++---------- packages/user_agent/user_agent/pubspec.yaml | 2 +- 9 files changed, 57 insertions(+), 51 deletions(-) rename packages/user_agent/angel_user_agent/lib/{angel_user_agent.dart => angel3_user_agent.dart} (86%) diff --git a/packages/user_agent/angel_user_agent/CHANGELOG.md b/packages/user_agent/angel_user_agent/CHANGELOG.md index 73335660..f5ffca77 100644 --- a/packages/user_agent/angel_user_agent/CHANGELOG.md +++ b/packages/user_agent/angel_user_agent/CHANGELOG.md @@ -1,5 +1,9 @@ -# 3.0.0 +# Change Log + +## 3.0.0 + * Migrated to support Dart SDK 2.12.x NNBD -# 2.0.0 -* Angel 2 + Dart 2 updates \ No newline at end of file +## 2.0.0 + +* Angel 2 + Dart 2 updates diff --git a/packages/user_agent/angel_user_agent/README.md b/packages/user_agent/angel_user_agent/README.md index c6753785..851a05de 100644 --- a/packages/user_agent/angel_user_agent/README.md +++ b/packages/user_agent/angel_user_agent/README.md @@ -1,3 +1,11 @@ -# user_agent -Middleware to inject a User Agent object into requests. -For convenience's sake, it also exports the `user_agent` library. \ No newline at end of file +# Angel3 User Agent + +[![version](https://img.shields.io/badge/pub-v3.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_user_agent) +[![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) +[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) + +[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/user_agent/angel_user_agent/LICENSE) + +**Forked from `angel_user_agent` to support NNBD** + +Middleware to inject a User Agent object into requests. For convenience's sake, it also exports the `user_agent` library. diff --git a/packages/user_agent/angel_user_agent/example/example.dart b/packages/user_agent/angel_user_agent/example/example.dart index 62b20946..2a62ffa6 100644 --- a/packages/user_agent/angel_user_agent/example/example.dart +++ b/packages/user_agent/angel_user_agent/example/example.dart @@ -1,15 +1,15 @@ import 'dart:io'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_framework/http.dart'; -//import 'package:angel_user_agent/angel_user_agent.dart'; -//import 'package:user_agent/user_agent.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_framework/http.dart'; +import 'package:angel3_user_agent/angel3_user_agent.dart'; +import 'package:user_agent_analyzer/user_agent_analyzer.dart'; void main() async { var app = Angel(); var http = AngelHttp(app); // TODO: Commented out due to unknow class - /* + app.get( '/', waterfall([ @@ -22,7 +22,6 @@ void main() async { }, ]), ); - */ var server = await http.startServer(InternetAddress.anyIPv4, 3000); print('Listening at http://${server.address.address}:${server.port}'); diff --git a/packages/user_agent/angel_user_agent/lib/angel_user_agent.dart b/packages/user_agent/angel_user_agent/lib/angel3_user_agent.dart similarity index 86% rename from packages/user_agent/angel_user_agent/lib/angel_user_agent.dart rename to packages/user_agent/angel_user_agent/lib/angel3_user_agent.dart index ec872e32..cab51971 100644 --- a/packages/user_agent/angel_user_agent/lib/angel_user_agent.dart +++ b/packages/user_agent/angel_user_agent/lib/angel3_user_agent.dart @@ -1,5 +1,5 @@ -import 'package:angel_framework/angel_framework.dart'; -import 'package:user_agent/user_agent.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:user_agent_analyzer/user_agent_analyzer.dart'; /// Injects a [UserAgent] factory into requests. /// diff --git a/packages/user_agent/angel_user_agent/pubspec.yaml b/packages/user_agent/angel_user_agent/pubspec.yaml index 6e5e0daa..bf3e17a0 100644 --- a/packages/user_agent/angel_user_agent/pubspec.yaml +++ b/packages/user_agent/angel_user_agent/pubspec.yaml @@ -1,19 +1,10 @@ -name: angel_user_agent +name: angel3_user_agent version: 3.0.0 -description: Angel middleware to parse and inject a User Agent object into requests. -homepage: https://github.com/angel-dart/user_agent -publish_to: none +description: Angel3 middleware to parse and inject a User Agent object into requests. +homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/user_agent/angel_user_agent environment: sdk: '>=2.12.0 <3.0.0' dependencies: - angel_framework: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/framework - user_agent: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/user_agent/user_agent + angel3_framework: ^4.0.0 + user_agent_analyzer: ^3.0.0 pedantic: ^1.11.1 \ No newline at end of file diff --git a/packages/user_agent/user_agent/CHANGELOG.md b/packages/user_agent/user_agent/CHANGELOG.md index c8c041bb..4a1e9ff4 100644 --- a/packages/user_agent/user_agent/CHANGELOG.md +++ b/packages/user_agent/user_agent/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 3.0.1 + +* Updated to use non nullable results + ## 3.0.0 * Migrated to support Dart SDK 2.12.x NNBD diff --git a/packages/user_agent/user_agent/README.md b/packages/user_agent/user_agent/README.md index 2d6ba0e1..8dce655d 100644 --- a/packages/user_agent/user_agent/README.md +++ b/packages/user_agent/user_agent/README.md @@ -1,6 +1,6 @@ # User Agent Analyzer -[![version](https://img.shields.io/badge/pub-v3.0.0-brightgreen)](https://pub.dartlang.org/packages/user_agent_analyzer) +[![version](https://img.shields.io/badge/pub-v3.0.1-brightgreen)](https://pub.dartlang.org/packages/user_agent_analyzer) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) diff --git a/packages/user_agent/user_agent/lib/user_agent_analyzer.dart b/packages/user_agent/user_agent/lib/user_agent_analyzer.dart index 3c4c50cc..f86757f4 100644 --- a/packages/user_agent/user_agent/lib/user_agent_analyzer.dart +++ b/packages/user_agent/user_agent/lib/user_agent_analyzer.dart @@ -2,11 +2,11 @@ library user_agent_analyzer; /// Utils for device detection. class UserAgent { - bool? _isChrome; - bool? _isOpera; - bool? _isIE; - bool? _isFirefox; - bool? _isWebKit; + bool _isChrome = false; + bool _isOpera = false; + bool _isIE = false; + bool _isFirefox = false; + bool _isWebKit = false; String? _cachedCssPrefix; String? _cachedPropertyPrefix; @@ -172,32 +172,32 @@ class UserAgent { bool get isBlackberryTablet => isBlackberry && contains('tablet'); /// Determines if the current device is running Chrome. - bool? get isChrome { - _isChrome ??= value.contains('Chrome', 0); + bool get isChrome { + _isChrome = value.contains('Chrome', 0); return _isChrome; } /// Determines if the current device is running Opera. - bool? get isOpera { - _isOpera ??= value.contains('Opera', 0); + bool get isOpera { + _isOpera = value.contains('Opera', 0); return _isOpera; } /// Determines if the current device is running Internet Explorer. - bool? get isIE { - _isIE ??= !isOpera! && value.contains('Trident/', 0); + bool get isIE { + _isIE = !isOpera && value.contains('Trident/', 0); return _isIE; } /// Determines if the current device is running Firefox. - bool? get isFirefox { - _isFirefox ??= value.contains('Firefox', 0); + bool get isFirefox { + _isFirefox = value.contains('Firefox', 0); return _isFirefox; } /// Determines if the current device is running WebKit. - bool? get isWebKit { - _isWebKit ??= !isOpera! && value.contains('WebKit', 0); + bool get isWebKit { + _isWebKit = !isOpera && value.contains('WebKit', 0); return _isWebKit; } @@ -205,11 +205,11 @@ class UserAgent { String get cssPrefix { var prefix = _cachedCssPrefix; if (prefix != null) return prefix; - if (isFirefox!) { + if (isFirefox) { prefix = '-moz-'; - } else if (isIE!) { + } else if (isIE) { prefix = '-ms-'; - } else if (isOpera!) { + } else if (isOpera) { prefix = '-o-'; } else { prefix = '-webkit-'; @@ -221,11 +221,11 @@ class UserAgent { String get propertyPrefix { var prefix = _cachedPropertyPrefix; if (prefix != null) return prefix; - if (isFirefox!) { + if (isFirefox) { prefix = 'moz'; - } else if (isIE!) { + } else if (isIE) { prefix = 'ms'; - } else if (isOpera!) { + } else if (isOpera) { prefix = 'o'; } else { prefix = 'webkit'; diff --git a/packages/user_agent/user_agent/pubspec.yaml b/packages/user_agent/user_agent/pubspec.yaml index 6c682b2f..79e17f8d 100644 --- a/packages/user_agent/user_agent/pubspec.yaml +++ b/packages/user_agent/user_agent/pubspec.yaml @@ -1,5 +1,5 @@ name: user_agent_analyzer -version: 3.0.0 +version: 3.0.1 description: A library to identify the type of devices and web browsers based on User-Agent string. homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/user_agent/user_agent environment: