From 1dce9a75c31c6d0d42bcc45e3c87911170f027a6 Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Sun, 26 Mar 2023 09:47:42 +0800 Subject: [PATCH] Migrated to Dart 3 --- packages/merge_map/CHANGELOG.md | 4 +++ packages/merge_map/pubspec.yaml | 4 +-- packages/pretty_logging/CHANGELOG.md | 4 +++ packages/pretty_logging/README.md | 2 +- packages/pretty_logging/pubspec.yaml | 4 +-- packages/pub_sub/CHANGELOG.md | 4 +++ packages/pub_sub/README.md | 2 +- packages/pub_sub/pubspec.yaml | 4 +-- packages/range_header/CHANGELOG.md | 4 +++ packages/range_header/README.md | 2 +- packages/range_header/example/main.dart | 4 ++- packages/range_header/lib/src/converter.dart | 4 ++- packages/range_header/lib/src/exception.dart | 6 ++--- packages/range_header/lib/src/parser.dart | 28 ++++++++++---------- packages/range_header/pubspec.yaml | 4 +-- packages/symbol_table/CHANGELOG.md | 4 +++ packages/symbol_table/README.md | 3 +-- packages/symbol_table/pubspec.yaml | 4 +-- packages/user_agent/CHANGELOG.md | 4 +++ packages/user_agent/pubspec.yaml | 4 +-- 20 files changed, 63 insertions(+), 36 deletions(-) diff --git a/packages/merge_map/CHANGELOG.md b/packages/merge_map/CHANGELOG.md index 6f6f95a..d319e62 100644 --- a/packages/merge_map/CHANGELOG.md +++ b/packages/merge_map/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 5.0.0-beta.1 + +* Require Dart >= 3.0 + ## 4.0.0 * Require Dart >= 2.17 diff --git a/packages/merge_map/pubspec.yaml b/packages/merge_map/pubspec.yaml index d19c995..4f1a2d4 100644 --- a/packages/merge_map/pubspec.yaml +++ b/packages/merge_map/pubspec.yaml @@ -1,9 +1,9 @@ name: belatuk_merge_map -version: 4.0.0 +version: 5.0.0-beta.1 description: Combine multiple Maps into one. Equivalent to Object.assign in JS. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/merge_map environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=3.0.0-290.3.beta <4.0.0' dev_dependencies: test: ^1.17.4 lints: ^2.0.0 diff --git a/packages/pretty_logging/CHANGELOG.md b/packages/pretty_logging/CHANGELOG.md index 22edb40..b8a60b7 100644 --- a/packages/pretty_logging/CHANGELOG.md +++ b/packages/pretty_logging/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.0.0-beta.1 + +* Require Dart >= 3.0 + ## 5.0.0 * Require Dart >= 2.17 diff --git a/packages/pretty_logging/README.md b/packages/pretty_logging/README.md index 3877a89..9325e40 100644 --- a/packages/pretty_logging/README.md +++ b/packages/pretty_logging/README.md @@ -15,7 +15,7 @@ In your `pubspec.yaml`: ```yaml dependencies: - belatuk_pretty_logging: ^5.0.0 + belatuk_pretty_logging: ^6.0.0 ``` ## Usage diff --git a/packages/pretty_logging/pubspec.yaml b/packages/pretty_logging/pubspec.yaml index 65576c1..d261296 100644 --- a/packages/pretty_logging/pubspec.yaml +++ b/packages/pretty_logging/pubspec.yaml @@ -1,9 +1,9 @@ name: belatuk_pretty_logging -version: 5.0.0 +version: 6.0.0-beta.1 description: Standalone helper for colorful logging output, using pkg:io AnsiCode. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/pretty_logging environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=3.0.0-290.3.beta <4.0.0' dependencies: io: ^1.0.0 logging: ^1.0.1 diff --git a/packages/pub_sub/CHANGELOG.md b/packages/pub_sub/CHANGELOG.md index 9ba9c63..e88a193 100644 --- a/packages/pub_sub/CHANGELOG.md +++ b/packages/pub_sub/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.0.0-beta.1 + +* Require Dart >= 3.0 + ## 5.0.0 * Require Dart >= 2.17 diff --git a/packages/pub_sub/README.md b/packages/pub_sub/README.md index e205bff..0465802 100644 --- a/packages/pub_sub/README.md +++ b/packages/pub_sub/README.md @@ -14,7 +14,7 @@ Add `belatuk_pub_sub` as a dependency in your `pubspec.yaml` file: ```yaml dependencies: - belatuk_pub_sub: ^5.0.0 + belatuk_pub_sub: ^6.0.0 ``` Then, be sure to run `pub get` in your terminal. diff --git a/packages/pub_sub/pubspec.yaml b/packages/pub_sub/pubspec.yaml index 0df14dd..a5ce549 100644 --- a/packages/pub_sub/pubspec.yaml +++ b/packages/pub_sub/pubspec.yaml @@ -1,9 +1,9 @@ name: belatuk_pub_sub -version: 5.0.0 +version: 6.0.0-beta.1 description: Keep application instances in sync with a simple pub/sub API. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/pub_sub environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=3.0.0-290.3.beta <4.0.0' dependencies: json_rpc_2: ^3.0.0 stream_channel: ^2.1.0 diff --git a/packages/range_header/CHANGELOG.md b/packages/range_header/CHANGELOG.md index aa3552a..9cc90b3 100644 --- a/packages/range_header/CHANGELOG.md +++ b/packages/range_header/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.0.0-beta.1 + +* Require Dart >= 3.0 + ## 5.0.0 * Require Dart >= 2.17 diff --git a/packages/range_header/README.md b/packages/range_header/README.md index 0c5b902..742ba28 100644 --- a/packages/range_header/README.md +++ b/packages/range_header/README.md @@ -14,7 +14,7 @@ In your `pubspec.yaml`: ```yaml dependencies: - belatuk_range_header: ^5.0.0 + belatuk_range_header: ^6.0.0 ``` ## Usage diff --git a/packages/range_header/example/main.dart b/packages/range_header/example/main.dart index a815762..46274ea 100644 --- a/packages/range_header/example/main.dart +++ b/packages/range_header/example/main.dart @@ -15,7 +15,9 @@ void handleRequest(HttpRequest request) async { // Get info header.items; header.rangeUnit; - header.items.forEach((item) => item.toContentRange(400)); + for (var item in header.items) { + item.toContentRange(400); + } // Serve the file var transformer = diff --git a/packages/range_header/lib/src/converter.dart b/packages/range_header/lib/src/converter.dart index d5c5645..d0ef65a 100644 --- a/packages/range_header/lib/src/converter.dart +++ b/packages/range_header/lib/src/converter.dart @@ -1,7 +1,9 @@ import 'dart:async'; import 'dart:collection'; import 'dart:convert'; -import 'dart:io' show BytesBuilder; +//import 'dart:io' hide BytesBuilder; +import 'dart:typed_data'; + import 'dart:math'; import 'package:async/async.dart'; import 'package:charcode/ascii.dart'; diff --git a/packages/range_header/lib/src/exception.dart b/packages/range_header/lib/src/exception.dart index c6b3a7b..f5c6cf1 100644 --- a/packages/range_header/lib/src/exception.dart +++ b/packages/range_header/lib/src/exception.dart @@ -1,8 +1,8 @@ class RangeHeaderParseException extends FormatException { - @override - final String message; + //@override + //final String message; - RangeHeaderParseException(this.message); + RangeHeaderParseException(super.message); @override String toString() => 'Range header parse exception: $message'; diff --git a/packages/range_header/lib/src/parser.dart b/packages/range_header/lib/src/parser.dart index ecc365c..2ca5ffa 100644 --- a/packages/range_header/lib/src/parser.dart +++ b/packages/range_header/lib/src/parser.dart @@ -9,7 +9,7 @@ import 'range_header_item.dart'; final RegExp _rgxInt = RegExp(r'[0-9]+'); final RegExp _rgxWs = RegExp(r'[ \n\r\t]'); -enum TokenType { RANGE_UNIT, COMMA, INT, DASH, EQUALS } +enum TokenType { rangeUnit, comma, int, dash, equals } class Token { final TokenType type; @@ -27,19 +27,19 @@ List scan(String text, List allowedRangeUnits) { scanner.scan(_rgxWs); if (scanner.scanChar($comma)) { - tokens.add(Token(TokenType.COMMA, scanner.lastSpan)); + tokens.add(Token(TokenType.comma, scanner.lastSpan)); } else if (scanner.scanChar($dash)) { - tokens.add(Token(TokenType.DASH, scanner.lastSpan)); + tokens.add(Token(TokenType.dash, scanner.lastSpan)); } else if (scanner.scan(_rgxInt)) { - tokens.add(Token(TokenType.INT, scanner.lastSpan)); + tokens.add(Token(TokenType.int, scanner.lastSpan)); } else if (scanner.scanChar($equal)) { - tokens.add(Token(TokenType.EQUALS, scanner.lastSpan)); + tokens.add(Token(TokenType.equals, scanner.lastSpan)); } else { var matched = false; for (var unit in allowedRangeUnits) { if (scanner.scan(unit)) { - tokens.add(Token(TokenType.RANGE_UNIT, scanner.lastSpan)); + tokens.add(Token(TokenType.rangeUnit, scanner.lastSpan)); matched = true; break; } @@ -98,9 +98,9 @@ class Parser { } RangeHeader? parseRangeHeader() { - if (next(TokenType.RANGE_UNIT)) { + if (next(TokenType.rangeUnit)) { var unit = current!.span!.text; - next(TokenType.EQUALS); // Consume =, if any. + next(TokenType.equals); // Consume =, if any. var items = []; var item = parseHeaderItem(); @@ -108,7 +108,7 @@ class Parser { while (item != null) { items.add(item); // Parse comma - if (next(TokenType.COMMA)) { + if (next(TokenType.comma)) { item = parseHeaderItem(); } else { item = null; @@ -126,11 +126,11 @@ class Parser { } RangeHeaderItem? parseHeaderItem() { - if (next(TokenType.INT)) { + if (next(TokenType.int)) { // i.e 500-544, or 600- var start = int.parse(current!.span!.text); - if (next(TokenType.DASH)) { - if (next(TokenType.INT)) { + if (next(TokenType.dash)) { + if (next(TokenType.int)) { return RangeHeaderItem(start, int.parse(current!.span!.text)); } else { return RangeHeaderItem(start); @@ -138,9 +138,9 @@ class Parser { } else { throw _expected('"-"'); } - } else if (next(TokenType.DASH)) { + } else if (next(TokenType.dash)) { // i.e. -599 - if (next(TokenType.INT)) { + if (next(TokenType.int)) { return RangeHeaderItem(-1, int.parse(current!.span!.text)); } else { throw _expected('integer'); diff --git a/packages/range_header/pubspec.yaml b/packages/range_header/pubspec.yaml index e421cf7..02ad98a 100644 --- a/packages/range_header/pubspec.yaml +++ b/packages/range_header/pubspec.yaml @@ -1,9 +1,9 @@ name: belatuk_range_header -version: 5.0.0 +version: 6.0.0-beta.1 description: Range header parser for Dart. Beyond parsing, a stream transformer is included. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/range_header environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=3.0.0-290.3.beta <4.0.0' dependencies: async: ^2.6.0 charcode: ^1.2.0 diff --git a/packages/symbol_table/CHANGELOG.md b/packages/symbol_table/CHANGELOG.md index 1a294c4..08acaad 100644 --- a/packages/symbol_table/CHANGELOG.md +++ b/packages/symbol_table/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 5.0.0-beta.1 + +* Require Dart >= 3.0 + ## 4.0.0 * Require Dart >= 2.17 diff --git a/packages/symbol_table/README.md b/packages/symbol_table/README.md index cfb8688..abb7fac 100644 --- a/packages/symbol_table/README.md +++ b/packages/symbol_table/README.md @@ -12,8 +12,7 @@ and utilize basic memoization to speed up repeated lookups. ## Variables -To represent a symbol, use `Variable`. I opted for the name -`Variable` to avoid conflict with the Dart primitive `Symbol`. +To represent a symbol, use `Variable`. I opted for the name `Variable` to avoid conflict with the Dart primitive `Symbol`. ```dart var foo = Variable('foo'); diff --git a/packages/symbol_table/pubspec.yaml b/packages/symbol_table/pubspec.yaml index 35413aa..88ae93d 100644 --- a/packages/symbol_table/pubspec.yaml +++ b/packages/symbol_table/pubspec.yaml @@ -1,9 +1,9 @@ name: belatuk_symbol_table -version: 4.0.0 +version: 5.0.0-beta.1 description: A generic symbol table implementation in Dart, with support for scopes and constants. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/symbol_table environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=3.0.0-290.3.beta <4.0.0' dependencies: collection: ^1.15.0 dev_dependencies: diff --git a/packages/user_agent/CHANGELOG.md b/packages/user_agent/CHANGELOG.md index e5f4881..d2b2e25 100644 --- a/packages/user_agent/CHANGELOG.md +++ b/packages/user_agent/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 5.0.0-beta.1 + +* Require Dart >= 3.0 + ## 4.0.0 * Require Dart >= 2.17 diff --git a/packages/user_agent/pubspec.yaml b/packages/user_agent/pubspec.yaml index 7b0e078..5c4138a 100644 --- a/packages/user_agent/pubspec.yaml +++ b/packages/user_agent/pubspec.yaml @@ -1,9 +1,9 @@ name: user_agent_analyzer -version: 4.0.0 +version: 5.0.0-beta.1 description: A library to identify the type of devices and web browsers based on User-Agent string. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/user_agent environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=3.0.0-290.3.beta <4.0.0' dev_dependencies: test: ^1.17.8 lints: ^2.0.0