Updated user_agent

This commit is contained in:
thomashii 2021-06-21 13:43:02 +08:00
parent 685c7fc6a5
commit ec2190162d
9 changed files with 57 additions and 51 deletions

View file

@ -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
## 2.0.0
* Angel 2 + Dart 2 updates

View file

@ -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.
# 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.

View file

@ -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}');

View file

@ -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.
///

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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';

View file

@ -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: