From f4a7b46cbc29cf9b3319d2beddf732ecde64fe8d Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Sat, 23 Sep 2023 11:02:18 +0800 Subject: [PATCH 1/5] Upgraded library --- packages/pub_sub/AUTHORS.md | 2 +- packages/pub_sub/CHANGELOG.md | 4 ++++ packages/pub_sub/pubspec.yaml | 4 ++-- packages/pub_sub/test/json_rpc_2_test.dart | 2 +- packages/range_header/CHANGELOG.md | 4 ++++ packages/range_header/pubspec.yaml | 4 ++-- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/packages/pub_sub/AUTHORS.md b/packages/pub_sub/AUTHORS.md index ac95ab5..6ae218e 100644 --- a/packages/pub_sub/AUTHORS.md +++ b/packages/pub_sub/AUTHORS.md @@ -3,7 +3,7 @@ Primary Authors * __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - Thomas is the current maintainer of the code base. He has refactored and migrated the + Thomas is the current maintainer of the code base. He has refactored and migrated the code base to support NNBD. * __[Tobe O](thosakwe@gmail.com)__ diff --git a/packages/pub_sub/CHANGELOG.md b/packages/pub_sub/CHANGELOG.md index 6eb4bb7..f0e042f 100644 --- a/packages/pub_sub/CHANGELOG.md +++ b/packages/pub_sub/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.1.0 + +* Upgraded `uuid` to 4.0.0 + ## 6.0.0 * Require Dart >= 3.0 diff --git a/packages/pub_sub/pubspec.yaml b/packages/pub_sub/pubspec.yaml index 7eb2c65..63f7067 100644 --- a/packages/pub_sub/pubspec.yaml +++ b/packages/pub_sub/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_pub_sub -version: 6.0.0 +version: 6.1.0 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: @@ -7,7 +7,7 @@ environment: dependencies: json_rpc_2: ^3.0.0 stream_channel: ^2.1.0 - uuid: ^3.0.4 + uuid: ^4.0.0 collection: ^1.17.0 dev_dependencies: lints: ^2.0.0 diff --git a/packages/pub_sub/test/json_rpc_2_test.dart b/packages/pub_sub/test/json_rpc_2_test.dart index 2f6932b..b5e9293 100644 --- a/packages/pub_sub/test/json_rpc_2_test.dart +++ b/packages/pub_sub/test/json_rpc_2_test.dart @@ -157,7 +157,7 @@ class _SocketStreamChannel extends StreamChannelMixin> { Stream> get stream => socket; } -class _SocketSink extends StreamSink> { +class _SocketSink implements StreamSink> { final Socket socket; _SocketSink(this.socket); diff --git a/packages/range_header/CHANGELOG.md b/packages/range_header/CHANGELOG.md index 9149bc2..c546061 100644 --- a/packages/range_header/CHANGELOG.md +++ b/packages/range_header/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.1.0 + +* Updated `file` to 7.0.0 + ## 6.0.0 * Require Dart >= 3.0 diff --git a/packages/range_header/pubspec.yaml b/packages/range_header/pubspec.yaml index 54b5d08..6de9eab 100644 --- a/packages/range_header/pubspec.yaml +++ b/packages/range_header/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_range_header -version: 6.0.0 +version: 6.1.0 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: @@ -11,7 +11,7 @@ dependencies: source_span: ^1.10.0 string_scanner: ^1.2.0 dev_dependencies: - file: ^6.1.0 + file: ^7.0.0 http_parser: ^4.0.0 logging: ^1.0.1 test: ^1.24.0 From 0aee2f64da6b2b766a12a58c225a36b4944e651d Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Thu, 16 Nov 2023 23:44:09 +0800 Subject: [PATCH 2/5] Updated lints --- packages/body_parser/README.md | 6 ++-- packages/code_buffer/README.md | 2 +- packages/code_buffer/pubspec.yaml | 2 +- packages/combinator/pubspec.yaml | 2 +- packages/html_builder/README.md | 2 +- packages/html_builder/pubspec.yaml | 2 +- packages/json_serializer/README.md | 2 +- packages/json_serializer/pubspec.yaml | 2 +- packages/merge_map/README.md | 3 +- packages/merge_map/pubspec.yaml | 2 +- packages/pretty_logging/README.md | 2 +- packages/pretty_logging/pubspec.yaml | 2 +- packages/pub_sub/README.md | 41 +++++++-------------------- packages/pub_sub/pubspec.yaml | 2 +- packages/range_header/README.md | 2 +- packages/range_header/pubspec.yaml | 2 +- packages/symbol_table/README.md | 3 +- packages/symbol_table/pubspec.yaml | 2 +- packages/user_agent/pubspec.yaml | 2 +- 19 files changed, 30 insertions(+), 53 deletions(-) diff --git a/packages/body_parser/README.md b/packages/body_parser/README.md index 05e893f..a5c7558 100644 --- a/packages/body_parser/README.md +++ b/packages/body_parser/README.md @@ -21,16 +21,14 @@ This is the request body parser powering the [Angel3 framework](https://pub.dev/ ### About -I needed something like Express.js's `body-parser` module, so I made it here. It fully supports JSON requests. x-www-form-urlencoded fully supported, as well as query strings. You can also include arrays in your query, in the same way you would for a PHP application. Full file upload support will also be present by the production 1.0.0 release. - -A benefit of this is that primitive types are automatically deserialized correctly. As in, if you have a `hello=1.5` request, then `body['hello']` will equal `1.5` and not `'1.5'`. A very semantic difference, yes, but it relieves stress in my head. +This package is similar to Express.js's `body-parser` module. It fully supports JSON, x-www-form-urlencoded as well as query strings requests. You can also include arrays in your query, in the same way you would for a PHP application. A benefit of this is that primitive types are automatically deserialized correctly. As in, if you have a `hello=1.5` request, then `body['hello']` will equal `1.5` and not `'1.5'`. ### Installation To install Body Parser for your Dart project, simply add body_parser to your pub dependencies. dependencies: - belatuk_body_parser: ^5.1.0 + belatuk_body_parser: ^8.0.0 ### Usage diff --git a/packages/code_buffer/README.md b/packages/code_buffer/README.md index 13747b7..0710eb8 100644 --- a/packages/code_buffer/README.md +++ b/packages/code_buffer/README.md @@ -14,7 +14,7 @@ In your `pubspec.yaml`: ```yaml dependencies: - belatuk_code_buffer: ^5.0.0 + belatuk_code_buffer: ^8.0.0 ``` ## Usage diff --git a/packages/code_buffer/pubspec.yaml b/packages/code_buffer/pubspec.yaml index d6a5c3b..7e6d388 100644 --- a/packages/code_buffer/pubspec.yaml +++ b/packages/code_buffer/pubspec.yaml @@ -9,4 +9,4 @@ dependencies: source_span: ^1.8.1 dev_dependencies: test: ^1.24.0 - lints: ^2.0.0 + lints: ^3.0.0 diff --git a/packages/combinator/pubspec.yaml b/packages/combinator/pubspec.yaml index e1d3928..72b39a9 100644 --- a/packages/combinator/pubspec.yaml +++ b/packages/combinator/pubspec.yaml @@ -12,4 +12,4 @@ dependencies: tuple: ^2.0.0 dev_dependencies: test: ^1.24.0 - lints: ^2.0.0 + lints: ^3.0.0 \ No newline at end of file diff --git a/packages/html_builder/README.md b/packages/html_builder/README.md index 7df12a4..2212166 100644 --- a/packages/html_builder/README.md +++ b/packages/html_builder/README.md @@ -18,7 +18,7 @@ In your `pubspec.yaml`: ```yaml dependencies: - belatuk_html_builder: ^5.0.0 + belatuk_html_builder: ^8.0.0 ``` ## Usage diff --git a/packages/html_builder/pubspec.yaml b/packages/html_builder/pubspec.yaml index fe9fc63..1c0ae04 100644 --- a/packages/html_builder/pubspec.yaml +++ b/packages/html_builder/pubspec.yaml @@ -9,4 +9,4 @@ dependencies: dev_dependencies: html: ^0.15.0 test: ^1.24.0 - lints: ^2.0.0 + lints: ^3.0.0 diff --git a/packages/json_serializer/README.md b/packages/json_serializer/README.md index def3b27..03a6722 100644 --- a/packages/json_serializer/README.md +++ b/packages/json_serializer/README.md @@ -12,7 +12,7 @@ The ***new and improved*** definitive solution for JSON in Dart. It supports syn ## Installation dependencies: - belatuk_json_serializer: ^7.0.0 + belatuk_json_serializer: ^8.0.0 ## Usage diff --git a/packages/json_serializer/pubspec.yaml b/packages/json_serializer/pubspec.yaml index 23ee766..75cccd3 100644 --- a/packages/json_serializer/pubspec.yaml +++ b/packages/json_serializer/pubspec.yaml @@ -9,4 +9,4 @@ dependencies: dev_dependencies: stack_trace: ^1.10.0 test: ^1.24.0 - lints: ^2.0.0 \ No newline at end of file + lints: ^3.0.0 \ No newline at end of file diff --git a/packages/merge_map/README.md b/packages/merge_map/README.md index 2f56a18..b18cd1d 100644 --- a/packages/merge_map/README.md +++ b/packages/merge_map/README.md @@ -7,8 +7,7 @@ **Replacement of `package:merge_map` with breaking changes to support NNBD.** Combine multiple Maps into one. Equivalent to -[Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) -in JS. +[Object.assign](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) in JS. ## Example diff --git a/packages/merge_map/pubspec.yaml b/packages/merge_map/pubspec.yaml index 31c3f50..de9c43d 100644 --- a/packages/merge_map/pubspec.yaml +++ b/packages/merge_map/pubspec.yaml @@ -6,4 +6,4 @@ environment: sdk: '>=3.0.0 <4.0.0' dev_dependencies: test: ^1.24.0 - lints: ^2.0.0 + lints: ^3.0.0 diff --git a/packages/pretty_logging/README.md b/packages/pretty_logging/README.md index 9325e40..db09cf0 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: ^6.0.0 + belatuk_pretty_logging: ^8.0.0 ``` ## Usage diff --git a/packages/pretty_logging/pubspec.yaml b/packages/pretty_logging/pubspec.yaml index 549823a..e546dda 100644 --- a/packages/pretty_logging/pubspec.yaml +++ b/packages/pretty_logging/pubspec.yaml @@ -9,4 +9,4 @@ dependencies: logging: ^1.0.1 dev_dependencies: test: ^1.24.0 - lints: ^2.0.0 + lints: ^3.0.0 diff --git a/packages/pub_sub/README.md b/packages/pub_sub/README.md index 5501031..bb4867b 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: ^6.0.0 + belatuk_pub_sub: ^8.0.0 ``` Then, be sure to run `dart pub get` in your terminal. @@ -22,17 +22,13 @@ Then, be sure to run `dart pub get` in your terminal. ## Usage `belatuk_pub_sub` is your typical pub/sub API. However, `belatuk_pub_sub` enforces authentication of every -request. It is very possible that `belatuk_pub_sub` will run on both servers and in the browser, -or on a platform belatuk_pub_sublike Flutter. Thus, there are provisions available to limit -access. +request. It is very possible that `belatuk_pub_sub` will run on both server and in the browser, +or on a platform like Flutter. **Be careful to not leak any `belatuk_pub_sub` client ID's if operating over a network.** -If you do, you risk malicious users injecting events into your application, which -could ultimately spell *disaster*. +If you do, you run the risk of malicious users injecting events into your application. -A `belatuk_pub_sub` server can operate across multiple *adapters*, which take care of interfacing data over different -media. For example, a single server can handle pub/sub between multiple Isolates and TCP Sockets, as well as -WebSockets, simultaneously. +A `belatuk_pub_sub` server can operate across multiple *adapters*, which take care of interfacing data over different media. For example, a single server can handle pub/sub between multiple Isolates and TCP Sockets, as well as WebSockets, simultaneously. ```dart import 'package:belatuk_pub_sub/belatuk_pub_sub.dart' as pub_sub; @@ -52,13 +48,7 @@ main() async { ### Trusted Clients -You can use `package:belatuk_pub_sub` without explicitly registering -clients, *if and only if* those clients come from trusted sources. - -Clients via `Isolate` are always trusted. - -Clients via `package:json_rpc_2` must be explicitly marked -as trusted (i.e. using an IP whitelist mechanism): +You can use `package:belatuk_pub_sub` without explicitly registering clients, *if and only if* those clients come from trusted sources. Clients via `Isolate` are always trusted. Clients via `package:json_rpc_2` must be explicitly marked as trusted (i.e. using an IP whitelist mechanism): ```dart JsonRpc2Adapter(..., isTrusted: false); @@ -71,8 +61,7 @@ pub_sub.IsolateClient(null); The ID's of all *untrusted* clients who will connect to the server must be known at start-up time. You may not register new clients after the server has started. This is mostly a security consideration; -if it is impossible to register new clients, then malicious users cannot grant themselves additional -privileges within the system. +mainly to make it impossible to register new clients, thus preventing malicious users from granting themselves additional privileges within the system. ```dart import 'package:belatuk_pub_sub/belatuk_pub_sub.dart' as pub_sub; @@ -96,10 +85,7 @@ void main() async { ### Isolates -If you are just running multiple instances of a server, -use `package:belatuk_pub_sub/isolate.dart`. - -You'll need one isolate to be the master. Typically this is the first isolate you create. +If you are just running multiple instances of a server, use `package:belatuk_pub_sub/isolate.dart`. You'll need one isolate to be the master. Typically this is the first isolate you create. ```dart import 'dart:io'; @@ -157,9 +143,7 @@ Check out `test/json_rpc_2_test.dart` for an example of serving `belatuk_pub_sub ## Protocol -`belatuk_pub_sub` is built upon a simple RPC, and this package includes -an implementation that runs via `SendPort`s and `ReceivePort`s, as -well as one that runs on any `StreamChannel`. +`belatuk_pub_sub` is built upon a simple RPC, and this package includes an implementation that runs via `SendPort`s and `ReceivePort`s, as well as one that runs on any `StreamChannel`. Data sent over the wire looks like the following: @@ -219,14 +203,11 @@ In the case of Isolate clients/servers, events will be simply sent as Lists: ['', value] ``` -Clients can send the following (3) methods: +Clients can send with the following 3 methods: * `subscribe` (`event_name`:string): Subscribe to an event. * `unsubscribe` (`subscription_id`:string): Unsubscribe from an event you previously subscribed to. * `publish` (`event_name`:string, `value`:any): Publish an event to all other clients who are subscribed. -The client and server in `package:belatuk_pub_sub/isolate.dart` must make extra -provisions to keep track of client ID's. Since `SendPort`s and `ReceivePort`s -do not have any sort of guaranteed-unique ID's, new clients must send their -`SendPort` to the server before sending any requests. The server then responds +The client and server in `package:belatuk_pub_sub/isolate.dart` must make extra provisions to keep track of client ID's. Since `SendPort`s and `ReceivePort`s do not have any sort of guaranteed-unique ID's, new clients must send their `SendPort` to the server before sending any requests. The server then responds with an `id` that must be used to identify a `SendPort` to send a response to. diff --git a/packages/pub_sub/pubspec.yaml b/packages/pub_sub/pubspec.yaml index 63f7067..73bd96b 100644 --- a/packages/pub_sub/pubspec.yaml +++ b/packages/pub_sub/pubspec.yaml @@ -10,5 +10,5 @@ dependencies: uuid: ^4.0.0 collection: ^1.17.0 dev_dependencies: - lints: ^2.0.0 + lints: ^3.0.0 test: ^1.24.0 diff --git a/packages/range_header/README.md b/packages/range_header/README.md index 742ba28..eb02430 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: ^6.0.0 + belatuk_range_header: ^8.0.0 ``` ## Usage diff --git a/packages/range_header/pubspec.yaml b/packages/range_header/pubspec.yaml index 6de9eab..e6c6e1d 100644 --- a/packages/range_header/pubspec.yaml +++ b/packages/range_header/pubspec.yaml @@ -15,4 +15,4 @@ dev_dependencies: http_parser: ^4.0.0 logging: ^1.0.1 test: ^1.24.0 - lints: ^2.0.0 + lints: ^3.0.0 diff --git a/packages/symbol_table/README.md b/packages/symbol_table/README.md index abb7fac..c1457e8 100644 --- a/packages/symbol_table/README.md +++ b/packages/symbol_table/README.md @@ -30,8 +30,7 @@ foo.value = 'baz'; // Also throws a StateError - Once a variable is locked, it c ## Visibility -Variables are *public* by default, but can also be marked as *private* or *protected*. This can be helpful if you are trying -to determine which symbols should be exported from a library or class. +Variables are *public* by default, but can also be marked as *private* or *protected*. This can be helpful if you are trying to determine which symbols should be exported from a library or class. ```dart myVariable.visibility = Visibility.protected; diff --git a/packages/symbol_table/pubspec.yaml b/packages/symbol_table/pubspec.yaml index 71b32b0..42deea2 100644 --- a/packages/symbol_table/pubspec.yaml +++ b/packages/symbol_table/pubspec.yaml @@ -8,4 +8,4 @@ dependencies: collection: ^1.17.0 dev_dependencies: test: ^1.24.0 - lints: ^2.0.0 + lints: ^3.0.0 diff --git a/packages/user_agent/pubspec.yaml b/packages/user_agent/pubspec.yaml index a5e35a7..d7ff4af 100644 --- a/packages/user_agent/pubspec.yaml +++ b/packages/user_agent/pubspec.yaml @@ -6,4 +6,4 @@ environment: sdk: '>=3.0.0 <4.0.0' dev_dependencies: test: ^1.24.0 - lints: ^2.0.0 + lints: ^3.0.0 From b6c1ba243ae0234557aee3c32f8ed8bbf67ac20b Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Thu, 16 Nov 2023 23:52:43 +0800 Subject: [PATCH 3/5] Updated lints --- packages/body_parser/pubspec.yaml | 2 +- packages/pub_sub/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/body_parser/pubspec.yaml b/packages/body_parser/pubspec.yaml index 253b78f..778fa2e 100644 --- a/packages/body_parser/pubspec.yaml +++ b/packages/body_parser/pubspec.yaml @@ -11,4 +11,4 @@ dependencies: dev_dependencies: http: ^1.0.0 test: ^1.24.0 - lints: ^2.1.0 \ No newline at end of file + lints: ^3.0.0 \ No newline at end of file diff --git a/packages/pub_sub/pubspec.yaml b/packages/pub_sub/pubspec.yaml index 73bd96b..ca587e4 100644 --- a/packages/pub_sub/pubspec.yaml +++ b/packages/pub_sub/pubspec.yaml @@ -10,5 +10,5 @@ dependencies: uuid: ^4.0.0 collection: ^1.17.0 dev_dependencies: - lints: ^3.0.0 test: ^1.24.0 + lints: ^3.0.0 From dfccf23629c223c2f3d4005933343bc53d43a850 Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Tue, 12 Dec 2023 09:30:25 +0800 Subject: [PATCH 4/5] Updated pub_sub --- .gitignore | 3 +- packages/pub_sub/CHANGELOG.md | 6 + packages/pub_sub/README.md | 5 +- packages/pub_sub/example/main.dart | 14 +- packages/pub_sub/lib/src/isolate/client.dart | 100 +++++----- packages/pub_sub/lib/src/isolate/server.dart | 143 +++++--------- packages/pub_sub/lib/src/isolate/shared.dart | 181 ++++++++++++++++++ .../lib/src/protocol/server/publish.dart | 2 +- packages/pub_sub/pubspec.yaml | 2 +- 9 files changed, 298 insertions(+), 158 deletions(-) create mode 100644 packages/pub_sub/lib/src/isolate/shared.dart diff --git a/.gitignore b/.gitignore index a67f375..2e43b8d 100644 --- a/.gitignore +++ b/.gitignore @@ -26,4 +26,5 @@ doc/api/ !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json -.metals/ \ No newline at end of file +.metals/ +.DS_Store \ No newline at end of file diff --git a/packages/pub_sub/CHANGELOG.md b/packages/pub_sub/CHANGELOG.md index f0e042f..8861780 100644 --- a/packages/pub_sub/CHANGELOG.md +++ b/packages/pub_sub/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 6.2.0 + +* Require Dart >= 3.2 +* Upgraded `lints` to 3.0.0 +* Refactored encode/decode message handling into `MessageHandler` + ## 6.1.0 * Upgraded `uuid` to 4.0.0 diff --git a/packages/pub_sub/README.md b/packages/pub_sub/README.md index bb4867b..1af71f7 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: ^8.0.0 + belatuk_pub_sub: ^8.2.0 ``` Then, be sure to run `dart pub get` in your terminal. @@ -60,8 +60,7 @@ pub_sub.IsolateClient(null); ### Access Control The ID's of all *untrusted* clients who will connect to the server must be known at start-up time. -You may not register new clients after the server has started. This is mostly a security consideration; -mainly to make it impossible to register new clients, thus preventing malicious users from granting themselves additional privileges within the system. +You may not register new clients after the server has started. This is mostly a security consideration, to make it impossible to register new clients, thus preventing malicious users from granting themselves additional privileges within the system. ```dart import 'package:belatuk_pub_sub/belatuk_pub_sub.dart' as pub_sub; diff --git a/packages/pub_sub/example/main.dart b/packages/pub_sub/example/main.dart index 42c7727..de482e5 100644 --- a/packages/pub_sub/example/main.dart +++ b/packages/pub_sub/example/main.dart @@ -1,19 +1,20 @@ import 'dart:io'; import 'dart:isolate'; -import 'package:belatuk_pub_sub/isolate.dart' as pub_sub; -import 'package:belatuk_pub_sub/belatuk_pub_sub.dart' as pub_sub; +import 'package:belatuk_pub_sub/isolate.dart'; +import 'package:belatuk_pub_sub/belatuk_pub_sub.dart'; void main() async { // Easily bring up a server. - var adapter = pub_sub.IsolateAdapter(); - var server = pub_sub.Server([adapter]); + var adapter = IsolateAdapter(); + var server = Server([adapter]); // You then need to create a client that will connect to the adapter. // Every untrusted client in your application should be pre-registered. // // In the case of Isolates, however, those are always implicitly trusted. + print("Register Client"); for (var i = 0; i < Platform.numberOfProcessors - 1; i++) { - server.registerClient(pub_sub.ClientInfo('client$i')); + server.registerClient(ClientInfo('client$i')); } // Start the server. @@ -22,6 +23,7 @@ void main() async { // Next, let's start isolates that interact with the server. // // Fortunately, we can send SendPorts over Isolates, so this is no hassle. + print("Create Isolate"); for (var i = 0; i < Platform.numberOfProcessors - 1; i++) { await Isolate.spawn(isolateMain, [i, adapter.receivePort.sendPort]); } @@ -32,7 +34,7 @@ void main() async { void isolateMain(List args) { // Isolates are always trusted, so technically we don't need to pass a client iD. - var client = pub_sub.IsolateClient('client${args[0]}', args[1] as SendPort); + var client = IsolateClient('client${args[0]}', args[1] as SendPort); // The client will connect automatically. In the meantime, we can start subscribing to events. client.subscribe('user::logged_in').then((sub) { diff --git a/packages/pub_sub/lib/src/isolate/client.dart b/packages/pub_sub/lib/src/isolate/client.dart index 4fab48e..cd1ce29 100644 --- a/packages/pub_sub/lib/src/isolate/client.dart +++ b/packages/pub_sub/lib/src/isolate/client.dart @@ -2,7 +2,9 @@ import 'dart:async'; import 'dart:collection'; import 'dart:isolate'; import 'package:uuid/uuid.dart'; -import '../../belatuk_pub_sub.dart'; + +import '../protocol/protocol.dart'; +import 'shared.dart'; /// A [Client] implementation that communicates via [SendPort]s and [ReceivePort]s. class IsolateClient extends Client { @@ -29,33 +31,39 @@ class IsolateClient extends Client { IsolateClient(String? clientId, this.serverSendPort) { _clientId = clientId; receivePort.listen((data) { - if (data is Map && data['request_id'] is String) { - var requestId = data['request_id'] as String?; - var c = _requests.remove(requestId); + if (data is Map) { + var (status, id, requestId, result, errorMessage) = + MessageHandler().decodeResponseMessage(data); - if (c != null && !c.isCompleted) { - if (data['status'] is! bool) { - c.completeError( - FormatException('The server sent an invalid response.')); - } else if (!(data['status'] as bool)) { - c.completeError(PubSubException(data['error_message']?.toString() ?? - 'The server sent a failure response, but did not provide an error message.')); - } else if (data['result'] is! Map) { - c.completeError(FormatException( - 'The server sent a success response, but did not include a result.')); - } else { - c.complete(data['result'] as Map?); + if (requestId != null) { + //var requestId = data['request_id'] as String?; + var c = _requests.remove(requestId); + + if (c != null && !c.isCompleted) { + //if (data['status'] is! bool) { + // c.completeError( + // FormatException('The server sent an invalid response.')); + //} else if (!(data['status'] as bool)) { + if (!status) { + c.completeError(PubSubException(errorMessage ?? + 'The server sent a failure response, but did not provide an error message.')); + } else if (result is! Map) { + c.completeError(FormatException( + 'The server sent a success response, but did not include a result.')); + } else { + c.complete(result); + } } - } - } else if (data is Map && data['id'] is String && _id == null) { - _id = data['id'] as String?; + } else if (id != null && _id == null) { + _id = id; - for (var c in _onConnect) { - if (!c.isCompleted) c.complete(_id); - } + for (var c in _onConnect) { + if (!c.isCompleted) c.complete(_id); + } - _onConnect.clear(); - } else if (data is List && data.length == 2 && data[0] is String) { + _onConnect.clear(); + } + } else if (data is List) { var eventName = data[0] as String; var event = data[1]; for (var s in _subscriptions.where((s) => s.eventName == eventName)) { @@ -82,18 +90,13 @@ class IsolateClient extends Client { var c = Completer(); var requestId = _uuid.v4(); _requests[requestId] = c; - serverSendPort.send({ - 'id': _id, - 'request_id': requestId, - 'method': 'publish', - 'params': { - 'client_id': clientId, - 'event_name': eventName, - 'value': value - } - }); + serverSendPort.send(MessageHandler().encodePublishRequestMessage( + _id, requestId, clientId, eventName, value)); + return c.future.then((result) { - _clientId = result['client_id'] as String?; + var (_, clientId) = MessageHandler() + .decodePublishResponseMessage(result as Map); + _clientId = clientId; }); }); } @@ -104,16 +107,14 @@ class IsolateClient extends Client { var c = Completer(); var requestId = _uuid.v4(); _requests[requestId] = c; - serverSendPort.send({ - 'id': _id, - 'request_id': requestId, - 'method': 'subscribe', - 'params': {'client_id': clientId, 'event_name': eventName} - }); + serverSendPort.send(MessageHandler().encodeSubscriptionRequestMessage( + _id, requestId, clientId, eventName)); + return c.future.then((result) { - _clientId = result['client_id'] as String?; - var s = _IsolateClientSubscription( - eventName, result['subscription_id'] as String?, this); + var (subcriptionId, clientId) = MessageHandler() + .decodeSubscriptionResponseMessage(result as Map); + _clientId = clientId; + var s = _IsolateClientSubscription(eventName, subcriptionId, this); _subscriptions.add(s); return s; }); @@ -171,14 +172,11 @@ class _IsolateClientSubscription extends ClientSubscription { var c = Completer(); var requestId = client._uuid.v4(); client._requests[requestId] = c; - client.serverSendPort.send({ - 'id': client._id, - 'request_id': requestId, - 'method': 'unsubscribe', - 'params': {'client_id': client.clientId, 'subscription_id': id} - }); + client.serverSendPort.send(MessageHandler() + .encodeUnsubscriptionRequestMessage( + client._id, requestId, client.clientId, id)); - return c.future.then((_) { + return c.future.then((result) { _close(); }); }); diff --git a/packages/pub_sub/lib/src/isolate/server.dart b/packages/pub_sub/lib/src/isolate/server.dart index bd9fadf..95c9f79 100644 --- a/packages/pub_sub/lib/src/isolate/server.dart +++ b/packages/pub_sub/lib/src/isolate/server.dart @@ -1,7 +1,8 @@ import 'dart:async'; import 'dart:isolate'; import 'package:uuid/uuid.dart'; -import '../../belatuk_pub_sub.dart'; +import '../protocol/protocol.dart'; +import 'shared.dart'; /// A [Adapter] implementation that communicates via [SendPort]s and [ReceivePort]s. class IsolateAdapter extends Adapter { @@ -42,81 +43,50 @@ class IsolateAdapter extends Adapter { if (data is SendPort) { var id = _uuid.v4(); _clients[id] = data; - data.send({'status': true, 'id': id}); - } else if (data is Map && - data['id'] is String && - data['request_id'] is String && - data['method'] is String && - data['params'] is Map) { - var id = data['id'] as String?, - requestId = data['request_id'] as String?, - method = data['method'] as String?; - var params = data['params'] as Map?; - var sp = _clients[id!]; + data.send(MessageHandler().encodeSendPortResponseMessage(id)); + } else if (data is Map) { + var (id, method, requestId, params) = + MessageHandler().decodeRequestMessage(data); + var (clientId, eventName, subscriptionId, value) = + MessageHandler().decodeRequestParams(params); + var sp = _clients[id]; if (sp == null) { - // There's nobody to respond to, so don't send anything to anyone. Oops. - } else if (method == 'publish') { - if (_isValidClientId(params!['client_id']) && - params['event_name'] is String && - params.containsKey('value')) { - var clientId = params['client_id'] as String?, - eventName = params['event_name'] as String?; - var value = params['value']; - var rq = _IsolatePublishRequestImpl( - requestId, clientId, eventName, value, sp); - _onPublish.add(rq); - } else { - sp.send({ - 'status': false, - 'request_id': requestId, - 'error_message': 'Expected client_id, event_name, and value.' - }); + // There's nobody to respond to, so don't send anything to anyone + return; + } + + if (method == 'publish') { + if (eventName == null || value == null) { + sp.send(MessageHandler().encodePublishResponseError(requestId)); } + var rq = _IsolatePublishRequestImpl( + requestId, clientId, eventName, value, sp); + _onPublish.add(rq); } else if (method == 'subscribe') { - if (_isValidClientId(params!['client_id']) && - params['event_name'] is String) { - var clientId = params['client_id'] as String?, - eventName = params['event_name'] as String?; - var rq = _IsolateSubscriptionRequestImpl( - clientId, eventName, sp, requestId, _uuid); - _onSubscribe.add(rq); - } else { - sp.send({ - 'status': false, - 'request_id': requestId, - 'error_message': 'Expected client_id, and event_name.' - }); + if (eventName == null) { + sp.send( + MessageHandler().encodeSubscriptionResponseError(requestId)); } + var rq = _IsolateSubscriptionRequestImpl( + clientId, eventName, sp, requestId, _uuid); + _onSubscribe.add(rq); } else if (method == 'unsubscribe') { - if (_isValidClientId(params!['client_id']) && - params['subscription_id'] is String) { - var clientId = params['client_id'] as String?, - subscriptionId = params['subscription_id'] as String?; - var rq = _IsolateUnsubscriptionRequestImpl( - clientId, subscriptionId, sp, requestId); - _onUnsubscribe.add(rq); - } else { - sp.send({ - 'status': false, - 'request_id': requestId, - 'error_message': 'Expected client_id, and subscription_id.' - }); + if (subscriptionId == null) { + sp.send( + MessageHandler().encodeUnsubscriptionResponseError(requestId)); } + var rq = _IsolateUnsubscriptionRequestImpl( + clientId, subscriptionId, sp, requestId); + _onUnsubscribe.add(rq); } else { - sp.send({ - 'status': false, - 'request_id': requestId, - 'error_message': - 'Unrecognized method "$method". Or, you omitted id, request_id, method, or params.' - }); + sp.send(MessageHandler() + .encodeUnknownMethodResponseError(requestId, method)); } } }); } - bool _isValidClientId(id) => id == null || id is String; - @override bool isTrustedPublishRequest(PublishRequest request) { // Isolate clients are considered trusted, because they are @@ -138,7 +108,7 @@ class _IsolatePublishRequestImpl extends PublishRequest { final String? eventName; @override - final dynamic value; + final Object? value; final SendPort sendPort; @@ -148,24 +118,15 @@ class _IsolatePublishRequestImpl extends PublishRequest { this.requestId, this.clientId, this.eventName, this.value, this.sendPort); @override - void accept(PublishResponse response) { - sendPort.send({ - 'status': true, - 'request_id': requestId, - 'result': { - 'listeners': response.listeners, - 'client_id': response.clientId - } - }); + void reject(String errorMessage) { + sendPort.send(MessageHandler() + .encodePublishResponseError(requestId, errorMessage: errorMessage)); } @override - void reject(String errorMessage) { - sendPort.send({ - 'status': false, - 'request_id': requestId, - 'error_message': errorMessage - }); + void accept(PublishResponse response) { + sendPort.send(MessageHandler().encodePublishResponseMessage2( + requestId, response.listeners, response.clientId)); } } @@ -187,21 +148,15 @@ class _IsolateSubscriptionRequestImpl extends SubscriptionRequest { @override void reject(String errorMessage) { - sendPort.send({ - 'status': false, - 'request_id': requestId, - 'error_message': errorMessage - }); + sendPort.send(MessageHandler().encodeSubscriptionResponseError(requestId, + errorMessage: errorMessage)); } @override FutureOr accept(String? clientId) { var id = _uuid.v4(); - sendPort.send({ - 'status': true, - 'request_id': requestId, - 'result': {'subscription_id': id, 'client_id': clientId} - }); + sendPort.send(MessageHandler() + .encodeSubscriptionResponseMessage(requestId, id, clientId)); return _IsolateSubscriptionImpl(clientId, id, eventName, sendPort); } } @@ -239,15 +194,13 @@ class _IsolateUnsubscriptionRequestImpl extends UnsubscriptionRequest { @override void reject(String errorMessage) { - sendPort.send({ - 'status': false, - 'request_id': requestId, - 'error_message': errorMessage - }); + sendPort.send(MessageHandler().encodeUnsubscriptionResponseError(requestId, + errorMessage: errorMessage)); } @override void accept() { - sendPort.send({'status': true, 'request_id': requestId, 'result': {}}); + sendPort + .send(MessageHandler().encodeUnsubscriptionResponseMessage(requestId)); } } diff --git a/packages/pub_sub/lib/src/isolate/shared.dart b/packages/pub_sub/lib/src/isolate/shared.dart new file mode 100644 index 0000000..d8f1728 --- /dev/null +++ b/packages/pub_sub/lib/src/isolate/shared.dart @@ -0,0 +1,181 @@ +class MessageHandler { + static const _requestId = 'request_id'; + static const _method = 'method'; + static const _clientId = 'client_id'; + static const _eventName = 'event_name'; + static const _subscriptionId = 'subscription_id'; + static const _errorMessage = 'error_message'; + static const _value = 'value'; + static const _id = 'id'; + static const _params = 'params'; + static const _status = 'status'; + static const _result = 'result'; + static const _listeners = 'listeners'; + + static const _publishErrorMsg = 'Expected client_id, event_name, and value'; + static const _subscribeErrorMsg = 'Expected client_id, and event_name'; + static const _unsubscribeErrorMsg = 'Expected client_id, and subscription_id'; + + const MessageHandler(); + + Map encodePublishResponseError(String? requestId, + {String errorMessage = _publishErrorMsg}) { + return _encodeResponseError(requestId, errorMessage); + } + + Map encodeSubscriptionResponseError(String? requestId, + {String errorMessage = _subscribeErrorMsg}) { + return _encodeResponseError(requestId, errorMessage); + } + + Map encodeUnsubscriptionResponseError(String? requestId, + {String errorMessage = _unsubscribeErrorMsg}) { + return _encodeResponseError(requestId, errorMessage); + } + + Map encodeUnknownMethodResponseError( + String? requestId, String method) { + var unknownMethodErrorMsg = + 'Unrecognized method "$method" or you have omitted id, request_id, method, or params'; + + return _encodeResponseError(requestId, unknownMethodErrorMsg); + } + + Map _encodeResponseError(String? requestId, String message) { + return { + _status: false, + _requestId: requestId ?? '', + _errorMessage: message + }; + } + + Map encodeEventMessage(String? requestId, Object message) { + return {_status: true, _requestId: requestId ?? '', _result: message}; + } + + Map encodeSubscriptionResponseMessage( + String? requestId, String? subscriptionId, String? clientId) { + return { + _status: true, + _requestId: requestId ?? '', + _result: {_subscriptionId: subscriptionId, _clientId: clientId} + }; + } + + (String?, String?) decodeSubscriptionResponseMessage( + Map message) { + var subscriptionId = message[_subscriptionId] as String?; + var clientId = message[_clientId] as String?; + + return (subscriptionId, clientId); + } + + Map encodeUnsubscriptionResponseMessage(String? requestId) { + return {_status: true, _requestId: requestId, _result: {}}; + } + + (bool, String?, Object?, String?) decodeUnsubscriptionResponseMessage( + Map message) { + var status = message[_status] as bool? ?? false; + var requestId = message[_requestId] as String?; + var result = message[_result]; + var errorMessage = message[_errorMessage] as String?; + + return (status, requestId, result, errorMessage); + } + + Map encodePublishResponseMessage2( + String? requestId, int listeners, String? clientId) { + return { + _status: true, + _requestId: requestId, + _result: {_listeners: listeners, _clientId: clientId} + }; + } + + (int, String?) decodePublishResponseMessage(Map message) { + var listeners = message[_listeners] as int; + var clientId = message[_clientId] as String?; + + return (listeners, clientId); + } + + Map encodePublishResponseMessage(String? id, + String? requestId, String? clientId, String? eventName, Object? value) { + return { + _id: id, + _requestId: requestId, + _method: 'publish', + _params: {_clientId: clientId, _eventName: eventName, _value: value} + }; + } + + Map encodeResponseMessage( + String? requestId, Object message) { + return {_status: true, _requestId: requestId ?? '', _result: message}; + } + + (bool, String?, String?, Object?, String?) decodeResponseMessage( + Map message) { + var id = message[_id] as String?; + var status = message[_status] as bool? ?? false; + var requestId = message[_requestId] as String?; + var result = message[_result]; + var errorMessage = message[_errorMessage] as String?; + + return (status, id, requestId, result, errorMessage); + } + + (String, String, String, Map) decodeRequestMessage( + Map message) { + var id = message[_id] as String? ?? ''; + var method = message[_method] as String? ?? ''; + var requestId = message[_requestId] as String? ?? ''; + var params = message[_params] as Map? ?? {}; + + return (id, method, requestId, params); + } + + Map encodeSubscriptionRequestMessage( + String? id, String? requestId, String? clientId, String? eventName) { + return { + _id: id, + _requestId: requestId, + _method: 'subscribe', + _params: {_clientId: clientId, _eventName: eventName} + }; + } + + Map encodeUnsubscriptionRequestMessage( + String? id, String? requestId, String? clientId, String? subscriptionId) { + return { + _id: id, + _requestId: requestId, + _method: 'unsubscribe', + _params: {_clientId: clientId, _subscriptionId: subscriptionId} + }; + } + + Map encodePublishRequestMessage(String? id, + String? requestId, String? clientId, String? eventName, Object? value) { + return { + _id: id, + _requestId: requestId, + _method: 'publish', + _params: {_clientId: clientId, _eventName: eventName, _value: value} + }; + } + + (String?, String?, String?, Object?) decodeRequestParams( + Map params) { + var clientId = params[_clientId] as String?; + var eventName = params[_eventName] as String?; + var value = params[_value]; + var subscriptionId = params[_subscriptionId] as String?; + return (clientId, eventName, subscriptionId, value); + } + + Map encodeSendPortResponseMessage(String id) { + return {_status: true, _id: id}; + } +} diff --git a/packages/pub_sub/lib/src/protocol/server/publish.dart b/packages/pub_sub/lib/src/protocol/server/publish.dart index b6cbf95..8aa0d76 100644 --- a/packages/pub_sub/lib/src/protocol/server/publish.dart +++ b/packages/pub_sub/lib/src/protocol/server/publish.dart @@ -7,7 +7,7 @@ abstract class PublishRequest { String? get eventName; /// The value to be published as an event. - dynamic get value; + Object? get value; /// Accept the request, with a response. void accept(PublishResponse response); diff --git a/packages/pub_sub/pubspec.yaml b/packages/pub_sub/pubspec.yaml index ca587e4..1b22f2d 100644 --- a/packages/pub_sub/pubspec.yaml +++ b/packages/pub_sub/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_pub_sub -version: 6.1.0 +version: 6.2.0 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: From 58f63f0315b9f24d68972f348953e95780aa357b Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Tue, 12 Dec 2023 10:10:10 +0800 Subject: [PATCH 5/5] Updated to use lints 3.0.0 --- packages/body_parser/CHANGELOG.md | 4 ++++ packages/body_parser/README.md | 2 +- packages/body_parser/pubspec.yaml | 2 +- packages/code_buffer/CHANGELOG.md | 4 ++++ packages/code_buffer/README.md | 2 +- packages/code_buffer/pubspec.yaml | 2 +- packages/combinator/CHANGELOG.md | 5 +++++ packages/combinator/README.md | 3 +-- packages/combinator/lib/src/combinator/advance.dart | 2 +- packages/combinator/lib/src/combinator/any.dart | 2 +- packages/combinator/lib/src/combinator/cache.dart | 2 +- packages/combinator/lib/src/combinator/cast.dart | 2 +- packages/combinator/lib/src/combinator/chain.dart | 2 +- packages/combinator/lib/src/combinator/check.dart | 2 +- packages/combinator/lib/src/combinator/compare.dart | 2 +- packages/combinator/lib/src/combinator/fold_errors.dart | 2 +- packages/combinator/lib/src/combinator/index.dart | 2 +- packages/combinator/lib/src/combinator/longest.dart | 2 +- packages/combinator/lib/src/combinator/map.dart | 2 +- packages/combinator/lib/src/combinator/match.dart | 2 +- packages/combinator/lib/src/combinator/max_depth.dart | 2 +- packages/combinator/lib/src/combinator/negate.dart | 2 +- packages/combinator/lib/src/combinator/opt.dart | 2 +- packages/combinator/lib/src/combinator/recursion.dart | 2 +- packages/combinator/lib/src/combinator/reduce.dart | 2 +- packages/combinator/lib/src/combinator/reference.dart | 2 +- packages/combinator/lib/src/combinator/repeat.dart | 2 +- packages/combinator/lib/src/combinator/safe.dart | 2 +- packages/combinator/lib/src/combinator/to_list.dart | 2 +- packages/combinator/lib/src/combinator/util.dart | 2 +- packages/combinator/lib/src/combinator/value.dart | 2 +- packages/combinator/pubspec.yaml | 2 +- packages/html_builder/CHANGELOG.md | 4 ++++ packages/html_builder/README.md | 6 +----- packages/html_builder/pubspec.yaml | 2 +- packages/json_serializer/CHANGELOG.md | 5 +++++ packages/json_serializer/README.md | 4 +++- packages/json_serializer/lib/src/deserialize.dart | 2 +- packages/json_serializer/lib/src/serialize.dart | 2 +- packages/json_serializer/lib/src/util.dart | 2 +- packages/json_serializer/lib/src/validation.dart | 2 +- packages/json_serializer/pubspec.yaml | 2 +- packages/merge_map/CHANGELOG.md | 4 ++++ packages/merge_map/pubspec.yaml | 2 +- packages/pretty_logging/CHANGELOG.md | 4 ++++ packages/pretty_logging/README.md | 2 +- packages/pretty_logging/pubspec.yaml | 2 +- packages/pub_sub/CHANGELOG.md | 5 ++--- packages/pub_sub/README.md | 2 +- packages/range_header/CHANGELOG.md | 4 ++++ packages/range_header/README.md | 2 +- packages/range_header/pubspec.yaml | 2 +- packages/symbol_table/CHANGELOG.md | 5 +++++ packages/symbol_table/lib/src/variable.dart | 2 +- packages/symbol_table/lib/src/visibility.dart | 2 +- packages/symbol_table/pubspec.yaml | 2 +- packages/user_agent/CHANGELOG.md | 4 ++++ packages/user_agent/pubspec.yaml | 2 +- 58 files changed, 94 insertions(+), 55 deletions(-) diff --git a/packages/body_parser/CHANGELOG.md b/packages/body_parser/CHANGELOG.md index 43a56fc..ad99490 100644 --- a/packages/body_parser/CHANGELOG.md +++ b/packages/body_parser/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 5.2.0 + +* Updated `lints` to 3.0.0 + ## 5.1.0 * Updated `belatuk_http_server` to 4.1.1 diff --git a/packages/body_parser/README.md b/packages/body_parser/README.md index a5c7558..72970d4 100644 --- a/packages/body_parser/README.md +++ b/packages/body_parser/README.md @@ -28,7 +28,7 @@ This package is similar to Express.js's `body-parser` module. It fully supports To install Body Parser for your Dart project, simply add body_parser to your pub dependencies. dependencies: - belatuk_body_parser: ^8.0.0 + belatuk_body_parser: ^5.2.0 ### Usage diff --git a/packages/body_parser/pubspec.yaml b/packages/body_parser/pubspec.yaml index 778fa2e..9301cca 100644 --- a/packages/body_parser/pubspec.yaml +++ b/packages/body_parser/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_body_parser -version: 5.1.0 +version: 5.2.0 description: Parse request bodies and query strings in Dart. Supports JSON, URL-encoded, and multi-part bodies. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/body_parser environment: diff --git a/packages/code_buffer/CHANGELOG.md b/packages/code_buffer/CHANGELOG.md index 04e70b4..fffa3d8 100644 --- a/packages/code_buffer/CHANGELOG.md +++ b/packages/code_buffer/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 5.1.0 + +* Updated `lints` to 3.0.0 + ## 5.0.0 * Require Dart >= 3.0 diff --git a/packages/code_buffer/README.md b/packages/code_buffer/README.md index 0710eb8..88df469 100644 --- a/packages/code_buffer/README.md +++ b/packages/code_buffer/README.md @@ -14,7 +14,7 @@ In your `pubspec.yaml`: ```yaml dependencies: - belatuk_code_buffer: ^8.0.0 + belatuk_code_buffer: ^5.1.0 ``` ## Usage diff --git a/packages/code_buffer/pubspec.yaml b/packages/code_buffer/pubspec.yaml index 7e6d388..1829173 100644 --- a/packages/code_buffer/pubspec.yaml +++ b/packages/code_buffer/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_code_buffer -version: 5.0.0 +version: 5.1.0 description: An advanced StringBuffer geared toward generating code, and source maps. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/code_buffer environment: diff --git a/packages/combinator/CHANGELOG.md b/packages/combinator/CHANGELOG.md index 0555a1f..8a1ff95 100644 --- a/packages/combinator/CHANGELOG.md +++ b/packages/combinator/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 5.1.0 + +* Updated `lints` to 3.0.0 +* Fixed lints warnings + ## 5.0.0 * Require Dart >= 3.0 diff --git a/packages/combinator/README.md b/packages/combinator/README.md index 8ed0b42..7573d5a 100644 --- a/packages/combinator/README.md +++ b/packages/combinator/README.md @@ -9,8 +9,7 @@ Packrat parser combinators that support static typing, generics, file spans, memoization, and more. **RECOMMENDED:** -Check `example/` for examples. -The examples contain examples of using: +Check `example/` for examples. The examples contain examples of using: * Generic typing * Reading `FileSpan` from `ParseResult` diff --git a/packages/combinator/lib/src/combinator/advance.dart b/packages/combinator/lib/src/combinator/advance.dart index 01506dc..868df58 100644 --- a/packages/combinator/lib/src/combinator/advance.dart +++ b/packages/combinator/lib/src/combinator/advance.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Advance extends Parser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/any.dart b/packages/combinator/lib/src/combinator/any.dart index 47fe49e..c5d5b93 100644 --- a/packages/combinator/lib/src/combinator/any.dart +++ b/packages/combinator/lib/src/combinator/any.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; /// Matches any one of the given [parsers]. /// diff --git a/packages/combinator/lib/src/combinator/cache.dart b/packages/combinator/lib/src/combinator/cache.dart index b07b38e..268224d 100644 --- a/packages/combinator/lib/src/combinator/cache.dart +++ b/packages/combinator/lib/src/combinator/cache.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Cache extends Parser { final Map> _cache = {}; diff --git a/packages/combinator/lib/src/combinator/cast.dart b/packages/combinator/lib/src/combinator/cast.dart index 9b531d4..eaa9044 100644 --- a/packages/combinator/lib/src/combinator/cast.dart +++ b/packages/combinator/lib/src/combinator/cast.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Cast extends Parser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/chain.dart b/packages/combinator/lib/src/combinator/chain.dart index 5833323..4f63a2f 100644 --- a/packages/combinator/lib/src/combinator/chain.dart +++ b/packages/combinator/lib/src/combinator/chain.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; /// Expects to parse a sequence of [parsers]. /// diff --git a/packages/combinator/lib/src/combinator/check.dart b/packages/combinator/lib/src/combinator/check.dart index 3ef6652..fa575b3 100644 --- a/packages/combinator/lib/src/combinator/check.dart +++ b/packages/combinator/lib/src/combinator/check.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Check extends Parser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/compare.dart b/packages/combinator/lib/src/combinator/compare.dart index 3a5e36d..1448569 100644 --- a/packages/combinator/lib/src/combinator/compare.dart +++ b/packages/combinator/lib/src/combinator/compare.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Compare extends ListParser { final ListParser parser; diff --git a/packages/combinator/lib/src/combinator/fold_errors.dart b/packages/combinator/lib/src/combinator/fold_errors.dart index 6d15c69..05f95f5 100644 --- a/packages/combinator/lib/src/combinator/fold_errors.dart +++ b/packages/combinator/lib/src/combinator/fold_errors.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _FoldErrors extends Parser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/index.dart b/packages/combinator/lib/src/combinator/index.dart index 41d4460..1a0d114 100644 --- a/packages/combinator/lib/src/combinator/index.dart +++ b/packages/combinator/lib/src/combinator/index.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Index extends Parser { final ListParser parser; diff --git a/packages/combinator/lib/src/combinator/longest.dart b/packages/combinator/lib/src/combinator/longest.dart index 94c7340..ff9fe71 100644 --- a/packages/combinator/lib/src/combinator/longest.dart +++ b/packages/combinator/lib/src/combinator/longest.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; /// Matches any one of the given [parsers]. /// diff --git a/packages/combinator/lib/src/combinator/map.dart b/packages/combinator/lib/src/combinator/map.dart index 4dfb326..f0ec10b 100644 --- a/packages/combinator/lib/src/combinator/map.dart +++ b/packages/combinator/lib/src/combinator/map.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Map extends Parser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/match.dart b/packages/combinator/lib/src/combinator/match.dart index 837c306..10c65b9 100644 --- a/packages/combinator/lib/src/combinator/match.dart +++ b/packages/combinator/lib/src/combinator/match.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; /// Expects to match a given [pattern]. If it is not matched, you can provide a custom [errorMessage]. Parser match(Pattern pattern, diff --git a/packages/combinator/lib/src/combinator/max_depth.dart b/packages/combinator/lib/src/combinator/max_depth.dart index 42befcf..3fdf22e 100644 --- a/packages/combinator/lib/src/combinator/max_depth.dart +++ b/packages/combinator/lib/src/combinator/max_depth.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _MaxDepth extends Parser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/negate.dart b/packages/combinator/lib/src/combinator/negate.dart index b507bdc..4c6119c 100644 --- a/packages/combinator/lib/src/combinator/negate.dart +++ b/packages/combinator/lib/src/combinator/negate.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Negate extends Parser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/opt.dart b/packages/combinator/lib/src/combinator/opt.dart index 3f31c99..8d1b43c 100644 --- a/packages/combinator/lib/src/combinator/opt.dart +++ b/packages/combinator/lib/src/combinator/opt.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Opt extends Parser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/recursion.dart b/packages/combinator/lib/src/combinator/recursion.dart index 7651694..b23e784 100644 --- a/packages/combinator/lib/src/combinator/recursion.dart +++ b/packages/combinator/lib/src/combinator/recursion.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; /* /// Handles left recursion in a grammar using the Pratt algorithm. diff --git a/packages/combinator/lib/src/combinator/reduce.dart b/packages/combinator/lib/src/combinator/reduce.dart index a8779b4..c4db631 100644 --- a/packages/combinator/lib/src/combinator/reduce.dart +++ b/packages/combinator/lib/src/combinator/reduce.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Reduce extends Parser { final ListParser parser; diff --git a/packages/combinator/lib/src/combinator/reference.dart b/packages/combinator/lib/src/combinator/reference.dart index 5088c4a..20bc524 100644 --- a/packages/combinator/lib/src/combinator/reference.dart +++ b/packages/combinator/lib/src/combinator/reference.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; Reference reference() => Reference._(); diff --git a/packages/combinator/lib/src/combinator/repeat.dart b/packages/combinator/lib/src/combinator/repeat.dart index 6b89019..debf118 100644 --- a/packages/combinator/lib/src/combinator/repeat.dart +++ b/packages/combinator/lib/src/combinator/repeat.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Repeat extends ListParser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/safe.dart b/packages/combinator/lib/src/combinator/safe.dart index a254229..86c12fb 100644 --- a/packages/combinator/lib/src/combinator/safe.dart +++ b/packages/combinator/lib/src/combinator/safe.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Safe extends Parser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/to_list.dart b/packages/combinator/lib/src/combinator/to_list.dart index bfd7e7b..f838ceb 100644 --- a/packages/combinator/lib/src/combinator/to_list.dart +++ b/packages/combinator/lib/src/combinator/to_list.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _ToList extends ListParser { final Parser parser; diff --git a/packages/combinator/lib/src/combinator/util.dart b/packages/combinator/lib/src/combinator/util.dart index cb5dcdc..69df180 100644 --- a/packages/combinator/lib/src/combinator/util.dart +++ b/packages/combinator/lib/src/combinator/util.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; /// A typed parser that parses a sequence of 2 values of different types. Parser> tuple2(Parser a, Parser b) { diff --git a/packages/combinator/lib/src/combinator/value.dart b/packages/combinator/lib/src/combinator/value.dart index b061207..ec47cc7 100644 --- a/packages/combinator/lib/src/combinator/value.dart +++ b/packages/combinator/lib/src/combinator/value.dart @@ -1,4 +1,4 @@ -part of lex.src.combinator; +part of 'combinator.dart'; class _Value extends Parser { final Parser parser; diff --git a/packages/combinator/pubspec.yaml b/packages/combinator/pubspec.yaml index 72b39a9..9d36a6f 100644 --- a/packages/combinator/pubspec.yaml +++ b/packages/combinator/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_combinator -version: 5.0.0 +version: 5.1.0 description: Packrat parser combinators that support static typing, generics, file spans, memoization, and more. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/combinator environment: diff --git a/packages/html_builder/CHANGELOG.md b/packages/html_builder/CHANGELOG.md index 099fefa..3376d6e 100644 --- a/packages/html_builder/CHANGELOG.md +++ b/packages/html_builder/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 5.1.0 + +* Updated `lints` to 3.0.0 + ## 5.0.0 * Require Dart >= 3.0 diff --git a/packages/html_builder/README.md b/packages/html_builder/README.md index 2212166..b1f8aee 100644 --- a/packages/html_builder/README.md +++ b/packages/html_builder/README.md @@ -8,17 +8,13 @@ This package builds HTML AST's and renders them to HTML. It can be used as an internal DSL, i.e. for a templating engine. -## Requirements - -* Dart SDK: 3.0.x or later - ## Installation In your `pubspec.yaml`: ```yaml dependencies: - belatuk_html_builder: ^8.0.0 + belatuk_html_builder: ^5.1.0 ``` ## Usage diff --git a/packages/html_builder/pubspec.yaml b/packages/html_builder/pubspec.yaml index 1c0ae04..44b8e9f 100644 --- a/packages/html_builder/pubspec.yaml +++ b/packages/html_builder/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_html_builder -version: 5.0.0 +version: 5.1.0 description: Build HTML AST's and render them to HTML. This can be used as an internal DSL, i.e. for a templating engine. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/html_builder environment: diff --git a/packages/json_serializer/CHANGELOG.md b/packages/json_serializer/CHANGELOG.md index cd8cd38..33ac891 100644 --- a/packages/json_serializer/CHANGELOG.md +++ b/packages/json_serializer/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 7.1.0 + +* Updated `lints` to 3.0.0 +* Fixed lints warnings + ## 7.0.0 * Require Dart >= 3.0 diff --git a/packages/json_serializer/README.md b/packages/json_serializer/README.md index 03a6722..2719c68 100644 --- a/packages/json_serializer/README.md +++ b/packages/json_serializer/README.md @@ -11,8 +11,10 @@ The ***new and improved*** definitive solution for JSON in Dart. It supports syn ## Installation +```yaml dependencies: - belatuk_json_serializer: ^8.0.0 + belatuk_json_serializer: ^7.1.0 +``` ## Usage diff --git a/packages/json_serializer/lib/src/deserialize.dart b/packages/json_serializer/lib/src/deserialize.dart index 35cc5ef..c7bdfe3 100644 --- a/packages/json_serializer/lib/src/deserialize.dart +++ b/packages/json_serializer/lib/src/deserialize.dart @@ -1,4 +1,4 @@ -part of belatuk_json_serializer; +part of '../belatuk_json_serializer.dart'; /// Deserializes a JSON string into a Dart datum. /// diff --git a/packages/json_serializer/lib/src/serialize.dart b/packages/json_serializer/lib/src/serialize.dart index 04251a0..79b9385 100644 --- a/packages/json_serializer/lib/src/serialize.dart +++ b/packages/json_serializer/lib/src/serialize.dart @@ -1,4 +1,4 @@ -part of belatuk_json_serializer; +part of '../belatuk_json_serializer.dart'; /// Serializes any arbitrary Dart datum to JSON. Supports schema validation. String serialize(value) { diff --git a/packages/json_serializer/lib/src/util.dart b/packages/json_serializer/lib/src/util.dart index 18a7f87..325b4b5 100644 --- a/packages/json_serializer/lib/src/util.dart +++ b/packages/json_serializer/lib/src/util.dart @@ -1,4 +1,4 @@ -part of belatuk_json_serializer; +part of '../belatuk_json_serializer.dart'; bool _isPrimitive(value) { return value is num || value is bool || value is String || value == null; diff --git a/packages/json_serializer/lib/src/validation.dart b/packages/json_serializer/lib/src/validation.dart index 8fc230e..22288fb 100644 --- a/packages/json_serializer/lib/src/validation.dart +++ b/packages/json_serializer/lib/src/validation.dart @@ -1,4 +1,4 @@ -part of belatuk_json_serializer; +part of '../belatuk_json_serializer.dart'; /// Thrown when schema validation fails. class JsonValidationError implements Exception { diff --git a/packages/json_serializer/pubspec.yaml b/packages/json_serializer/pubspec.yaml index 75cccd3..ff6c33e 100644 --- a/packages/json_serializer/pubspec.yaml +++ b/packages/json_serializer/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_json_serializer -version: 7.0.0 +version: 7.1.0 description: Easy JSON to Object serialization and deserialization in Dart. homepage: https://github.com/dart-backend/belatuk-common-utilities/tree/main/packages/json_serializer environment: diff --git a/packages/merge_map/CHANGELOG.md b/packages/merge_map/CHANGELOG.md index 72187c7..aa36494 100644 --- a/packages/merge_map/CHANGELOG.md +++ b/packages/merge_map/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 5.1.0 + +* Updated `lints` to 3.0.0 + ## 5.0.0 * Require Dart >= 3.0 diff --git a/packages/merge_map/pubspec.yaml b/packages/merge_map/pubspec.yaml index de9c43d..d5b6b5c 100644 --- a/packages/merge_map/pubspec.yaml +++ b/packages/merge_map/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_merge_map -version: 5.0.0 +version: 5.1.0 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: diff --git a/packages/pretty_logging/CHANGELOG.md b/packages/pretty_logging/CHANGELOG.md index 2f3d492..e135d46 100644 --- a/packages/pretty_logging/CHANGELOG.md +++ b/packages/pretty_logging/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.1.0 + +* Updated `lints` to 3.0.0 + ## 6.0.0 * Require Dart >= 3.0 diff --git a/packages/pretty_logging/README.md b/packages/pretty_logging/README.md index db09cf0..e7f847a 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: ^8.0.0 + belatuk_pretty_logging: ^6.1.0 ``` ## Usage diff --git a/packages/pretty_logging/pubspec.yaml b/packages/pretty_logging/pubspec.yaml index e546dda..33b4456 100644 --- a/packages/pretty_logging/pubspec.yaml +++ b/packages/pretty_logging/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_pretty_logging -version: 6.0.0 +version: 6.1.0 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: diff --git a/packages/pub_sub/CHANGELOG.md b/packages/pub_sub/CHANGELOG.md index 8861780..ddad207 100644 --- a/packages/pub_sub/CHANGELOG.md +++ b/packages/pub_sub/CHANGELOG.md @@ -2,13 +2,12 @@ ## 6.2.0 -* Require Dart >= 3.2 -* Upgraded `lints` to 3.0.0 +* Updated `lints` to 3.0.0 * Refactored encode/decode message handling into `MessageHandler` ## 6.1.0 -* Upgraded `uuid` to 4.0.0 +* Updated `uuid` to 4.0.0 ## 6.0.0 diff --git a/packages/pub_sub/README.md b/packages/pub_sub/README.md index 1af71f7..9a64766 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: ^8.2.0 + belatuk_pub_sub: ^6.2.0 ``` Then, be sure to run `dart pub get` in your terminal. diff --git a/packages/range_header/CHANGELOG.md b/packages/range_header/CHANGELOG.md index c546061..add543f 100644 --- a/packages/range_header/CHANGELOG.md +++ b/packages/range_header/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.2.0 + +* Updated `lints` to 3.0.0 + ## 6.1.0 * Updated `file` to 7.0.0 diff --git a/packages/range_header/README.md b/packages/range_header/README.md index eb02430..f1682e6 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: ^8.0.0 + belatuk_range_header: ^6.2.0 ``` ## Usage diff --git a/packages/range_header/pubspec.yaml b/packages/range_header/pubspec.yaml index e6c6e1d..fff44d9 100644 --- a/packages/range_header/pubspec.yaml +++ b/packages/range_header/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_range_header -version: 6.1.0 +version: 6.2.0 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: diff --git a/packages/symbol_table/CHANGELOG.md b/packages/symbol_table/CHANGELOG.md index d87cb94..17a4721 100644 --- a/packages/symbol_table/CHANGELOG.md +++ b/packages/symbol_table/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 5.1.0 + +* Updated `lints` to 3.0.0 +* Fixed lints warnings + ## 5.0.0 * Require Dart >= 3.0 diff --git a/packages/symbol_table/lib/src/variable.dart b/packages/symbol_table/lib/src/variable.dart index 402aec2..eea01cb 100644 --- a/packages/symbol_table/lib/src/variable.dart +++ b/packages/symbol_table/lib/src/variable.dart @@ -1,4 +1,4 @@ -part of symbol_table; +part of 'symbol_table.dart'; /// Holds a symbol, the value of which may change or be marked immutable. class Variable { diff --git a/packages/symbol_table/lib/src/visibility.dart b/packages/symbol_table/lib/src/visibility.dart index 4144e0f..be53da3 100644 --- a/packages/symbol_table/lib/src/visibility.dart +++ b/packages/symbol_table/lib/src/visibility.dart @@ -1,4 +1,4 @@ -part of symbol_table; +part of 'symbol_table.dart'; /// Represents the visibility of a symbol. /// diff --git a/packages/symbol_table/pubspec.yaml b/packages/symbol_table/pubspec.yaml index 42deea2..f12b11e 100644 --- a/packages/symbol_table/pubspec.yaml +++ b/packages/symbol_table/pubspec.yaml @@ -1,5 +1,5 @@ name: belatuk_symbol_table -version: 5.0.0 +version: 5.1.0 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: diff --git a/packages/user_agent/CHANGELOG.md b/packages/user_agent/CHANGELOG.md index 98da8a0..0f0954f 100644 --- a/packages/user_agent/CHANGELOG.md +++ b/packages/user_agent/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 5.1.0 + +* Updated `lints` to 3.0.0 + ## 5.0.0 * Require Dart >= 3.0 diff --git a/packages/user_agent/pubspec.yaml b/packages/user_agent/pubspec.yaml index d7ff4af..9ab9ffc 100644 --- a/packages/user_agent/pubspec.yaml +++ b/packages/user_agent/pubspec.yaml @@ -1,5 +1,5 @@ name: user_agent_analyzer -version: 5.0.0 +version: 5.1.0 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: