From c0997507558d3a3045efa74a21ded79a77b2ec30 Mon Sep 17 00:00:00 2001 From: thomashii Date: Fri, 20 Aug 2021 13:55:04 +0800 Subject: [PATCH 01/22] Updated README --- packages/framework/CHANGELOG.md | 4 ++++ packages/framework/README.md | 11 ++++++----- packages/framework/pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/packages/framework/CHANGELOG.md b/packages/framework/CHANGELOG.md index 38016e78..98581c61 100644 --- a/packages/framework/CHANGELOG.md +++ b/packages/framework/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 4.1.3 + +* Updated README + ## 4.1.2 * Updated README diff --git a/packages/framework/README.md b/packages/framework/README.md index 69ba6f67..1638d15f 100644 --- a/packages/framework/README.md +++ b/packages/framework/README.md @@ -1,19 +1,20 @@ # Angel3 Framework -[![version](https://img.shields.io/badge/pub-v4.1.2-brightgreen)](https://pub.dev/packages/angel3_framework) +[![version](https://img.shields.io/badge/pub-v4.1.3-brightgreen)](https://pub.dev/packages/angel3_framework) [![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/framework/LICENSE) -**Replacement of Angel Framework with major change to support NNBD** +**Replacement of Angel Framework with major change to support NNBD.** + Angel3 framework is a high-powered HTTP server with support for dependency injection, sophisticated routing, authentication, ORM, graphql etc. It is designed to keep the core minimal but extensible through a series of plugin packages. It won't dictate which features, databases or web templating engine to use. This flexibility enable Angel3 framework to grow with your application as new features can be added to handle the new use cases. This package is the core of the [Angel3](https://github.com/dukefirehawk/angel/tree/angel3) framework. To see more details, please refer to the [Developer Guide](https://angel3-docs.dukefirehawk.com). -## Usage +## Installation and Setup -### Create a new project by cloning from boilerplate templates +### (Option 1) Create a new project by cloning from boilerplate templates 1. Download and install [Dart](https://dart.dev/get-dart) @@ -36,7 +37,7 @@ This package is the core of the [Angel3](https://github.com/dukefirehawk/angel/t 5. Run as docker. Edit and build the image with the provided `Dockerfile` file. -### Create a new project with Angel3 CLI +### (Option 2) Create a new project with Angel3 CLI 1. Download and install [Dart](https://dart.dev/get-dart) diff --git a/packages/framework/pubspec.yaml b/packages/framework/pubspec.yaml index ff8b13e0..4b0b5d01 100644 --- a/packages/framework/pubspec.yaml +++ b/packages/framework/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_framework -version: 4.1.2 +version: 4.1.3 description: A high-powered HTTP server extensible framework with dependency injection, routing and much more. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel From 3d8778db5a6cd068d69a22d28224606f9370a8ee Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 11 Sep 2021 08:41:00 +0800 Subject: [PATCH 02/22] Updated pkg:angel3_production to use lints --- packages/production/.gitignore | 71 ----------------------- packages/production/CHANGELOG.md | 4 ++ packages/production/LICENSE | 42 ++++++++------ packages/production/README.md | 2 +- packages/production/analysis_options.yaml | 5 +- packages/production/lib/src/runner.dart | 4 +- packages/production/pubspec.yaml | 6 +- 7 files changed, 37 insertions(+), 97 deletions(-) delete mode 100644 packages/production/.gitignore diff --git a/packages/production/.gitignore b/packages/production/.gitignore deleted file mode 100644 index 24d68312..00000000 --- a/packages/production/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.dart_tool -.packages -.pub/ -build/ - -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# SDK 1.20 and later (no longer creates packages directories) - -# Older SDK versions -# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) -.project -.buildlog -**/packages/ - - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: - -## VsCode -.vscode/ - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -.idea/ -/out/ -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties diff --git a/packages/production/CHANGELOG.md b/packages/production/CHANGELOG.md index 79fe83cf..f1a655e3 100644 --- a/packages/production/CHANGELOG.md +++ b/packages/production/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 3.0.3 + +* Upgraded from `pendantic` to `lints` linter + ## 3.0.2 * Fixed NNBD issues diff --git a/packages/production/LICENSE b/packages/production/LICENSE index 8f65b579..df5e0635 100644 --- a/packages/production/LICENSE +++ b/packages/production/LICENSE @@ -1,21 +1,29 @@ -MIT License (MIT) +BSD 3-Clause License -Copyright (c) 2021 dukefirehawk.com +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/production/README.md b/packages/production/README.md index b34e2cb9..531a36db 100644 --- a/packages/production/README.md +++ b/packages/production/README.md @@ -1,6 +1,6 @@ # Angel3 Production Runner -[![version](https://img.shields.io/badge/pub-v3.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_production) +[![version](https://img.shields.io/badge/pub-v3.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_production) [![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/production/analysis_options.yaml b/packages/production/analysis_options.yaml index c230cee7..ea2c9e94 100644 --- a/packages/production/analysis_options.yaml +++ b/packages/production/analysis_options.yaml @@ -1,4 +1 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/production/lib/src/runner.dart b/packages/production/lib/src/runner.dart index 5dad59ef..d9560409 100644 --- a/packages/production/lib/src/runner.dart +++ b/packages/production/lib/src/runner.dart @@ -180,7 +180,9 @@ _ ___ | /| / / /_/ / _ /___ _ /___ 'https://angel3-framework.web.app\n')); if (argResults['help'] == true) { - stdout..writeln('Options:')..writeln(RunnerOptions.argParser.usage); + stdout + ..writeln('Options:') + ..writeln(RunnerOptions.argParser.usage); return; } diff --git a/packages/production/pubspec.yaml b/packages/production/pubspec.yaml index 3c8f0030..d6b42449 100644 --- a/packages/production/pubspec.yaml +++ b/packages/production/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_production -version: 3.0.2 +version: 3.0.3 description: Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel3. homepage: https://angel3-framework.web.app repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/production @@ -7,10 +7,10 @@ environment: sdk: '>=2.12.0 <3.0.0' dependencies: angel3_container: ^3.0.0 - angel3_framework: ^4.0.0 + angel3_framework: ^4.1.0 angel3_pub_sub: ^3.0.0 args: ^2.1.0 io: ^1.0.0 logging: ^1.0.1 dev_dependencies: - pedantic: ^1.11.0 \ No newline at end of file + lints: ^1.0.1 \ No newline at end of file From d810e27673b05c0479b194a874234215c4972f01 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 11 Sep 2021 11:18:35 +0800 Subject: [PATCH 03/22] Updated hot --- packages/hot/CHANGELOG.md | 5 ++++ packages/hot/LICENSE | 42 ++++++++++++++++++------------ packages/hot/README.md | 8 +++--- packages/hot/analysis_options.yaml | 9 +------ packages/hot/lib/angel3_hot.dart | 7 ++--- packages/hot/pubspec.yaml | 8 +++--- 6 files changed, 43 insertions(+), 36 deletions(-) diff --git a/packages/hot/CHANGELOG.md b/packages/hot/CHANGELOG.md index b5a0fb97..f973940c 100644 --- a/packages/hot/CHANGELOG.md +++ b/packages/hot/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 4.2.0 + +* Updated to use `belatuk_html_builder` package +* Upgraded from `pendantic` to `lints` linter + ## 4.1.1 * Fixed NNBD issues diff --git a/packages/hot/LICENSE b/packages/hot/LICENSE index 8f65b579..df5e0635 100644 --- a/packages/hot/LICENSE +++ b/packages/hot/LICENSE @@ -1,21 +1,29 @@ -MIT License (MIT) +BSD 3-Clause License -Copyright (c) 2021 dukefirehawk.com +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/hot/README.md b/packages/hot/README.md index 2a32f79b..55bdf3de 100644 --- a/packages/hot/README.md +++ b/packages/hot/README.md @@ -1,6 +1,6 @@ # Angel3 Hot Reloader -[![version](https://img.shields.io/badge/pub-v4.1.1-brightgreen)](https://pub.dartlang.org/packages/angel3_hot) +[![version](https://img.shields.io/badge/pub-v4.2.0-brightgreen)](https://pub.dartlang.org/packages/angel3_hot) [![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) @@ -9,7 +9,7 @@ ![Screenshot of terminal](screenshots/angel3-screenshot.png) Supports *hot reloading* of Angel3 servers on file changes. This is faster and more reliable than merely reactively restarting a `Process`. -This package only works with the [Angel3 framework](https://github.com/dukefirehawk/angel). +This package only works with the [Angel3 framework](https://pub.dev/packages/angel3_framework). **Not recommended to use in production, unless you are specifically intending for a "hot code push" in production..** @@ -19,8 +19,8 @@ In your `pubspec.yaml`: ```yaml dependencies: - angel3_framework: ^4.0.0 - angel3_hot: ^4.0.0 + angel3_framework: ^4.1.0 + angel3_hot: ^4.2.0 ``` ## Usage diff --git a/packages/hot/analysis_options.yaml b/packages/hot/analysis_options.yaml index 085be64d..ea2c9e94 100644 --- a/packages/hot/analysis_options.yaml +++ b/packages/hot/analysis_options.yaml @@ -1,8 +1 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false -linter: - rules: - - unnecessary_const - - unnecessary_new \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/hot/lib/angel3_hot.dart b/packages/hot/lib/angel3_hot.dart index 18affc7d..6d2d4a94 100644 --- a/packages/hot/lib/angel3_hot.dart +++ b/packages/hot/lib/angel3_hot.dart @@ -10,8 +10,8 @@ import 'package:angel3_websocket/server.dart'; import 'package:charcode/ascii.dart'; import 'package:glob/glob.dart'; import 'package:glob/list_local_fs.dart'; -import 'package:angel3_html_builder/elements.dart'; -import 'package:angel3_html_builder/angel3_html_builder.dart'; +import 'package:belatuk_html_builder/elements.dart'; +import 'package:belatuk_html_builder/belatuk_html_builder.dart'; import 'package:io/ansi.dart'; import 'package:path/path.dart' as p; import 'package:vm_service/vm_service.dart' as vm; @@ -211,7 +211,7 @@ class HotReloader { var serverUri = Uri(scheme: 'http', host: server.address.address, port: server.port); - var observatoryUri; + Uri? observatoryUri; if (isHot) { observatoryUri = await dev.Service.getInfo().then((i) => i.serverUri!); } @@ -224,6 +224,7 @@ class HotReloader { if (isHot) { stdout.write( 'An Observatory debugger and profiler on ${Platform.operatingSystem} is available at: '); + print(wrapWith('$observatoryUri', [cyan, styleUnderlined])); } else { stdout.write( diff --git a/packages/hot/pubspec.yaml b/packages/hot/pubspec.yaml index bc902a74..c0e0186d 100644 --- a/packages/hot/pubspec.yaml +++ b/packages/hot/pubspec.yaml @@ -1,14 +1,14 @@ name: angel3_hot description: Supports hot reloading/hot code push of Angel3 servers on file changes. -version: 4.1.1 +version: 4.2.0 homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/hot environment: sdk: '>=2.12.0 <3.0.0' dependencies: - angel3_framework: ^4.0.0 + angel3_framework: ^4.1.0 angel3_websocket: ^4.0.0 - angel3_html_builder: ^2.0.0 + belatuk_html_builder: ^3.0.0 charcode: ^1.2.0 glob: ^2.0.1 io: ^1.0.0 @@ -18,4 +18,4 @@ dependencies: dev_dependencies: http: ^0.13.2 logging: ^1.0.1 - pedantic: ^1.11.0 + lints: ^1.0.0 From d528e5d2a4307ad62c3efc8f5d659d78dc10af41 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 11 Sep 2021 11:49:37 +0800 Subject: [PATCH 04/22] Deprecated html_builder --- packages/html_builder/CHANGELOG.md | 7 +- packages/html_builder/LICENSE | 42 +- packages/html_builder/README.md | 6 +- packages/html_builder/lib/elements.dart | 2492 +++++++++++------------ packages/html_builder/lib/src/node.dart | 8 +- packages/html_builder/pubspec.yaml | 4 +- 6 files changed, 1190 insertions(+), 1369 deletions(-) diff --git a/packages/html_builder/CHANGELOG.md b/packages/html_builder/CHANGELOG.md index 83c870e9..412c3403 100644 --- a/packages/html_builder/CHANGELOG.md +++ b/packages/html_builder/CHANGELOG.md @@ -1,8 +1,13 @@ # Change Log +## 2.0.4 + +* Upgraded from `pendantic` to `lints` linter +* Removed deprecated parameters + ## 2.0.3 -* Added example +* Added an example * Updated README ## 2.0.2 diff --git a/packages/html_builder/LICENSE b/packages/html_builder/LICENSE index 8f65b579..df5e0635 100644 --- a/packages/html_builder/LICENSE +++ b/packages/html_builder/LICENSE @@ -1,21 +1,29 @@ -MIT License (MIT) +BSD 3-Clause License -Copyright (c) 2021 dukefirehawk.com +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/html_builder/README.md b/packages/html_builder/README.md index e99fbdbc..0a8ed41a 100644 --- a/packages/html_builder/README.md +++ b/packages/html_builder/README.md @@ -1,11 +1,13 @@ # Angel3 Html Builder -[![version](https://img.shields.io/badge/pub-v2.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_html_builder) +[![version](https://img.shields.io/badge/pub-v2.0.4-brightgreen)](https://pub.dartlang.org/packages/angel3_html_builder) [![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/html_builder/LICENSE) +**DEPRECATED: Replaced by [`belatuk_html_builder`](https://pub.dartlang.org/packages/belatuk_html_builder) package** + Build HTML AST's and render them to HTML. This can be used as an internal DSL, i.e. for a templating engine. @@ -68,6 +70,7 @@ void main() { ``` Standard HTML5 elements: + ```dart import 'package:angel3_html_builder/elements.dart'; @@ -85,6 +88,7 @@ void main() { ``` Rendering to HTML: + ```dart String html = StringRenderer().render($dom); ``` diff --git a/packages/html_builder/lib/elements.dart b/packages/html_builder/lib/elements.dart index 757a0689..d4cbb249 100644 --- a/packages/html_builder/lib/elements.dart +++ b/packages/html_builder/lib/elements.dart @@ -34,14 +34,11 @@ Node a( className, style, Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => + Iterable c = const []}) => h( 'a', _apply([ p, - props ], { 'href': href, 'rel': rel, @@ -50,7 +47,7 @@ Node a( 'class': className, 'style': style, }), - [...c, ...children]); + [...c]); Node abbr( {String? title, @@ -58,50 +55,44 @@ Node abbr( className, style, Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => + Iterable c = const []}) => h( 'addr', - _apply([p, props], + _apply([p], {'title': title, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + [...c]); -Node address( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'address', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node address({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('address', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node area( - {String? alt, - Iterable? coordinates, - String? download, - String? href, - String? hreflang, - String? media, - String? nohref, - String? rel, - String? shape, - String? target, - String? type, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node area({ + String? alt, + Iterable? coordinates, + String? download, + String? href, + String? hreflang, + String? media, + String? nohref, + String? rel, + String? shape, + String? target, + String? type, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'area', _apply([ - p, - props + p ], { 'alt': alt, 'coordinates': coordinates, @@ -119,48 +110,41 @@ Node area( 'style': style })); -Node article( - {className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('article', _apply([p, props], {'class': className, 'style': style}), - [...c, ...children]); +Node article({ + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('article', _apply([p], {'class': className, 'style': style}), [...c]); -Node aside( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'aside', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node aside({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('aside', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node audio( - {bool? autoplay, - bool? controls, - bool? loop, - bool? muted, - String? preload, - String? src, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node audio({ + bool? autoplay, + bool? controls, + bool? loop, + bool? muted, + String? preload, + String? src, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'audio', _apply([ - p, - props + p ], { 'autoplay': autoplay, 'controls': controls, @@ -172,32 +156,29 @@ Node audio( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node b( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('b', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node b({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('b', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); -Node base( - {String? href, - String? target, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node base({ + String? href, + String? target, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'base', _apply([ - p, - props + p ], { 'href': href, 'target': target, @@ -206,86 +187,77 @@ Node base( 'style': style })); -Node bdi( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('bdi', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node bdi({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('bdi', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node bdo( - {String? dir, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node bdo({ + String? dir, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'bdo', - _apply([p, props], - {'dir': dir, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + _apply([p], {'dir': dir, 'id': id, 'class': className, 'style': style}), + [...c]); -Node blockquote( - {String? cite, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node blockquote({ + String? cite, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'blockquote', - _apply([p, props], - {'cite': cite, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + _apply( + [p], {'cite': cite, 'id': id, 'class': className, 'style': style}), + [...c]); -Node body( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'body', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node body({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('body', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); Node br() => SelfClosingNode('br'); -Node button( - {bool? autofocus, - bool? disabled, - form, - String? formaction, - String? formenctype, - String? formmethod, - bool? formnovalidate, - String? formtarget, - String? name, - String? type, - String? value, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node button({ + bool? autofocus, + bool? disabled, + form, + String? formaction, + String? formenctype, + String? formmethod, + bool? formnovalidate, + String? formtarget, + String? name, + String? type, + String? value, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'button', _apply([ - p, - props + p ], { 'autofocus': autofocus, 'disabled': disabled, @@ -302,23 +274,21 @@ Node button( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node canvas( - {num? height, - num? width, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node canvas({ + num? height, + num? width, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'canvas', _apply([ - p, - props + p ], { 'height': height, 'width': width, @@ -326,116 +296,99 @@ Node canvas( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node cite( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'cite', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node cite({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('cite', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node caption( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'caption', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node caption({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('caption', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node code( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'code', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node code({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('code', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node col( - {num? span, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node col({ + num? span, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'col', - _apply([p, props], - {'span': span, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + _apply( + [p], {'span': span, 'id': id, 'class': className, 'style': style}), + [...c]); -Node colgroup( - {num? span, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node colgroup({ + num? span, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'colgroup', - _apply([p, props], - {'span': span, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + _apply( + [p], {'span': span, 'id': id, 'class': className, 'style': style}), + [...c]); -Node datalist( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'datalist', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node datalist({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('datalist', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node dd( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('dd', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node dd({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('dd', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node del( - {String? cite, - String? datetime, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node del({ + String? cite, + String? datetime, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'del', _apply([ - p, - props + p ], { 'cite': cite, 'datetime': datetime, @@ -443,112 +396,104 @@ Node del( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node details( - {bool? open, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node details({ + bool? open, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'details', - _apply([p, props], - {'open': open, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + _apply( + [p], {'open': open, 'id': id, 'class': className, 'style': style}), + [...c]); -Node dfn( - {String? title, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node dfn({ + String? title, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'dfn', - _apply([p, props], + _apply([p], {'title': title, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + [...c]); -Node dialog( - {bool? open, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node dialog({ + bool? open, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'dialog', - _apply([p, props], - {'open': open, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + _apply( + [p], {'open': open, 'id': id, 'class': className, 'style': style}), + [...c]); -Node div( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('div', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node div({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('div', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node dl( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('dl', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node dl({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('dl', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node dt( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('dt', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node dt({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('dt', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node em( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('em', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node em({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('em', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node embed( - {num? height, - String? src, - String? type, - num? width, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node embed({ + num? height, + String? src, + String? type, + num? width, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'embed', _apply([ - p, - props + p ], { 'height': height, 'src': src, @@ -559,22 +504,20 @@ Node embed( 'style': style })); -Node fieldset( - {bool? disabled, - String? form, - String? name, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node fieldset({ + bool? disabled, + String? form, + String? name, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'fieldset', _apply([ - p, - props + p ], { 'disabled': disabled, 'form': form, @@ -583,69 +526,58 @@ Node fieldset( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node figcaption( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'figcaption', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node figcaption({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('figcaption', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node figure( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'figure', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node figure({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('figure', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node footer( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'footer', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node footer({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('footer', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node form( - {String? accept, - String? acceptCharset, - String? action, - bool? autocomplete, - String? enctype, - String? method, - String? name, - bool? novalidate, - String? target, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node form({ + String? accept, + String? acceptCharset, + String? action, + bool? autocomplete, + String? enctype, + String? method, + String? name, + bool? novalidate, + String? target, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'form', _apply([ - p, - props + p ], { 'accept': accept, 'accept-charset': acceptCharset, @@ -661,117 +593,103 @@ Node form( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node h1( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('h1', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node h1({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('h1', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node h2( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('h2', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); -Node h3( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('h3', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node h2({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('h2', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); +Node h3({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('h3', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node h4( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('h4', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node h4({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('h4', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node h5( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('h5', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node h5({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('h5', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node h6( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('h6', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node h6({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('h6', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node head( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'head', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node head({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('head', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node header( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'header', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node header({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('header', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); Node hr() => SelfClosingNode('hr'); -Node html( - {String? manifest, - String? xmlns, - String? lang, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node html({ + String? manifest, + String? xmlns, + String? lang, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'html', _apply([ - p, - props + p ], { 'manifest': manifest, 'xmlns': xmlns, @@ -780,36 +698,33 @@ Node html( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node i( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('i', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node i({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('i', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); -Node iframe( - {num? height, - String? name, - sandbox, - String? src, - String? srcdoc, - num? width, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node iframe({ + num? height, + String? name, + sandbox, + String? src, + String? srcdoc, + num? width, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'iframe', _apply([ - p, - props + p ], { 'height': height, 'name': name, @@ -822,27 +737,26 @@ Node iframe( 'style': style })); -Node img( - {String? alt, - String? crossorigin, - num? height, - String? ismap, - String? longdesc, - sizes, - String? src, - String? srcset, - String? usemap, - num? width, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node img({ + String? alt, + String? crossorigin, + num? height, + String? ismap, + String? longdesc, + sizes, + String? src, + String? srcset, + String? usemap, + num? width, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'img', _apply([ - p, - props + p ], { 'alt': alt, 'crossorigin': crossorigin, @@ -859,47 +773,46 @@ Node img( 'style': style })); -Node input( - {String? accept, - String? alt, - bool? autocomplete, - bool? autofocus, - bool? checked, - String? dirname, - bool? disabled, - String? form, - String? formaction, - String? formenctype, - String? method, - String? formnovalidate, - String? formtarget, - num? height, - String? list, - max, - num? maxlength, - min, - bool? multiple, - String? name, - String? pattern, - String? placeholder, - bool? readonly, - bool? required, - num? size, - String? src, - num? step, - String? type, - String? value, - num? width, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node input({ + String? accept, + String? alt, + bool? autocomplete, + bool? autofocus, + bool? checked, + String? dirname, + bool? disabled, + String? form, + String? formaction, + String? formenctype, + String? method, + String? formnovalidate, + String? formtarget, + num? height, + String? list, + max, + num? maxlength, + min, + bool? multiple, + String? name, + String? pattern, + String? placeholder, + bool? readonly, + bool? required, + num? size, + String? src, + num? step, + String? type, + String? value, + num? width, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'input', _apply([ - p, - props + p ], { 'accept': accept, 'alt': alt, @@ -937,21 +850,19 @@ Node input( 'style': style })); -Node ins( - {String? cite, - String? datetime, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node ins({ + String? cite, + String? datetime, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'ins', _apply([ - p, - props + p ], { 'cite': cite, 'datetime': datetime, @@ -959,38 +870,35 @@ Node ins( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node kbd( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('kbd', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node kbd({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('kbd', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node keygen( - {bool? autofocus, - String? challenge, - bool? disabled, - String? from, - String? keytype, - String? name, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node keygen({ + bool? autofocus, + String? challenge, + bool? disabled, + String? from, + String? keytype, + String? name, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'keygen', _apply([ - p, - props + p ], { 'autofocus': autofocus, 'challenge': challenge, @@ -1002,23 +910,21 @@ Node keygen( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node label( - {String? for_, - String? form, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node label({ + String? for_, + String? form, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'label', _apply([ - p, - props + p ], { 'for': for_, 'form': form, @@ -1026,55 +932,50 @@ Node label( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node legend( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'legend', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node legend({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('legend', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node li( - {num? value, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node li({ + num? value, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'li', - _apply([p, props], + _apply([p], {'value': value, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + [...c]); -Node link( - {String? crossorigin, - String? href, - String? hreflang, - String? media, - String? rel, - sizes, - String? target, - String? type, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node link({ + String? crossorigin, + String? href, + String? hreflang, + String? media, + String? rel, + sizes, + String? target, + String? type, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'link', _apply([ - p, - props + p ], { 'crossorigin': crossorigin, 'href': href, @@ -1089,62 +990,53 @@ Node link( 'style': style })); -Node main( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'main', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node main({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('main', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node map( - {String? name, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node map({ + String? name, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'map', - _apply([p, props], - {'name': name, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + _apply( + [p], {'name': name, 'id': id, 'class': className, 'style': style}), + [...c]); -Node mark( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'mark', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node mark({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('mark', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node menu( - {String? label, - String? type, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node menu({ + String? label, + String? type, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'menu', _apply([ - p, - props + p ], { 'label': label, 'type': type, @@ -1152,29 +1044,27 @@ Node menu( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node menuitem( - {bool? checked, - command, - bool? default_, - bool? disabled, - String? icon, - String? label, - String? radiogroup, - String? type, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node menuitem({ + bool? checked, + command, + bool? default_, + bool? disabled, + String? icon, + String? label, + String? radiogroup, + String? type, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'menuitem', _apply([ - p, - props + p ], { 'checked': checked, 'command': command, @@ -1188,23 +1078,22 @@ Node menuitem( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node meta( - {String? charset, - String? content, - String? httpEquiv, - String? name, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node meta({ + String? charset, + String? content, + String? httpEquiv, + String? name, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'meta', _apply([ - p, - props + p ], { 'charset': charset, 'content': content, @@ -1215,50 +1104,44 @@ Node meta( 'style': style })); -Node nav( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('nav', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node nav({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('nav', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node noscript( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'noscript', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node noscript({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('noscript', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node object( - {String? data, - String? form, - num? height, - String? name, - String? type, - String? usemap, - num? width, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node object({ + String? data, + String? form, + num? height, + String? name, + String? type, + String? usemap, + num? width, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'object', _apply([ - p, - props + p ], { 'data': data, 'form': form, @@ -1271,24 +1154,22 @@ Node object( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node ol( - {bool? reversed, - num? start, - String? type, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node ol({ + bool? reversed, + num? start, + String? type, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'ol', _apply([ - p, - props + p ], { 'reversed': reversed, 'start': start, @@ -1297,23 +1178,21 @@ Node ol( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node optgroup( - {bool? disabled, - String? label, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node optgroup({ + bool? disabled, + String? label, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'optgroup', _apply([ - p, - props + p ], { 'disabled': disabled, 'label': label, @@ -1321,25 +1200,23 @@ Node optgroup( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node option( - {bool? disabled, - String? label, - bool? selected, - String? value, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node option({ + bool? disabled, + String? label, + bool? selected, + String? value, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'option', _apply([ - p, - props + p ], { 'disabled': disabled, 'label': label, @@ -1349,24 +1226,22 @@ Node option( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node output( - {String? for_, - String? form, - String? name, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node output({ + String? for_, + String? form, + String? name, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'output', _apply([ - p, - props + p ], { 'for': for_, 'form': form, @@ -1375,32 +1250,29 @@ Node output( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node p( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('p', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node p({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('p', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); -Node param( - {String? name, - value, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node param({ + String? name, + value, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'param', _apply([ - p, - props + p ], { 'name': name, 'value': value, @@ -1409,45 +1281,39 @@ Node param( 'style': style })); -Node picture( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'picture', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node picture({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('picture', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node pre( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('pre', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node pre({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('pre', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node progress( - {num? max, - num? value, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node progress({ + num? max, + num? value, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'progress', _apply([ - p, - props + p ], { 'max': max, 'value': value, @@ -1455,100 +1321,87 @@ Node progress( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node q( - {String? cite, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node q({ + String? cite, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'q', - _apply([p, props], - {'cite': cite, 'id': id, 'class': className, 'style': style}), - [...c, ...children]); + _apply( + [p], {'cite': cite, 'id': id, 'class': className, 'style': style}), + [...c]); -Node rp( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('rp', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node rp({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('rp', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node rt( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('rt', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node rt({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('rt', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node ruby( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'ruby', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node ruby({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('ruby', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node s( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('s', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node s({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('s', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); -Node samp( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'samp', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node samp({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('samp', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node script( - {bool? async, - String? charset, - bool? defer, - String? src, - String? type, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node script({ + bool? async, + String? charset, + bool? defer, + String? src, + String? type, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'script', _apply([ - p, - props + p ], { 'async': async, 'charset': charset, @@ -1559,40 +1412,35 @@ Node script( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node section( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'section', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node section({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('section', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node select( - {bool? autofocus, - bool? disabled, - String? form, - bool? multiple, - bool? required, - num? size, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node select({ + bool? autofocus, + bool? disabled, + String? form, + bool? multiple, + bool? required, + num? size, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'select', _apply([ - p, - props + p ], { 'autofocus': autofocus, 'disabled': disabled, @@ -1604,37 +1452,33 @@ Node select( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node small( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'small', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node small({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('small', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node source( - {String? src, - String? srcset, - String? media, - sizes, - String? type, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node source({ + String? src, + String? srcset, + String? media, + sizes, + String? type, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'source', _apply([ - p, - props + p ], { 'src': src, 'srcset': srcset, @@ -1646,133 +1490,113 @@ Node source( 'style': style })); -Node span( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'span', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node span({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('span', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node strong( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'strong', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node strong({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('strong', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node style( - {String? media, - bool? scoped, - String? type, - String? id, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node style({ + String? media, + bool? scoped, + String? type, + String? id, + Map p = const {}, + Iterable c = const [], +}) => h( 'style', - _apply([p, props], - {'media': media, 'scoped': scoped, 'type': type, 'id': id}), - [...c, ...children]); + _apply([p], {'media': media, 'scoped': scoped, 'type': type, 'id': id}), + [...c]); -Node sub( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('sub', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node sub({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('sub', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node summary( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'summary', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node summary({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('summary', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node sup( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('sup', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node sup({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('sup', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node table( - {bool? sortable, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node table({ + bool? sortable, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'table', _apply([ - p, - props + p ], { 'sortable': sortable, 'id': id, 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node tbody( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'tbody', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node tbody({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('tbody', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node td( - {num? colspan, - headers, - num? rowspan, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node td({ + num? colspan, + headers, + num? rowspan, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'td', _apply([ - p, - props + p ], { 'colspan': colspan, 'headers': headers, @@ -1781,33 +1605,31 @@ Node td( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node textarea( - {bool? autofocus, - num? cols, - String? dirname, - bool? disabled, - String? form, - num? maxlength, - String? name, - String? placeholder, - bool? readonly, - bool? required, - num? rows, - String? wrap, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node textarea({ + bool? autofocus, + num? cols, + String? dirname, + bool? disabled, + String? form, + num? maxlength, + String? name, + String? placeholder, + bool? readonly, + bool? required, + num? rows, + String? wrap, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'textarea', _apply([ - p, - props + p ], { 'autofocus': autofocus, 'cols': cols, @@ -1825,40 +1647,35 @@ Node textarea( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node tfoot( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'tfoot', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node tfoot({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('tfoot', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node th( - {String? abbr, - num? colspan, - headers, - num? rowspan, - String? scope, - sorted, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node th({ + String? abbr, + num? colspan, + headers, + num? rowspan, + String? scope, + sorted, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'th', _apply([ - p, - props + p ], { 'abbr': abbr, 'colspan': colspan, @@ -1870,83 +1687,73 @@ Node th( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node thead( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'thead', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node thead({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('thead', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node time( - {String? datetime, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node time({ + String? datetime, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'time', _apply([ - p, - props + p ], { 'datetime': datetime, 'id': id, 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node title( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h( - 'title', - _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node title({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('title', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node tr( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('tr', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node tr({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('tr', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node track( - {bool? default_, - String? kind, - String? label, - String? src, - String? srclang, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}}) => +Node track({ + bool? default_, + String? kind, + String? label, + String? src, + String? srclang, + String? id, + className, + style, + Map p = const {}, +}) => SelfClosingNode( 'track', _apply([ - p, - props + p ], { 'default': default_, 'kind': kind, @@ -1958,61 +1765,55 @@ Node track( 'style': style })); -Node u( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('u', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node u({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('u', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); -Node ul( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('ul', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node ul({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('ul', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node var_( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('var', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node var_({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('var', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); -Node video( - {bool? autoplay, - bool? controls, - num? height, - bool? loop, - bool? muted, - String? poster, - String? preload, - String? src, - num? width, - String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => +Node video({ + bool? autoplay, + bool? controls, + num? height, + bool? loop, + bool? muted, + String? poster, + String? preload, + String? src, + num? width, + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => h( 'video', _apply([ - p, - props + p ], { 'autoplay': autoplay, 'controls': controls, @@ -2027,15 +1828,14 @@ Node video( 'class': className, 'style': style }), - [...c, ...children]); + [...c]); -Node wbr( - {String? id, - className, - style, - Map p = const {}, - @deprecated Map props = const {}, - Iterable c = const [], - @deprecated Iterable children = const []}) => - h('wbr', _apply([p, props], {'id': id, 'class': className, 'style': style}), - [...c, ...children]); +Node wbr({ + String? id, + className, + style, + Map p = const {}, + Iterable c = const [], +}) => + h('wbr', _apply([p], {'id': id, 'class': className, 'style': style}), + [...c]); diff --git a/packages/html_builder/lib/src/node.dart b/packages/html_builder/lib/src/node.dart index ec32488b..b547077e 100644 --- a/packages/html_builder/lib/src/node.dart +++ b/packages/html_builder/lib/src/node.dart @@ -15,7 +15,9 @@ class Node { Node(this.tagName, [Map attributes = const {}, Iterable children = const []]) { - this..attributes.addAll(attributes)..children.addAll(children); + this + ..attributes.addAll(attributes) + ..children.addAll(children); } Node._selfClosing(this.tagName, @@ -35,16 +37,18 @@ class Node { /// Represents a self-closing tag, i.e. `
`. class SelfClosingNode extends Node { + /* @override final String tagName; @override final Map attributes = {}; + */ @override List get children => List.unmodifiable([]); - SelfClosingNode(this.tagName, [Map attributes = const {}]) + SelfClosingNode(tagName, [Map attributes = const {}]) : super._selfClosing(tagName, attributes); } diff --git a/packages/html_builder/pubspec.yaml b/packages/html_builder/pubspec.yaml index a9ec87ed..8b31a293 100644 --- a/packages/html_builder/pubspec.yaml +++ b/packages/html_builder/pubspec.yaml @@ -1,6 +1,6 @@ name: angel3_html_builder description: Build HTML AST's and render them to HTML. This can be used as an internal DSL, i.e. for a templating engine. -version: 2.0.3 +version: 2.0.4 homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/html_builder environment: sdk: '>=2.12.0 <3.0.0' @@ -9,4 +9,4 @@ dependencies: dev_dependencies: html: ^0.15.0 test: ^1.17.4 - pedantic: ^1.11.0 \ No newline at end of file + lints: ^1.0.1 From d09d08caad1b5201521f1fe2703456c14646c22e Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 11 Sep 2021 12:03:14 +0800 Subject: [PATCH 05/22] Updated angel3_html --- packages/html/.gitignore | 58 ------------------- packages/html/CHANGELOG.md | 10 +++- packages/html/LICENSE | 42 ++++++++------ packages/html/README.md | 33 ++++++----- packages/html/analysis_options.yaml | 5 +- packages/html/example/main.dart | 8 +-- .../lib/{angel_html.dart => angel3_html.dart} | 9 +-- packages/html/pubspec.yaml | 26 +++------ packages/html/test/all_test.dart | 10 ++-- packages/html_builder/analysis_options.yaml | 6 +- 10 files changed, 73 insertions(+), 134 deletions(-) delete mode 100644 packages/html/.gitignore rename packages/html/lib/{angel_html.dart => angel3_html.dart} (78%) diff --git a/packages/html/.gitignore b/packages/html/.gitignore deleted file mode 100644 index fe4c4cfa..00000000 --- a/packages/html/.gitignore +++ /dev/null @@ -1,58 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.packages -.pub/ -build/ -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries - -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -/out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties - -.dart_tool \ No newline at end of file diff --git a/packages/html/CHANGELOG.md b/packages/html/CHANGELOG.md index 3857adbb..43ec6378 100644 --- a/packages/html/CHANGELOG.md +++ b/packages/html/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/html/LICENSE b/packages/html/LICENSE index 3de28325..df5e0635 100644 --- a/packages/html/LICENSE +++ b/packages/html/LICENSE @@ -1,21 +1,29 @@ -MIT License +BSD 3-Clause License -Copyright (c) 2017 Tobe O +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/html/README.md b/packages/html/README.md index cdf92e78..273b8280 100644 --- a/packages/html/README.md +++ b/packages/html/README.md @@ -1,16 +1,17 @@ -# html -[![Pub](https://img.shields.io/pub/v/angel_html.svg)](https://pub.dartlang.org/packages/angel_html) -[![build status](https://travis-ci.org/angel-dart/html.svg)](https://travis-ci.org/angel-dart/html) +# Angel3 HTML -A plug-in that allows you to return html_builder AST's from request handlers, and have them sent as HTML automatically. +[![version](https://img.shields.io/badge/pub-v3.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_html) +[![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) -[`package:html_builder`](https://github.com/thosakwe/html_builder) is a simple virtual DOM library -(without diffing, you can find that -[here](https://github.com/thosakwe/html_builder_vdom)), with a handy Dart DSL that makes it easy to build HTML -AST's: +[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/html/LICENSE) + +A plug-in that allows you to return `belatuk_html_builder` AST's from request handlers, and have them sent as HTML automatically. + +[`package:belatuk_html_builder`](https://pub.dev/packages/belatuk_html_builder) is a simple virtual DOM library with a handy Dart DSL that makes it easy to build HTML AST's: ```dart -import 'package:html_builder/elements.dart'; +import 'package:belatuk_html_builder/elements.dart'; Node myDom = html(lang: 'en', c: [ head(c: [ @@ -28,19 +29,21 @@ Node myDom = html(lang: 'en', c: [ ``` This plug-in means that you can now `return` these AST's, and Angel will automatically send them to -clients. Ultimately, the implication is that you can use `html_builder` as a substitute for a -templating system within Dart. With [hot reloading](https://github.com/angel-dart/hot), you won't +clients. Ultimately, the implication is that you can use `belatuk_html_builder` as a substitute for a +templating system within Dart. With [hot reloading](https://pub.dev/packages/angel3_hot), you won't even need to reload your server (as it should be). -# Installation +## Installation + In your `pubspec.yaml`: ```yaml dependencies: - angel_html: ^1.0.0 + angel3_html: ^3.0.0 ``` -# Usage +## Usage + The `renderHtml` function does all the magic for you. ```dart @@ -80,4 +83,4 @@ configureServer(Angel app) async { // ... } -``` \ No newline at end of file +``` diff --git a/packages/html/analysis_options.yaml b/packages/html/analysis_options.yaml index c230cee7..ea2c9e94 100644 --- a/packages/html/analysis_options.yaml +++ b/packages/html/analysis_options.yaml @@ -1,4 +1 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/html/example/main.dart b/packages/html/example/main.dart index a322cf39..3e9d3f60 100644 --- a/packages/html/example/main.dart +++ b/packages/html/example/main.dart @@ -1,7 +1,7 @@ -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_framework/http.dart'; -import 'package:angel_html/angel_html.dart'; -import 'package:html_builder/elements.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_framework/http.dart'; +import 'package:angel3_html/angel3_html.dart'; +import 'package:belatuk_html_builder/elements.dart'; import 'package:logging/logging.dart'; void main() async { diff --git a/packages/html/lib/angel_html.dart b/packages/html/lib/angel3_html.dart similarity index 78% rename from packages/html/lib/angel_html.dart rename to packages/html/lib/angel3_html.dart index 2393adb1..f72506d4 100644 --- a/packages/html/lib/angel_html.dart +++ b/packages/html/lib/angel3_html.dart @@ -1,13 +1,14 @@ import 'dart:async'; -import 'package:angel_framework/angel_framework.dart'; -import 'package:html_builder/html_builder.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:belatuk_html_builder/belatuk_html_builder.dart'; /// Returns a [RequestMiddleware] that allows you to return `html_builder` [Node]s as responses. /// /// You can provide a custom [renderer]. The default renders minified HTML5 pages. /// /// Set [enforceAcceptHeader] to `true` to throw a `406 Not Acceptable` if the client doesn't accept HTML responses. -RequestHandler renderHtml({StringRenderer? renderer, bool? enforceAcceptHeader}) { +RequestHandler renderHtml( + {StringRenderer? renderer, bool? enforceAcceptHeader}) { renderer ??= StringRenderer(pretty: false, html5: true); return (RequestContext req, ResponseContext res) { @@ -15,7 +16,7 @@ RequestHandler renderHtml({StringRenderer? renderer, bool? enforceAcceptHeader}) res.serializer = (data) { if (data is! Node) { - return oldSerializer!(data); + return oldSerializer(data); } else { if (enforceAcceptHeader == true && !req.accepts('text/html')) { throw AngelHttpException.notAcceptable(); diff --git a/packages/html/pubspec.yaml b/packages/html/pubspec.yaml index 1ef34ad1..ec7e0246 100644 --- a/packages/html/pubspec.yaml +++ b/packages/html/pubspec.yaml @@ -1,28 +1,16 @@ -name: angel_html +name: angel3_html version: 3.0.0 description: Support for rendering html_builder AST's as responses in Angel. -homepage: https://github.com/angel-dart/html_builder -publish_to: none +homepage: https://angel3-framework.web.app/ +repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/html_builder 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 - html_builder: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/html_builder + angel3_framework: ^4.0.0 + belatuk_html_builder: ^3.0.0 dev_dependencies: - angel_test: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/test + angel3_test: ^4.0.0 html: ^0.15.0 logging: ^1.0.1 test: ^1.17.0 - pedantic: ^1.11.0 \ No newline at end of file + lints: ^1.0.0 \ No newline at end of file diff --git a/packages/html/test/all_test.dart b/packages/html/test/all_test.dart index ba2d05d4..585c05a5 100644 --- a/packages/html/test/all_test.dart +++ b/packages/html/test/all_test.dart @@ -1,8 +1,8 @@ -import 'package:angel_framework/angel_framework.dart'; -import 'package:angel_html/angel_html.dart'; -import 'package:angel_test/angel_test.dart'; -import 'package:html_builder/elements.dart'; -import 'package:html_builder/html_builder.dart'; +import 'package:angel3_framework/angel3_framework.dart'; +import 'package:angel3_html/angel3_html.dart'; +import 'package:angel3_test/angel3_test.dart'; +import 'package:belatuk_html_builder/elements.dart'; +import 'package:belatuk_html_builder/belatuk_html_builder.dart'; import 'package:test/test.dart'; void main() { diff --git a/packages/html_builder/analysis_options.yaml b/packages/html_builder/analysis_options.yaml index c5667a80..ea2c9e94 100644 --- a/packages/html_builder/analysis_options.yaml +++ b/packages/html_builder/analysis_options.yaml @@ -1,5 +1 @@ -include: package:pedantic/analysis_options.yaml - -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file From e88219da70abeec37a6c1b34f9263b95fc0f7265 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 11 Sep 2021 14:37:53 +0800 Subject: [PATCH 06/22] Updated serialize_generator --- packages/serialize/.gitignore | 23 ---------- .../angel_serialize_generator/CHANGELOG.md | 6 +++ .../angel_serialize_generator/LICENSE | 42 +++++++++++-------- .../angel_serialize_generator/README.md | 4 +- .../analysis_options.yaml | 9 +--- .../angel_serialize_generator/build.yaml | 2 +- .../lib/serialize.dart | 27 ++++++++---- .../angel_serialize_generator/pubspec.yaml | 4 +- 8 files changed, 56 insertions(+), 61 deletions(-) delete mode 100644 packages/serialize/.gitignore diff --git a/packages/serialize/.gitignore b/packages/serialize/.gitignore deleted file mode 100644 index ae3d0ab0..00000000 --- a/packages/serialize/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -# Created by .ignore support plugin (hsz.mobi) -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml -.idea/**/gradle.xml -.idea/**/libraries -.idea/**/mongoSettings.xml -*.iws -/out/ -.idea_modules/ -atlassian-ide-plugin.xml -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties -.dart_tool \ No newline at end of file diff --git a/packages/serialize/angel_serialize_generator/CHANGELOG.md b/packages/serialize/angel_serialize_generator/CHANGELOG.md index 023606f5..f23030fc 100644 --- a/packages/serialize/angel_serialize_generator/CHANGELOG.md +++ b/packages/serialize/angel_serialize_generator/CHANGELOG.md @@ -1,5 +1,11 @@ # Change Log +## 4.2.0 + +* Fixed `toMap` method generation for non nullable Map +* Fixed `fromMap` method generation for non nullable Map +* Upgraded from `pendantic` to `lints` linter + ## 4.1.2 * Fixed `toMap` method generation diff --git a/packages/serialize/angel_serialize_generator/LICENSE b/packages/serialize/angel_serialize_generator/LICENSE index 8f65b579..df5e0635 100644 --- a/packages/serialize/angel_serialize_generator/LICENSE +++ b/packages/serialize/angel_serialize_generator/LICENSE @@ -1,21 +1,29 @@ -MIT License (MIT) +BSD 3-Clause License -Copyright (c) 2021 dukefirehawk.com +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/serialize/angel_serialize_generator/README.md b/packages/serialize/angel_serialize_generator/README.md index d3987cc4..03303f1a 100644 --- a/packages/serialize/angel_serialize_generator/README.md +++ b/packages/serialize/angel_serialize_generator/README.md @@ -1,6 +1,6 @@ # Angel3 Serialize Generator -[![version](https://img.shields.io/badge/pub-v4.1.2-brightgreen)](https://pub.dartlang.org/packages/angel3_serialize_generator) +[![version](https://img.shields.io/badge/pub-v4.2.0-brightgreen)](https://pub.dartlang.org/packages/angel3_serialize_generator) [![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) @@ -8,4 +8,4 @@ The builder for Angel3 model serialization. -Find documentation in the main project repo: +Find documentation in the main [serialize project repo](https://github.com/dukefirehawk/angel/tree/master/packages/serialize) diff --git a/packages/serialize/angel_serialize_generator/analysis_options.yaml b/packages/serialize/angel_serialize_generator/analysis_options.yaml index dd372bfa..ea2c9e94 100644 --- a/packages/serialize/angel_serialize_generator/analysis_options.yaml +++ b/packages/serialize/angel_serialize_generator/analysis_options.yaml @@ -1,8 +1 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false -linter: - rules: - - unnecessary_new - - unnecessary_const \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/serialize/angel_serialize_generator/build.yaml b/packages/serialize/angel_serialize_generator/build.yaml index d15efe53..6648010b 100644 --- a/packages/serialize/angel_serialize_generator/build.yaml +++ b/packages/serialize/angel_serialize_generator/build.yaml @@ -31,7 +31,7 @@ builders: # - "test/models/with_enum.dart" # $default: # dependencies: -# - "angel_serialize_generator:_book" +# - "angel3_serialize_generator:_book" # sources: # - "test/models/author.dart" # - "test/models/game_pad.dart" diff --git a/packages/serialize/angel_serialize_generator/lib/serialize.dart b/packages/serialize/angel_serialize_generator/lib/serialize.dart index 60e89182..0e3b589f 100644 --- a/packages/serialize/angel_serialize_generator/lib/serialize.dart +++ b/packages/serialize/angel_serialize_generator/lib/serialize.dart @@ -180,8 +180,7 @@ class ${pascal}Decoder extends Converter { // Serialize model classes via `XSerializer.toMap` else if (isModelClass(type)) { var rc = ReCase(type.getDisplayString(withNullability: true)); - serializedRepresentation = - '${serializerToMap(rc, 'model.${field.name}')}'; + serializedRepresentation = serializerToMap(rc, 'model.${field.name}'); } else if (type is InterfaceType) { if (isListOfModelType(type)) { var name = @@ -201,8 +200,8 @@ class ${pascal}Decoder extends Converter { var rc = ReCase( type.typeArguments[1].getDisplayString(withNullability: true)); serializedRepresentation = - '''model.${field.name}.keys?.fold({}, (map, key) { - return map..[key] = + '''model.${field.name}.keys.fold({}, (map, key) { + return (map as Map?)?..[key] = ${serializerToMap(rc, 'model.${field.name}[key]')}; })'''; } else if (type.element.isEnum) { @@ -270,11 +269,19 @@ class ${pascal}Decoder extends Converter { ctx.requiredFields.forEach((key, msg) { if (ctx.excluded[key]?.canDeserialize == false) return; var name = ctx.resolveFieldName(key); - buf.writeln(''' - if (map['$name'] == null) { - throw FormatException("$msg"); + if (msg.contains("'")) { + buf.writeln(''' + if (map['$name'] == null) { + throw FormatException("$msg"); + } + '''); + } else { + buf.writeln(''' + if (map['$name'] == null) { + throw FormatException('$msg'); + } + '''); } - '''); }); buf.writeln('return ${ctx.modelClassName}('); @@ -348,6 +355,10 @@ class ${pascal}Decoder extends Converter { ' : $defaultValue'; } else if (isMapToModelType(type)) { // TODO: This requires refractoring + if (defaultValue == 'null') { + defaultValue = '{}'; + } + var rc = ReCase( type.typeArguments[1].getDisplayString(withNullability: true)); deserializedRepresentation = ''' diff --git a/packages/serialize/angel_serialize_generator/pubspec.yaml b/packages/serialize/angel_serialize_generator/pubspec.yaml index 53322ff7..afda443b 100644 --- a/packages/serialize/angel_serialize_generator/pubspec.yaml +++ b/packages/serialize/angel_serialize_generator/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_serialize_generator -version: 4.1.2 +version: 4.2.0 description: Angel3 model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/serialize/angel_serialize_generator @@ -22,5 +22,5 @@ dependencies: dev_dependencies: build_runner: ^2.0.1 collection: ^1.15.0 - pedantic: ^1.11.0 + lints: ^1.0.0 test: ^1.17.4 From 715051e4161ed0299f7387e5ae3f800cd14d05df Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 11 Sep 2021 18:53:01 +0800 Subject: [PATCH 07/22] Updated README --- packages/html_builder/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/html_builder/CHANGELOG.md b/packages/html_builder/CHANGELOG.md index 412c3403..cc1b46ce 100644 --- a/packages/html_builder/CHANGELOG.md +++ b/packages/html_builder/CHANGELOG.md @@ -4,6 +4,7 @@ * Upgraded from `pendantic` to `lints` linter * Removed deprecated parameters +* Final release. Replaced by `belatuk_html_builder` package. ## 2.0.3 From 507e1a3710a1a83f46232ef5d6ef94b54affbc40 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sat, 11 Sep 2021 18:54:02 +0800 Subject: [PATCH 08/22] Cleanup --- packages/html_builder/.gitignore | 71 -------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 packages/html_builder/.gitignore diff --git a/packages/html_builder/.gitignore b/packages/html_builder/.gitignore deleted file mode 100644 index 24d68312..00000000 --- a/packages/html_builder/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.dart_tool -.packages -.pub/ -build/ - -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# SDK 1.20 and later (no longer creates packages directories) - -# Older SDK versions -# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) -.project -.buildlog -**/packages/ - - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: - -## VsCode -.vscode/ - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -.idea/ -/out/ -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties From 3b42fcae469673a7a0e18f3ec0f5354b9ca30c03 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 10:34:20 +0800 Subject: [PATCH 09/22] Moved to belatuk repository --- CHANGELOG.md | 16 + packages/code_buffer/.gitignore | 71 ---- packages/code_buffer/.travis.yml | 1 - packages/code_buffer/AUTHORS.md | 12 - packages/code_buffer/CHANGELOG.md | 11 - packages/code_buffer/LICENSE | 21 - packages/code_buffer/README.md | 66 --- packages/code_buffer/analysis_options.yaml | 4 - packages/code_buffer/example/main.dart | 46 -- .../code_buffer/lib/angel3_code_buffer.dart | 231 ---------- packages/code_buffer/pubspec.yaml | 12 - packages/code_buffer/test/copy_test.dart | 45 -- packages/code_buffer/test/span_test.dart | 44 -- packages/code_buffer/test/write_test.dart | 87 ---- packages/combinator/.gitignore | 71 ---- packages/combinator/.travis.yml | 4 - packages/combinator/AUTHORS.md | 12 - packages/combinator/CHANGELOG.md | 20 - packages/combinator/LICENSE | 21 - packages/combinator/README.md | 123 ------ packages/combinator/analysis_options.yaml | 5 - packages/combinator/combinator.iml | 14 - packages/combinator/example/basic_auth.dart | 56 --- packages/combinator/example/calculator.dart | 71 ---- packages/combinator/example/delimiter.dart | 29 -- packages/combinator/example/json.dart | 71 ---- packages/combinator/example/main.dart | 38 -- packages/combinator/example/query_string.dart | 45 -- packages/combinator/example/sexp.dart | 85 ---- packages/combinator/example/tuple.dart | 14 - .../combinator/lib/angel3_combinator.dart | 2 - .../lib/src/combinator/advance.dart | 26 -- .../combinator/lib/src/combinator/any.dart | 85 ---- .../combinator/lib/src/combinator/cache.dart | 26 -- .../combinator/lib/src/combinator/cast.dart | 63 --- .../combinator/lib/src/combinator/chain.dart | 111 ----- .../combinator/lib/src/combinator/check.dart | 42 -- .../lib/src/combinator/combinator.dart | 394 ------------------ .../lib/src/combinator/compare.dart | 38 -- .../lib/src/combinator/fold_errors.dart | 29 -- .../combinator/lib/src/combinator/index.dart | 52 --- .../lib/src/combinator/longest.dart | 115 ----- .../combinator/lib/src/combinator/map.dart | 56 --- .../combinator/lib/src/combinator/match.dart | 41 -- .../lib/src/combinator/max_depth.dart | 28 -- .../combinator/lib/src/combinator/negate.dart | 51 --- .../combinator/lib/src/combinator/opt.dart | 57 --- .../lib/src/combinator/recursion.dart | 142 ------- .../combinator/lib/src/combinator/reduce.dart | 46 -- .../lib/src/combinator/reference.dart | 44 -- .../combinator/lib/src/combinator/repeat.dart | 89 ---- .../combinator/lib/src/combinator/safe.dart | 47 --- .../lib/src/combinator/to_list.dart | 41 -- .../combinator/lib/src/combinator/util.dart | 57 --- .../combinator/lib/src/combinator/value.dart | 25 -- packages/combinator/lib/src/error.dart | 23 - packages/combinator/pubspec.yaml | 15 - packages/combinator/test/all.dart | 12 - packages/combinator/test/common.dart | 3 - packages/combinator/test/list_test.dart | 22 - packages/combinator/test/match_test.dart | 16 - packages/combinator/test/misc_test.dart | 66 --- packages/combinator/test/recursion_test.dart | 53 --- packages/combinator/test/value_test.dart | 15 - packages/pub_sub/.gitignore | 71 ---- packages/user_agent/user_agent/.gitignore | 25 -- packages/user_agent/user_agent/.travis.yml | 1 - packages/user_agent/user_agent/AUTHORS.md | 12 - packages/user_agent/user_agent/CHANGELOG.md | 17 - packages/user_agent/user_agent/LICENSE | 21 - packages/user_agent/user_agent/LICENSE.orig | 25 -- packages/user_agent/user_agent/README.md | 27 +- .../user_agent/analysis_options.yaml | 4 - .../user_agent/example/example.dart | 7 - .../user_agent/lib/user_agent_analyzer.dart | 235 ----------- packages/user_agent/user_agent/pubspec.yaml | 9 - .../user_agent/test/user_agent_test.dart | 30 -- 77 files changed, 17 insertions(+), 3745 deletions(-) delete mode 100644 packages/code_buffer/.gitignore delete mode 100644 packages/code_buffer/.travis.yml delete mode 100644 packages/code_buffer/AUTHORS.md delete mode 100644 packages/code_buffer/CHANGELOG.md delete mode 100644 packages/code_buffer/LICENSE delete mode 100644 packages/code_buffer/README.md delete mode 100644 packages/code_buffer/analysis_options.yaml delete mode 100644 packages/code_buffer/example/main.dart delete mode 100644 packages/code_buffer/lib/angel3_code_buffer.dart delete mode 100644 packages/code_buffer/pubspec.yaml delete mode 100644 packages/code_buffer/test/copy_test.dart delete mode 100644 packages/code_buffer/test/span_test.dart delete mode 100644 packages/code_buffer/test/write_test.dart delete mode 100644 packages/combinator/.gitignore delete mode 100644 packages/combinator/.travis.yml delete mode 100644 packages/combinator/AUTHORS.md delete mode 100644 packages/combinator/CHANGELOG.md delete mode 100644 packages/combinator/LICENSE delete mode 100644 packages/combinator/README.md delete mode 100644 packages/combinator/analysis_options.yaml delete mode 100644 packages/combinator/combinator.iml delete mode 100644 packages/combinator/example/basic_auth.dart delete mode 100644 packages/combinator/example/calculator.dart delete mode 100644 packages/combinator/example/delimiter.dart delete mode 100644 packages/combinator/example/json.dart delete mode 100644 packages/combinator/example/main.dart delete mode 100644 packages/combinator/example/query_string.dart delete mode 100644 packages/combinator/example/sexp.dart delete mode 100644 packages/combinator/example/tuple.dart delete mode 100644 packages/combinator/lib/angel3_combinator.dart delete mode 100644 packages/combinator/lib/src/combinator/advance.dart delete mode 100644 packages/combinator/lib/src/combinator/any.dart delete mode 100644 packages/combinator/lib/src/combinator/cache.dart delete mode 100644 packages/combinator/lib/src/combinator/cast.dart delete mode 100644 packages/combinator/lib/src/combinator/chain.dart delete mode 100644 packages/combinator/lib/src/combinator/check.dart delete mode 100644 packages/combinator/lib/src/combinator/combinator.dart delete mode 100644 packages/combinator/lib/src/combinator/compare.dart delete mode 100644 packages/combinator/lib/src/combinator/fold_errors.dart delete mode 100644 packages/combinator/lib/src/combinator/index.dart delete mode 100644 packages/combinator/lib/src/combinator/longest.dart delete mode 100644 packages/combinator/lib/src/combinator/map.dart delete mode 100644 packages/combinator/lib/src/combinator/match.dart delete mode 100644 packages/combinator/lib/src/combinator/max_depth.dart delete mode 100644 packages/combinator/lib/src/combinator/negate.dart delete mode 100644 packages/combinator/lib/src/combinator/opt.dart delete mode 100644 packages/combinator/lib/src/combinator/recursion.dart delete mode 100644 packages/combinator/lib/src/combinator/reduce.dart delete mode 100644 packages/combinator/lib/src/combinator/reference.dart delete mode 100644 packages/combinator/lib/src/combinator/repeat.dart delete mode 100644 packages/combinator/lib/src/combinator/safe.dart delete mode 100644 packages/combinator/lib/src/combinator/to_list.dart delete mode 100644 packages/combinator/lib/src/combinator/util.dart delete mode 100644 packages/combinator/lib/src/combinator/value.dart delete mode 100644 packages/combinator/lib/src/error.dart delete mode 100644 packages/combinator/pubspec.yaml delete mode 100644 packages/combinator/test/all.dart delete mode 100644 packages/combinator/test/common.dart delete mode 100644 packages/combinator/test/list_test.dart delete mode 100644 packages/combinator/test/match_test.dart delete mode 100644 packages/combinator/test/misc_test.dart delete mode 100644 packages/combinator/test/recursion_test.dart delete mode 100644 packages/combinator/test/value_test.dart delete mode 100644 packages/pub_sub/.gitignore delete mode 100644 packages/user_agent/user_agent/.gitignore delete mode 100644 packages/user_agent/user_agent/.travis.yml delete mode 100644 packages/user_agent/user_agent/AUTHORS.md delete mode 100644 packages/user_agent/user_agent/CHANGELOG.md delete mode 100644 packages/user_agent/user_agent/LICENSE delete mode 100644 packages/user_agent/user_agent/LICENSE.orig delete mode 100644 packages/user_agent/user_agent/analysis_options.yaml delete mode 100644 packages/user_agent/user_agent/example/example.dart delete mode 100644 packages/user_agent/user_agent/lib/user_agent_analyzer.dart delete mode 100644 packages/user_agent/user_agent/pubspec.yaml delete mode 100644 packages/user_agent/user_agent/test/user_agent_test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index 56d989ba..58a0be02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,21 @@ # Change Log +## 4.2.0 + +* Refactored the framework internal to use [Belatuk Common Utilities]() +* Updated [examples] () +* Updated to use `lints` linter + +## 4.1.0 + +* Updated [website] () +* Updated [examples] () +* Fixed ORM code generator +* Fixed Serializer code generator +* Fixed graphQL code generator +* Fixed CLI +* Fixed failed test cases + ## 4.0.0 (NNBD) * Published all packages with `angel3_` prefix diff --git a/packages/code_buffer/.gitignore b/packages/code_buffer/.gitignore deleted file mode 100644 index 24d68312..00000000 --- a/packages/code_buffer/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.dart_tool -.packages -.pub/ -build/ - -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# SDK 1.20 and later (no longer creates packages directories) - -# Older SDK versions -# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) -.project -.buildlog -**/packages/ - - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: - -## VsCode -.vscode/ - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -.idea/ -/out/ -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties diff --git a/packages/code_buffer/.travis.yml b/packages/code_buffer/.travis.yml deleted file mode 100644 index de2210c9..00000000 --- a/packages/code_buffer/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: dart \ No newline at end of file diff --git a/packages/code_buffer/AUTHORS.md b/packages/code_buffer/AUTHORS.md deleted file mode 100644 index ac95ab58..00000000 --- a/packages/code_buffer/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -Primary Authors -=============== - -* __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - - 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)__ - - Tobe has written much of the original code prior to NNBD migration. He has moved on and - is no longer involved with the project. diff --git a/packages/code_buffer/CHANGELOG.md b/packages/code_buffer/CHANGELOG.md deleted file mode 100644 index 468aa9a1..00000000 --- a/packages/code_buffer/CHANGELOG.md +++ /dev/null @@ -1,11 +0,0 @@ -# 2.0.3 -* Resolved static analysis warnings - -# 2.0.2 -* Updated README -# 2.0.1 -* Fixed invalid homepage url in pubspec.yaml -# 2.0.0 -* Migrated to support Dart SDK 2.12.x NNBD -# 1.0.1 -* Added `CodeBuffer.noWhitespace()`. \ No newline at end of file diff --git a/packages/code_buffer/LICENSE b/packages/code_buffer/LICENSE deleted file mode 100644 index 8f65b579..00000000 --- a/packages/code_buffer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License (MIT) - -Copyright (c) 2021 dukefirehawk.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/code_buffer/README.md b/packages/code_buffer/README.md deleted file mode 100644 index b9371bb5..00000000 --- a/packages/code_buffer/README.md +++ /dev/null @@ -1,66 +0,0 @@ -# angel3_code_buffer -[![version](https://img.shields.io/badge/pub-v2.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_code_buffer) -[![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/code_buffer/LICENSE) - -An advanced StringBuffer geared toward generating code, and source maps. - -# Installation -In your `pubspec.yaml`: - -```yaml -dependencies: - angel3_code_buffer: ^2.0.0 -``` - -# Usage -Use a `CodeBuffer` just like any regular `StringBuffer`: - -```dart -String someFunc() { - var buf = CodeBuffer(); - buf - ..write('hello ') - ..writeln('world!'); - return buf.toString(); -} -``` - -However, a `CodeBuffer` supports indentation. - -```dart -void someOtherFunc() { - var buf = CodeBuffer(); - // Custom options... - var buf = CodeBuffer(newline: '\r\n', space: '\t', trailingNewline: true); - - // Any following lines will have an incremented indentation level... - buf.indent(); - - // And vice-versa: - buf.outdent(); -} -``` - -`CodeBuffer` instances keep track of every `SourceSpan` they create. -This makes them useful for codegen tools, or to-JS compilers. - -```dart -void someFunc(CodeBuffer buf) { - buf.write('hello'); - expect(buf.lastLine.text, 'hello'); - - buf.writeln('world'); - expect(buf.lastLine.lastSpan.start.column, 5); -} -``` - -You can copy a `CodeBuffer` into another, heeding indentation rules: - -```dart -void yetAnotherFunc(CodeBuffer a, CodeBuffer b) { - b.copyInto(a); -} -``` \ No newline at end of file diff --git a/packages/code_buffer/analysis_options.yaml b/packages/code_buffer/analysis_options.yaml deleted file mode 100644 index c230cee7..00000000 --- a/packages/code_buffer/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file diff --git a/packages/code_buffer/example/main.dart b/packages/code_buffer/example/main.dart deleted file mode 100644 index 7d4463aa..00000000 --- a/packages/code_buffer/example/main.dart +++ /dev/null @@ -1,46 +0,0 @@ -import 'package:angel3_code_buffer/angel3_code_buffer.dart'; -import 'package:test/test.dart'; - -/// Use a `CodeBuffer` just like any regular `StringBuffer`: -String someFunc() { - var buf = CodeBuffer(); - buf - ..write('hello ') - ..writeln('world!'); - return buf.toString(); -} - -/// However, a `CodeBuffer` supports indentation. -void someOtherFunc() { - var buf = CodeBuffer(); - - // Custom options... - // ignore: unused_local_variable - var customBuf = - CodeBuffer(newline: '\r\n', space: '\t', trailingNewline: true); - - // Without whitespace.. - // ignore: unused_local_variable - var minifyingBuf = CodeBuffer.noWhitespace(); - - // Any following lines will have an incremented indentation level... - buf.indent(); - - // And vice-versa: - buf.outdent(); -} - -/// `CodeBuffer` instances keep track of every `SourceSpan` they create. -//This makes them useful for codegen tools, or to-JS compilers. -void yetAnotherOtherFunc(CodeBuffer buf) { - buf.write('hello'); - expect(buf.lastLine!.text, 'hello'); - - buf.writeln('world'); - expect(buf.lastLine!.lastSpan!.start.column, 5); -} - -/// You can copy a `CodeBuffer` into another, heeding indentation rules: -void yetEvenAnotherFunc(CodeBuffer a, CodeBuffer b) { - b.copyInto(a); -} diff --git a/packages/code_buffer/lib/angel3_code_buffer.dart b/packages/code_buffer/lib/angel3_code_buffer.dart deleted file mode 100644 index 4fd9bea6..00000000 --- a/packages/code_buffer/lib/angel3_code_buffer.dart +++ /dev/null @@ -1,231 +0,0 @@ -import 'package:source_span/source_span.dart'; - -/// An advanced StringBuffer geared toward generating code, and source maps. -class CodeBuffer implements StringBuffer { - /// The character sequence used to represent a line break. - final String newline; - - /// The character sequence used to represent a space/tab. - final String space; - - /// The source URL to be applied to all generated [SourceSpan] instances. - final sourceUrl; - - /// If `true` (default: `false`), then an additional [newline] will be inserted at the end of the generated string. - final bool trailingNewline; - - final List _lines = []; - CodeBufferLine? _currentLine, _lastLine; - int _indentationLevel = 0; - int _length = 0; - - CodeBuffer( - {this.space = ' ', - this.newline = '\n', - this.trailingNewline = false, - this.sourceUrl}); - - /// Creates a [CodeBuffer] that does not emit additional whitespace. - factory CodeBuffer.noWhitespace({sourceUrl}) => CodeBuffer( - space: '', newline: '', trailingNewline: false, sourceUrl: sourceUrl); - - /// The last line created within this buffer. - CodeBufferLine? get lastLine => _lastLine; - - /// Returns an immutable collection of the [CodeBufferLine]s within this instance. - List get lines => List.unmodifiable(_lines); - - @override - bool get isEmpty => _lines.isEmpty; - - @override - bool get isNotEmpty => _lines.isNotEmpty; - - @override - int get length => _length; - - CodeBufferLine _createLine() { - var start = SourceLocation( - _length, - sourceUrl: sourceUrl, - line: _lines.length, - column: _indentationLevel * space.length, - ); - var line = CodeBufferLine._(_indentationLevel, start).._end = start; - _lines.add(_lastLine = line); - return line; - } - - /// Increments the indentation level. - void indent() { - _indentationLevel++; - } - - /// Decrements the indentation level, if it is greater than `0`. - void outdent() { - if (_indentationLevel > 0) _indentationLevel--; - } - - /// Copies the contents of this [CodeBuffer] into another, preserving indentation and source mapping information. - void copyInto(CodeBuffer other) { - if (_lines.isEmpty) return; - var i = 0; - - for (var line in _lines) { - // To compute offset: - // 1. Find current length of other - // 2. Add length of its newline - // 3. Add indentation - var column = (other._indentationLevel + line.indentationLevel) * - other.space.length; - var offset = other._length + other.newline.length + column; - - // Re-compute start + end - var start = SourceLocation( - offset, - sourceUrl: other.sourceUrl, - line: other._lines.length + i, - column: column, - ); - - var end = SourceLocation( - offset + line.span.length, - sourceUrl: other.sourceUrl, - line: start.line, - column: column + line._buf.length, - ); - - var clone = CodeBufferLine._( - line.indentationLevel + other._indentationLevel, start) - .._end = end - .._buf.write(line._buf.toString()); - - // Adjust lastSpan - if (line._lastSpan != null) { - var s = line._lastSpan!.start; - var lastSpanColumn = - ((line.indentationLevel + other._indentationLevel) * - other.space.length) + - line.text.indexOf(line._lastSpan!.text); - clone._lastSpan = SourceSpan( - SourceLocation( - offset + s.offset, - sourceUrl: other.sourceUrl, - line: clone.span.start.line, - column: lastSpanColumn, - ), - SourceLocation( - offset + s.offset + line._lastSpan!.length, - sourceUrl: other.sourceUrl, - line: clone.span.end.line, - column: lastSpanColumn + line._lastSpan!.length, - ), - line._lastSpan!.text, - ); - } - - other._lines.add(other._currentLine = other._lastLine = clone); - - // Adjust length accordingly... - other._length = offset + clone.span.length; - i++; - } - - other.writeln(); - } - - @override - void clear() { - _lines.clear(); - _length = _indentationLevel = 0; - _currentLine = null; - } - - @override - void writeCharCode(int charCode) { - _currentLine ??= _createLine(); - - _currentLine!._buf.writeCharCode(charCode); - var end = _currentLine!._end; - _currentLine!._end = SourceLocation( - end.offset + 1, - sourceUrl: end.sourceUrl, - line: end.line, - column: end.column + 1, - ); - _length++; - _currentLine!._lastSpan = - SourceSpan(end, _currentLine!._end, String.fromCharCode(charCode)); - } - - @override - void write(Object? obj) { - var msg = obj.toString(); - _currentLine ??= _createLine(); - _currentLine!._buf.write(msg); - var end = _currentLine!._end; - _currentLine!._end = SourceLocation( - end.offset + msg.length, - sourceUrl: end.sourceUrl, - line: end.line, - column: end.column + msg.length, - ); - _length += msg.length; - _currentLine!._lastSpan = SourceSpan(end, _currentLine!._end, msg); - } - - @override - void writeln([Object? obj = '']) { - if (obj != null && obj != '') write(obj); - _currentLine = null; - _length++; - } - - @override - void writeAll(Iterable objects, [String separator = '']) { - write(objects.join(separator)); - } - - @override - String toString() { - var buf = StringBuffer(); - var i = 0; - - for (var line in lines) { - if (i++ > 0) buf.write(newline); - for (var j = 0; j < line.indentationLevel; j++) { - buf.write(space); - } - buf.write(line._buf.toString()); - } - - if (trailingNewline == true) buf.write(newline); - - return buf.toString(); - } -} - -/// Represents a line of text within a [CodeBuffer]. -class CodeBufferLine { - /// Mappings from one [SourceSpan] to another, to aid with generating dynamic source maps. - final Map sourceMappings = {}; - - /// The level of indentation preceding this line. - final int indentationLevel; - - final SourceLocation _start; - final StringBuffer _buf = StringBuffer(); - late SourceLocation _end; - SourceSpan? _lastSpan; - - CodeBufferLine._(this.indentationLevel, this._start); - - /// The [SourceSpan] corresponding to the last text written to this line. - SourceSpan? get lastSpan => _lastSpan; - - /// The [SourceSpan] corresponding to this entire line. - SourceSpan get span => SourceSpan(_start, _end, _buf.toString()); - - /// The text within this line. - String get text => _buf.toString(); -} diff --git a/packages/code_buffer/pubspec.yaml b/packages/code_buffer/pubspec.yaml deleted file mode 100644 index afef3105..00000000 --- a/packages/code_buffer/pubspec.yaml +++ /dev/null @@ -1,12 +0,0 @@ -name: angel3_code_buffer -version: 2.0.3 -description: An advanced StringBuffer geared toward generating code, and source maps. -homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/code_buffer -environment: - sdk: '>=2.12.0 <3.0.0' -dependencies: - charcode: ^1.2.0 - source_span: ^1.8.1 -dev_dependencies: - test: ^1.17.3 - pedantic: ^1.11.0 diff --git a/packages/code_buffer/test/copy_test.dart b/packages/code_buffer/test/copy_test.dart deleted file mode 100644 index 01f60420..00000000 --- a/packages/code_buffer/test/copy_test.dart +++ /dev/null @@ -1,45 +0,0 @@ -import 'package:angel3_code_buffer/angel3_code_buffer.dart'; -import 'package:test/test.dart'; - -void main() { - var a = CodeBuffer(), b = CodeBuffer(); - - setUp(() { - a.writeln('outer block 1'); - b..writeln('inner block 1')..writeln('inner block 2'); - b.copyInto(a..indent()); - a - ..outdent() - ..writeln('outer block 2'); - }); - - tearDown(() { - a.clear(); - b.clear(); - }); - - test('sets correct text', () { - expect( - a.toString(), - [ - 'outer block 1', - ' inner block 1', - ' inner block 2', - 'outer block 2', - ].join('\n')); - }); - - test('sets lastLine+lastSpan', () { - var c = CodeBuffer() - ..indent() - ..write('>') - ..writeln('innermost'); - c.copyInto(a); - expect(a.lastLine!.text, '>innermost'); - expect(a.lastLine!.span.start.column, 2); - expect(a.lastLine!.lastSpan!.start.line, 4); - expect(a.lastLine!.lastSpan!.start.column, 3); - expect(a.lastLine!.lastSpan!.end.line, 4); - expect(a.lastLine!.lastSpan!.end.column, 12); - }); -} diff --git a/packages/code_buffer/test/span_test.dart b/packages/code_buffer/test/span_test.dart deleted file mode 100644 index 61615ae8..00000000 --- a/packages/code_buffer/test/span_test.dart +++ /dev/null @@ -1,44 +0,0 @@ -import 'package:charcode/charcode.dart'; -import 'package:angel3_code_buffer/angel3_code_buffer.dart'; -import 'package:test/test.dart'; - -void main() { - var buf = CodeBuffer(); - tearDown(buf.clear); - - test('writeCharCode', () { - buf.writeCharCode($x); - expect(buf.lastLine!.lastSpan!.start.column, 0); - expect(buf.lastLine!.lastSpan!.start.line, 0); - expect(buf.lastLine!.lastSpan!.end.column, 1); - expect(buf.lastLine!.lastSpan!.end.line, 0); - }); - - test('write', () { - buf.write('foo'); - expect(buf.lastLine!.lastSpan!.start.column, 0); - expect(buf.lastLine!.lastSpan!.start.line, 0); - expect(buf.lastLine!.lastSpan!.end.column, 3); - expect(buf.lastLine!.lastSpan!.end.line, 0); - }); - - test('multiple writes in one line', () { - buf..write('foo')..write('baz'); - expect(buf.lastLine!.lastSpan!.start.column, 3); - expect(buf.lastLine!.lastSpan!.start.line, 0); - expect(buf.lastLine!.lastSpan!.end.column, 6); - expect(buf.lastLine!.lastSpan!.end.line, 0); - }); - - test('multiple lines', () { - buf - ..writeln('foo') - ..write('bar') - ..write('+') - ..writeln('baz'); - expect(buf.lastLine!.lastSpan!.start.column, 4); - expect(buf.lastLine!.lastSpan!.start.line, 1); - expect(buf.lastLine!.lastSpan!.end.column, 7); - expect(buf.lastLine!.lastSpan!.end.line, 1); - }); -} diff --git a/packages/code_buffer/test/write_test.dart b/packages/code_buffer/test/write_test.dart deleted file mode 100644 index b8b3ca9a..00000000 --- a/packages/code_buffer/test/write_test.dart +++ /dev/null @@ -1,87 +0,0 @@ -import 'package:charcode/charcode.dart'; -import 'package:test/test.dart'; -import 'package:angel3_code_buffer/angel3_code_buffer.dart'; - -void main() { - var buf = CodeBuffer(); - tearDown(buf.clear); - - test('writeCharCode', () { - buf.writeCharCode($x); - expect(buf.toString(), 'x'); - }); - - test('write', () { - buf.write('hello world'); - expect(buf.toString(), 'hello world'); - }); - - test('custom space', () { - var b = CodeBuffer(space: '+') - ..writeln('foo') - ..indent() - ..writeln('baz'); - expect(b.toString(), 'foo\n+baz'); - }); - - test('custom newline', () { - var b = CodeBuffer(newline: 'N') - ..writeln('foo') - ..indent() - ..writeln('baz'); - expect(b.toString(), 'fooN baz'); - }); - - test('trailing newline', () { - var b = CodeBuffer(trailingNewline: true)..writeln('foo'); - expect(b.toString(), 'foo\n'); - }); - - group('multiple lines', () { - setUp(() { - buf..writeln('foo')..writeln('bar')..writeln('baz'); - expect(buf.lines, hasLength(3)); - expect(buf.lines[0].text, 'foo'); - expect(buf.lines[1].text, 'bar'); - expect(buf.lines[2].text, 'baz'); - }); - }); - - test('indent', () { - buf - ..writeln('foo') - ..indent() - ..writeln('bar') - ..indent() - ..writeln('baz') - ..outdent() - ..writeln('quux') - ..outdent() - ..writeln('end'); - expect(buf.toString(), 'foo\n bar\n baz\n quux\nend'); - }); - - group('sets lastLine text', () { - test('writeCharCode', () { - buf.writeCharCode($x); - expect(buf.lastLine!.text, 'x'); - }); - - test('write', () { - buf.write('hello world'); - expect(buf.lastLine!.text, 'hello world'); - }); - }); - - group('sets lastLine lastSpan', () { - test('writeCharCode', () { - buf.writeCharCode($x); - expect(buf.lastLine!.lastSpan!.text, 'x'); - }); - - test('write', () { - buf.write('hello world'); - expect(buf.lastLine!.lastSpan!.text, 'hello world'); - }); - }); -} diff --git a/packages/combinator/.gitignore b/packages/combinator/.gitignore deleted file mode 100644 index 24d68312..00000000 --- a/packages/combinator/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.dart_tool -.packages -.pub/ -build/ - -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# SDK 1.20 and later (no longer creates packages directories) - -# Older SDK versions -# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) -.project -.buildlog -**/packages/ - - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: - -## VsCode -.vscode/ - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -.idea/ -/out/ -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties diff --git a/packages/combinator/.travis.yml b/packages/combinator/.travis.yml deleted file mode 100644 index 2f22c5ce..00000000 --- a/packages/combinator/.travis.yml +++ /dev/null @@ -1,4 +0,0 @@ -language: dart -dart: - - stable - - dev \ No newline at end of file diff --git a/packages/combinator/AUTHORS.md b/packages/combinator/AUTHORS.md deleted file mode 100644 index ac95ab58..00000000 --- a/packages/combinator/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -Primary Authors -=============== - -* __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - - 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)__ - - Tobe has written much of the original code prior to NNBD migration. He has moved on and - is no longer involved with the project. diff --git a/packages/combinator/CHANGELOG.md b/packages/combinator/CHANGELOG.md deleted file mode 100644 index cea07a47..00000000 --- a/packages/combinator/CHANGELOG.md +++ /dev/null @@ -1,20 +0,0 @@ -# 2.0.2 -* Resolve static analysis warnings - -# 2.0.1 -* Updated README - -# 2.0.0 -* Migrated to support Dart SDK 2.12.x NNBD - -# 1.1.0 -* Add `tupleX` parsers. Hooray for strong typing! - -# 1.0.0+3 -* `then` now *always* returns `dynamic`. - -# 1.0.0+2 -* `star` now includes with a call to `opt`. -* Added comments. -* Enforce generics on `separatedBy`. -* Enforce Dart 2 semantics. \ No newline at end of file diff --git a/packages/combinator/LICENSE b/packages/combinator/LICENSE deleted file mode 100644 index 8f65b579..00000000 --- a/packages/combinator/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License (MIT) - -Copyright (c) 2021 dukefirehawk.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/packages/combinator/README.md b/packages/combinator/README.md deleted file mode 100644 index 0c0e509e..00000000 --- a/packages/combinator/README.md +++ /dev/null @@ -1,123 +0,0 @@ -# angel3_combinator -[![version](https://img.shields.io/badge/pub-v2.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_combinator) -[![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/combinator/LICENSE) - -Packrat parser combinators that support static typing, generics, file spans, memoization, and more. - -**RECOMMENDED:** -Check `example/` for examples. -The examples contain examples of using: -* Generic typing -* Reading `FileSpan` from `ParseResult` -* More... - -## Basic Usage -```dart -void main() { - // Parse a Pattern (usually String or RegExp). - var foo = match('foo'); - var number = match(RegExp(r'[0-9]+'), errorMessage: 'Expected a number.'); - - // Set a value. - var numWithValue = number.map((r) => int.parse(r.span.text)); - - // Expect a pattern, or nothing. - var optional = numWithValue.opt(); - - // Expect a pattern zero or more times. - var star = optional.star(); - - // Expect one or more times. - var plus = optional.plus(); - - // Expect an arbitrary number of times. - var threeTimes = optional.times(3); - - // Expect a sequence of patterns. - var doraTheExplorer = chain([ - match('Dora').space(), - match('the').space(), - match('Explorer').space(), - ]); - - // Choose exactly one of a set of patterns, whichever - // appears first. - var alt = any([ - match('1'), - match('11'), - match('111'), - ]); - - // Choose the *longest* match for any of the given alternatives. - var alt2 = longest([ - match('1'), - match('11'), - match('111'), - ]); - - // Friendly operators - var fooOrNumber = foo | number; - var fooAndNumber = foo & number; - var notFoo = ~foo; -} -``` - -## Error Messages -Parsers without descriptive error messages can lead to frustrating dead-ends -for end-users. Fortunately, `angel3_combinator` is built with error handling in mind. - -```dart -void main(Parser parser) { - // Append an arbitrary error message to a parser if it is not matched. - var withError = parser.error(errorMessage: 'Hey!!! Wrong!!!'); - - // You can also set the severity of an error. - var asHint = parser.error(severity: SyntaxErrorSeverity.hint); - - // Constructs like `any`, `chain`, and `longest` support this as well. - var foo = longest([ - parser.error(errorMessage: 'foo'), - parser.error(errorMessage: 'bar') - ], errorMessage: 'Expected a "foo" or a "bar"'); - - // If multiple errors are present at one location, - // it can create a lot of noise. - // - // Use `foldErrors` to only take one error at a given location. - var lessNoise = parser.foldErrors(); -} -``` - -## Whitespaces -Handling optional whitespace is dead-easy: - -```dart -void main(Parser parser) { - var optionalSpace = parser.space(); -} -``` - -## For Programming Languages -`angel3_combinator` was conceived to make writing parsers for complex grammars easier, -namely programming languages. Thus, there are functions built-in to make common constructs -easier: - -```dart -void main(Parser parser) { - var array = parser - .separatedByComma() - .surroundedBySquareBrackets(defaultValue: []); - - var braces = parser.surroundedByCurlyBraces(); - - var sep = parser.separatedBy(match('!').space()); -} -``` - -## Differences between this and Petitparser -* `angel3_combinator` makes extensive use of Dart's dynamic typing -* `angel3_combinator` supports detailed error messages (with configurable severity) -* `angel3_combinator` keeps track of locations (ex. `line 1: 3`) \ No newline at end of file diff --git a/packages/combinator/analysis_options.yaml b/packages/combinator/analysis_options.yaml deleted file mode 100644 index 8dc465d4..00000000 --- a/packages/combinator/analysis_options.yaml +++ /dev/null @@ -1,5 +0,0 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false - #implicit-dynamic: false \ No newline at end of file diff --git a/packages/combinator/combinator.iml b/packages/combinator/combinator.iml deleted file mode 100644 index 75734c90..00000000 --- a/packages/combinator/combinator.iml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/combinator/example/basic_auth.dart b/packages/combinator/example/basic_auth.dart deleted file mode 100644 index 623be5c7..00000000 --- a/packages/combinator/example/basic_auth.dart +++ /dev/null @@ -1,56 +0,0 @@ -// Run this with "Basic QWxhZGRpbjpPcGVuU2VzYW1l" - -import 'dart:convert'; -import 'dart:io'; -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:string_scanner/string_scanner.dart'; - -/// Parse a part of a decoded Basic auth string. -/// -/// Namely, the `username` or `password` in `{username}:{password}`. -final Parser string = - match(RegExp(r'[^:$]+'), errorMessage: 'Expected a string.') - .value((r) => r.span!.text); - -/// Transforms `{username}:{password}` to `{"username": username, "password": password}`. -final Parser> credentials = chain([ - string.opt(), - match(':'), - string.opt(), -]).map>( - (r) => {'username': r.value![0], 'password': r.value![2]}); - -/// We can actually embed a parser within another parser. -/// -/// This is used here to BASE64URL-decode a string, and then -/// parse the decoded string. -final Parser credentialString = match?>( - RegExp(r'([^\n$]+)'), - errorMessage: 'Expected a credential string.') - .value((r) { - var decoded = utf8.decode(base64Url.decode(r.span!.text)); - var scanner = SpanScanner(decoded); - return credentials.parse(scanner).value; -}); - -final Parser basic = match('Basic').space(); - -final Parser basicAuth = basic.then(credentialString).index(1); - -void main() { - while (true) { - stdout.write('Enter a basic auth value: '); - var line = stdin.readLineSync()!; - var scanner = SpanScanner(line, sourceUrl: 'stdin'); - var result = basicAuth.parse(scanner); - - if (!result.successful) { - for (var error in result.errors) { - print(error.toolString); - print(error.span!.highlight(color: true)); - } - } else { - print(result.value); - } - } -} diff --git a/packages/combinator/example/calculator.dart b/packages/combinator/example/calculator.dart deleted file mode 100644 index 552bc744..00000000 --- a/packages/combinator/example/calculator.dart +++ /dev/null @@ -1,71 +0,0 @@ -import 'dart:math'; -import 'dart:io'; -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:string_scanner/string_scanner.dart'; - -/// Note: This grammar does not handle precedence, for the sake of simplicity. -Parser calculatorGrammar() { - var expr = reference(); - - var number = match(RegExp(r'-?[0-9]+(\.[0-9]+)?')) - .value((r) => num.parse(r.span!.text)); - - var hex = match(RegExp(r'0x([A-Fa-f0-9]+)')) - .map((r) => int.parse(r.scanner.lastMatch![1]!, radix: 16)); - - var binary = match(RegExp(r'([0-1]+)b')) - .map((r) => int.parse(r.scanner.lastMatch![1]!, radix: 2)); - - var alternatives = >[]; - - void registerBinary(String op, num Function(num, num) f) { - alternatives.add( - chain([ - expr.space(), - match(op).space() as Parser, - expr.space(), - ]).map((r) => f(r.value![0], r.value![2])), - ); - } - - registerBinary('**', (a, b) => pow(a, b)); - registerBinary('*', (a, b) => a * b); - registerBinary('/', (a, b) => a / b); - registerBinary('%', (a, b) => a % b); - registerBinary('+', (a, b) => a + b); - registerBinary('-', (a, b) => a - b); - registerBinary('^', (a, b) => a.toInt() ^ b.toInt()); - registerBinary('&', (a, b) => a.toInt() & b.toInt()); - registerBinary('|', (a, b) => a.toInt() | b.toInt()); - - alternatives.addAll([ - number, - hex, - binary, - expr.parenthesized(), - ]); - - expr.parser = longest(alternatives); - - return expr; -} - -void main() { - var calculator = calculatorGrammar(); - - while (true) { - stdout.write('Enter an expression: '); - var line = stdin.readLineSync()!; - var scanner = SpanScanner(line, sourceUrl: 'stdin'); - var result = calculator.parse(scanner); - - if (!result.successful) { - for (var error in result.errors) { - stderr.writeln(error.toolString); - stderr.writeln(error.span!.highlight(color: true)); - } - } else { - print(result.value); - } - } -} diff --git a/packages/combinator/example/delimiter.dart b/packages/combinator/example/delimiter.dart deleted file mode 100644 index 4571790c..00000000 --- a/packages/combinator/example/delimiter.dart +++ /dev/null @@ -1,29 +0,0 @@ -import 'dart:io'; -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:string_scanner/string_scanner.dart'; - -final Parser id = - match(RegExp(r'[A-Za-z]+')).value((r) => r.span!.text); - -// We can use `separatedBy` to easily construct parser -// that can be matched multiple times, separated by another -// pattern. -// -// This is useful for parsing arrays or map literals. -void main() { - while (true) { - stdout.write('Enter a string (ex "a,b,c"): '); - var line = stdin.readLineSync()!; - var scanner = SpanScanner(line, sourceUrl: 'stdin'); - var result = id.separatedBy(match(',').space()).parse(scanner); - - if (!result.successful) { - for (var error in result.errors) { - print(error.toolString); - print(error.span!.highlight(color: true)); - } - } else { - print(result.value); - } - } -} diff --git a/packages/combinator/example/json.dart b/packages/combinator/example/json.dart deleted file mode 100644 index caaba890..00000000 --- a/packages/combinator/example/json.dart +++ /dev/null @@ -1,71 +0,0 @@ -import 'dart:io'; -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:string_scanner/string_scanner.dart'; - -Parser jsonGrammar() { - var expr = reference(); - - // Parse a number - var number = match(RegExp(r'-?[0-9]+(\.[0-9]+)?'), - errorMessage: 'Expected a number.') - .value( - (r) => num.parse(r.span!.text), - ); - - // Parse a string (no escapes supported, because lazy). - var string = - match(RegExp(r'"[^"]*"'), errorMessage: 'Expected a string.').value( - (r) => r.span!.text.substring(1, r.span!.text.length - 1), - ); - - // Parse an array - var array = expr - .space() - .separatedByComma() - .surroundedBySquareBrackets(defaultValue: []); - - // KV pair - var keyValuePair = chain([ - string.space(), - match(':').space(), - expr.error(errorMessage: 'Missing expression.'), - ]).castDynamic().cast().value((r) => {r.value![0]: r.value![2]}); - - // Parse an object. - var object = keyValuePair - .separatedByComma() - .castDynamic() - .surroundedByCurlyBraces(defaultValue: {}); - - expr.parser = longest( - [ - array, - number, - string, - object.error(), - ], - errorMessage: 'Expected an expression.', - ).space(); - - return expr.foldErrors(); -} - -void main() { - var JSON = jsonGrammar(); - - while (true) { - stdout.write('Enter some JSON: '); - var line = stdin.readLineSync()!; - var scanner = SpanScanner(line, sourceUrl: 'stdin'); - var result = JSON.parse(scanner); - - if (!result.successful) { - for (var error in result.errors) { - print(error.toolString); - print(error.span!.highlight(color: true)); - } - } else { - print(result.value); - } - } -} diff --git a/packages/combinator/example/main.dart b/packages/combinator/example/main.dart deleted file mode 100644 index 1ea328c6..00000000 --- a/packages/combinator/example/main.dart +++ /dev/null @@ -1,38 +0,0 @@ -import 'dart:io'; -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:string_scanner/string_scanner.dart'; - -final Parser minus = match('-'); - -final Parser digit = - match(RegExp(r'[0-9]'), errorMessage: 'Expected a number'); - -final Parser digits = digit.plus(); - -final Parser dot = match('.'); - -final Parser decimal = ( // digits, (dot, digits)? - digits & (dot & digits).opt() // - ); - -final Parser number = // - (minus.opt() & decimal) // minus?, decimal - .map((r) => num.parse(r.span!.text)); - -void main() { - while (true) { - stdout.write('Enter a number: '); - var line = stdin.readLineSync()!; - var scanner = SpanScanner(line, sourceUrl: 'stdin'); - var result = number.parse(scanner); - - if (!result.successful) { - for (var error in result.errors) { - stderr.writeln(error.toolString); - stderr.writeln(error.span!.highlight(color: true)); - } - } else { - print(result.value); - } - } -} diff --git a/packages/combinator/example/query_string.dart b/packages/combinator/example/query_string.dart deleted file mode 100644 index 4a42fff7..00000000 --- a/packages/combinator/example/query_string.dart +++ /dev/null @@ -1,45 +0,0 @@ -// For some reason, this cannot be run in checked mode??? - -import 'dart:io'; -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:string_scanner/string_scanner.dart'; - -final Parser key = - match(RegExp(r'[^=&\n]+'), errorMessage: 'Missing k/v') - .value((r) => r.span!.text); - -final Parser value = key.map((r) => Uri.decodeQueryComponent(r.value!)); - -final Parser pair = chain([ - key, - match('='), - value, -]).map((r) { - return { - r.value![0]: r.value![2], - }; -}); - -final Parser pairs = pair - .separatedBy(match(r'&')) - .map((r) => r.value!.reduce((a, b) => a..addAll(b))); - -final Parser queryString = pairs.opt(); - -void main() { - while (true) { - stdout.write('Enter a query string: '); - var line = stdin.readLineSync()!; - var scanner = SpanScanner(line, sourceUrl: 'stdin'); - var result = pairs.parse(scanner); - - if (!result.successful) { - for (var error in result.errors) { - print(error.toolString); - print(error.span!.highlight(color: true)); - } - } else { - print(result.value); - } - } -} diff --git a/packages/combinator/example/sexp.dart b/packages/combinator/example/sexp.dart deleted file mode 100644 index 9b51d626..00000000 --- a/packages/combinator/example/sexp.dart +++ /dev/null @@ -1,85 +0,0 @@ -import 'dart:collection'; -import 'dart:io'; -import 'dart:math'; -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:string_scanner/string_scanner.dart'; -import 'package:tuple/tuple.dart'; - -void main() { - var expr = reference(); - var symbols = {}; - - void registerFunction(String name, int nArgs, Function(List) f) { - symbols[name] = Tuple2(nArgs, f); - } - - registerFunction('**', 2, (args) => pow(args[0], args[1])); - registerFunction('*', 2, (args) => args[0] * args[1]); - registerFunction('/', 2, (args) => args[0] / args[1]); - registerFunction('%', 2, (args) => args[0] % args[1]); - registerFunction('+', 2, (args) => args[0] + args[1]); - registerFunction('-', 2, (args) => args[0] - args[1]); - registerFunction('.', 1, (args) => args[0].toDouble()); - registerFunction('print', 1, (args) { - print(args[0]); - return args[0]; - }); - - var number = - match(RegExp(r'[0-9]+(\.[0-9]+)?'), errorMessage: 'Expected a number.') - .map((r) => num.parse(r.span!.text)); - - var id = match( - RegExp( - r'[A-Za-z_!\\$",\\+-\\./:;\\?<>%&\\*@\[\]\\{\}\\|`\\^~][A-Za-z0-9_!\\$",\\+-\\./:;\\?<>%&\*@\[\]\\{\}\\|`\\^~]*'), - errorMessage: 'Expected an ID') - .map((r) => symbols[r.span!.text] ??= - throw "Undefined symbol: '${r.span!.text}'"); - - var atom = number.castDynamic().or(id); - - var list = expr.space().times(2, exact: false).map((r) { - try { - var out = []; - var q = Queue.from(r.value!.reversed); - - while (q.isNotEmpty) { - var current = q.removeFirst(); - if (current is! Tuple2) { - out.insert(0, current); - } else { - var args = []; - for (var i = 0; i < (current.item1 as num); i++) { - args.add(out.removeLast()); - } - out.add(current.item2(args)); - } - } - - return out.length == 1 ? out.first : out; - } catch (_) { - return []; - } - }); - - expr.parser = longest([ - list, - atom, - expr.parenthesized(), - ]); //list | atom | expr.parenthesized(); - - while (true) { - stdout.write('> '); - var line = stdin.readLineSync()!; - var result = expr.parse(SpanScanner(line)); - - if (result.errors.isNotEmpty) { - for (var error in result.errors) { - print(error.toolString); - print(error.message); - } - } else { - print(result.value); - } - } -} diff --git a/packages/combinator/example/tuple.dart b/packages/combinator/example/tuple.dart deleted file mode 100644 index 188ced83..00000000 --- a/packages/combinator/example/tuple.dart +++ /dev/null @@ -1,14 +0,0 @@ -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:string_scanner/string_scanner.dart'; - -void main() { - var pub = match('pub').map((r) => r.span!.text).space(); - var dart = match('dart').map((r) => 24).space(); - var lang = match('lang').map((r) => true).space(); - - // Parses a Tuple3 - var grammar = tuple3(pub, dart, lang); - - var scanner = SpanScanner('pub dart lang'); - print(grammar.parse(scanner).value); -} diff --git a/packages/combinator/lib/angel3_combinator.dart b/packages/combinator/lib/angel3_combinator.dart deleted file mode 100644 index 79e4c074..00000000 --- a/packages/combinator/lib/angel3_combinator.dart +++ /dev/null @@ -1,2 +0,0 @@ -export 'src/combinator/combinator.dart'; -export 'src/error.dart'; diff --git a/packages/combinator/lib/src/combinator/advance.dart b/packages/combinator/lib/src/combinator/advance.dart deleted file mode 100644 index 01506dc2..00000000 --- a/packages/combinator/lib/src/combinator/advance.dart +++ /dev/null @@ -1,26 +0,0 @@ -part of lex.src.combinator; - -class _Advance extends Parser { - final Parser parser; - final int amount; - - _Advance(this.parser, this.amount); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()).change(parser: this); - if (result.successful) args.scanner.position += amount; - return result; - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('advance($amount) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/any.dart b/packages/combinator/lib/src/combinator/any.dart deleted file mode 100644 index 45bc107a..00000000 --- a/packages/combinator/lib/src/combinator/any.dart +++ /dev/null @@ -1,85 +0,0 @@ -part of lex.src.combinator; - -/// Matches any one of the given [parsers]. -/// -/// If [backtrack] is `true` (default), a failed parse will not modify the scanner state. -/// -/// You can provide a custom [errorMessage]. You can set it to `false` to not -/// generate any error at all. -Parser any(Iterable> parsers, - {bool backtrack = true, errorMessage, SyntaxErrorSeverity? severity}) { - return _Any(parsers, backtrack != false, errorMessage, - severity ?? SyntaxErrorSeverity.error); -} - -class _Any extends Parser { - final Iterable> parsers; - final bool backtrack; - final errorMessage; - final SyntaxErrorSeverity severity; - - _Any(this.parsers, this.backtrack, this.errorMessage, this.severity); - - @override - ParseResult _parse(ParseArgs args) { - var inactive = parsers - .where((p) => !args.trampoline.isActive(p, args.scanner.position)); - - if (inactive.isEmpty) { - return ParseResult(args.trampoline, args.scanner, this, false, []); - } - - var errors = []; - var replay = args.scanner.position; - - for (var parser in inactive) { - var result = parser._parse(args.increaseDepth()); - - if (result.successful) { - return result; - } else { - if (backtrack) args.scanner.position = replay; - if (parser is _Alt) errors.addAll(result.errors); - } - } - - if (errorMessage != false) { - errors.add( - SyntaxError( - severity, - errorMessage?.toString() ?? - 'No match found for ${parsers.length} alternative(s)', - args.scanner.emptySpan, - ), - ); - } - - return ParseResult(args.trampoline, args.scanner, this, false, errors); - } - - @override - ParseResult __parse(ParseArgs args) { - // Never called - throw ArgumentError('[Combinator] Invalid method call'); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('any(${parsers.length}) (') - ..indent(); - var i = 1; - - for (var parser in parsers) { - buffer - ..writeln('#${i++}:') - ..indent(); - parser.stringify(buffer); - buffer.outdent(); - } - - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/cache.dart b/packages/combinator/lib/src/combinator/cache.dart deleted file mode 100644 index b07b38e0..00000000 --- a/packages/combinator/lib/src/combinator/cache.dart +++ /dev/null @@ -1,26 +0,0 @@ -part of lex.src.combinator; - -class _Cache extends Parser { - final Map> _cache = {}; - final Parser parser; - - _Cache(this.parser); - - @override - ParseResult __parse(ParseArgs args) { - return _cache.putIfAbsent(args.scanner.position, () { - return parser._parse(args.increaseDepth()); - }).change(parser: this); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('cache(${_cache.length}) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/cast.dart b/packages/combinator/lib/src/combinator/cast.dart deleted file mode 100644 index 9b531d43..00000000 --- a/packages/combinator/lib/src/combinator/cast.dart +++ /dev/null @@ -1,63 +0,0 @@ -part of lex.src.combinator; - -class _Cast extends Parser { - final Parser parser; - - _Cast(this.parser); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()); - return ParseResult( - args.trampoline, - args.scanner, - this, - result.successful, - result.errors, - span: result.span, - value: result.value as U?, - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('cast<$U> (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} - -class _CastDynamic extends Parser { - final Parser parser; - - _CastDynamic(this.parser); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()); - return ParseResult( - args.trampoline, - args.scanner, - this, - result.successful, - result.errors, - span: result.span, - value: result.value, - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('cast (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/chain.dart b/packages/combinator/lib/src/combinator/chain.dart deleted file mode 100644 index 101836b4..00000000 --- a/packages/combinator/lib/src/combinator/chain.dart +++ /dev/null @@ -1,111 +0,0 @@ -part of lex.src.combinator; - -/// Expects to parse a sequence of [parsers]. -/// -/// If [failFast] is `true` (default), then the first failure to parse will abort the parse. -ListParser chain(Iterable> parsers, - {bool failFast = true, SyntaxErrorSeverity? severity}) { - return _Chain( - parsers, failFast != false, severity ?? SyntaxErrorSeverity.error); -} - -class _Alt extends Parser { - final Parser parser; - final String? errorMessage; - final SyntaxErrorSeverity severity; - - _Alt(this.parser, this.errorMessage, this.severity); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()); - return result.successful - ? result - : result.addErrors([ - SyntaxError( - severity, errorMessage, result.span ?? args.scanner.emptySpan), - ]); - } - - @override - void stringify(CodeBuffer buffer) { - parser.stringify(buffer); - } -} - -class _Chain extends ListParser { - final Iterable> parsers; - final bool failFast; - final SyntaxErrorSeverity severity; - - _Chain(this.parsers, this.failFast, this.severity); - - @override - ParseResult> __parse(ParseArgs args) { - var errors = []; - var results = []; - var spans = []; - var successful = true; - - for (var parser in parsers) { - var result = parser._parse(args.increaseDepth()); - - if (!result.successful) { - if (parser is _Alt) errors.addAll(result.errors); - - if (failFast) { - return ParseResult( - args.trampoline, args.scanner, this, false, result.errors); - } - - successful = false; - } - - if (result.value != null) { - results.add(result.value!); - } else { - results.add('NULL' as T); - } - - if (result.span != null) { - spans.add(result.span!); - } - } - - FileSpan? span; - - if (spans.isNotEmpty) { - span = spans.reduce((a, b) => a.expand(b)); - } - - return ParseResult>( - args.trampoline, - args.scanner, - this, - successful, - errors, - span: span, - value: List.unmodifiable(results), - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('chain(${parsers.length}) (') - ..indent(); - var i = 1; - - for (var parser in parsers) { - buffer - ..writeln('#${i++}:') - ..indent(); - parser.stringify(buffer); - buffer.outdent(); - } - - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/check.dart b/packages/combinator/lib/src/combinator/check.dart deleted file mode 100644 index a6f7bedc..00000000 --- a/packages/combinator/lib/src/combinator/check.dart +++ /dev/null @@ -1,42 +0,0 @@ -part of lex.src.combinator; - -class _Check extends Parser { - final Parser parser; - final Matcher matcher; - final String? errorMessage; - final SyntaxErrorSeverity severity; - - _Check(this.parser, this.matcher, this.errorMessage, this.severity); - - @override - ParseResult __parse(ParseArgs args) { - var matchState = {}; - var result = parser._parse(args.increaseDepth()).change(parser: this); - if (!result.successful) { - return result; - } else if (!matcher.matches(result.value, matchState)) { - return result.change(successful: false).addErrors([ - SyntaxError( - severity, - errorMessage ?? - matcher.describe(StringDescription('Expected ')).toString() + '.', - result.span, - ), - ]); - } else { - return result; - } - } - - @override - void stringify(CodeBuffer buffer) { - var d = matcher.describe(StringDescription()); - buffer - ..writeln('check($d) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/combinator.dart b/packages/combinator/lib/src/combinator/combinator.dart deleted file mode 100644 index 717365ab..00000000 --- a/packages/combinator/lib/src/combinator/combinator.dart +++ /dev/null @@ -1,394 +0,0 @@ -library lex.src.combinator; - -import 'dart:collection'; - -import 'package:angel3_code_buffer/angel3_code_buffer.dart'; -import 'package:matcher/matcher.dart'; -import 'package:source_span/source_span.dart'; -import 'package:string_scanner/string_scanner.dart'; -import 'package:tuple/tuple.dart'; -import '../error.dart'; - -part 'any.dart'; - -part 'advance.dart'; - -part 'cache.dart'; - -part 'cast.dart'; - -part 'chain.dart'; - -part 'check.dart'; - -part 'compare.dart'; - -part 'fold_errors.dart'; - -part 'index.dart'; - -part 'longest.dart'; - -part 'map.dart'; - -part 'match.dart'; - -part 'max_depth.dart'; - -part 'negate.dart'; - -part 'opt.dart'; - -part 'recursion.dart'; - -part 'reduce.dart'; - -part 'reference.dart'; - -part 'repeat.dart'; - -part 'safe.dart'; - -part 'to_list.dart'; - -part 'util.dart'; - -part 'value.dart'; - -class ParseArgs { - final Trampoline trampoline; - final SpanScanner scanner; - final int depth; - - ParseArgs(this.trampoline, this.scanner, this.depth); - - ParseArgs increaseDepth() => ParseArgs(trampoline, scanner, depth + 1); -} - -/// A parser combinator, which can parse very complicated grammars in a manageable manner. -abstract class Parser { - ParseResult __parse(ParseArgs args); - - ParseResult _parse(ParseArgs args) { - var pos = args.scanner.position; - - if (args.trampoline.hasMemoized(this, pos)) { - return args.trampoline.getMemoized(this, pos); - } - - if (args.trampoline.isActive(this, pos)) { - return ParseResult(args.trampoline, args.scanner, this, false, []); - } - - args.trampoline.enter(this, pos); - var result = __parse(args); - args.trampoline.memoize(this, pos, result); - args.trampoline.exit(this); - return result; - } - - /// Parses text from a [SpanScanner]. - ParseResult parse(SpanScanner scanner, [int depth = 1]) { - var args = ParseArgs(Trampoline(), scanner, depth); - return _parse(args); - } - - /// Skips forward a certain amount of steps after parsing, if it was successful. - Parser forward(int amount) => _Advance(this, amount); - - /// Moves backward a certain amount of steps after parsing, if it was successful. - Parser back(int amount) => _Advance(this, amount * -1); - - /// Casts this parser to produce [U] objects. - Parser cast() => _Cast(this); - - /// Casts this parser to produce [dynamic] objects. - Parser castDynamic() => _CastDynamic(this); - - /// Runs the given function, which changes the returned [ParseResult] into one relating to a [U] object. - Parser change(ParseResult Function(ParseResult) f) { - return _Change(this, f); - } - - /// Validates the parse result against a [Matcher]. - /// - /// You can provide a custom [errorMessage]. - Parser check(Matcher matcher, - {String? errorMessage, SyntaxErrorSeverity? severity}) => - _Check( - this, matcher, errorMessage, severity ?? SyntaxErrorSeverity.error); - - /// Binds an [errorMessage] to a copy of this parser. - Parser error({String? errorMessage, SyntaxErrorSeverity? severity}) => - _Alt(this, errorMessage, severity ?? SyntaxErrorSeverity.error); - - /// Removes multiple errors that occur in the same spot; this can reduce noise in parser output. - Parser foldErrors({bool Function(SyntaxError a, SyntaxError b)? equal}) { - equal ??= (b, e) => b.span?.start.offset == e.span?.start.offset; - return _FoldErrors(this, equal); - } - - /// Transforms the parse result using a unary function. - Parser map(U Function(ParseResult) f) { - return _Map(this, f); - } - - /// Prevents recursion past a certain [depth], preventing stack overflow errors. - Parser maxDepth(int depth) => _MaxDepth(this, depth); - - Parser operator ~() => negate(); - - /// Ensures this pattern is not matched. - /// - /// You can provide an [errorMessage]. - Parser negate( - {String errorMessage = 'Negate error', - SyntaxErrorSeverity severity = SyntaxErrorSeverity.error}) => - _Negate(this, errorMessage, severity); - - /// Caches the results of parse attempts at various locations within the source text. - /// - /// Use this to prevent excessive recursion. - Parser cache() => _Cache(this); - - Parser operator &(Parser other) => and(other); - - /// Consumes `this` and another parser, but only considers the result of `this` parser. - Parser and(Parser other) => then(other).change((r) { - return ParseResult( - r.trampoline, - r.scanner, - this, - r.successful, - r.errors, - span: r.span, - value: (r.value != null ? r.value![0] : r.value) as T?, - ); - }); - - Parser operator |(Parser other) => or(other); - - /// Shortcut for [or]-ing two parsers. - Parser or(Parser other) => any([this, other]); - - /// Parses this sequence one or more times. - ListParser plus() => times(1, exact: false); - - /// Safely escapes this parser when an error occurs. - /// - /// The generated parser only runs once; repeated uses always exit eagerly. - Parser safe( - {bool backtrack = true, - String errorMessage = 'error', - SyntaxErrorSeverity? severity}) => - _Safe( - this, backtrack, errorMessage, severity ?? SyntaxErrorSeverity.error); - - Parser> separatedByComma() => - separatedBy(match>(',').space()); - - /// Expects to see an infinite amounts of the pattern, separated by the [other] pattern. - /// - /// Use this as a shortcut to parse arrays, parameter lists, etc. - Parser> separatedBy(Parser other) { - var suffix = other.then(this).index(1).cast(); - return then(suffix.star()).map((r) { - var v = r.value; - if (v == null || v.length < 2) { - return []; - } - var preceding = v.isEmpty ? [] : (v[0] == null ? [] : [v[0]]); - var out = List.from(preceding); - if (v[1] != null && v[1] != 'NULL') { - v[1].forEach((element) { - out.add(element as T); - }); - } - return out; - }); - } - - Parser surroundedByCurlyBraces({required T defaultValue}) => opt() - .surroundedBy(match('{').space(), match('}').space()) - .map((r) => r.value ?? defaultValue); - - Parser surroundedBySquareBrackets({required T defaultValue}) => opt() - .surroundedBy(match('[').space(), match(']').space()) - .map((r) => r.value ?? defaultValue); - - /// Expects to see the pattern, surrounded by the others. - /// - /// If no [right] is provided, it expects to see the same pattern on both sides. - /// Use this parse things like parenthesized expressions, arrays, etc. - Parser surroundedBy(Parser left, [Parser? right]) { - return chain([ - left, - this, - right ?? left, - ]).index(1).castDynamic().cast(); - } - - /// Parses `this`, either as-is or wrapped in parentheses. - Parser maybeParenthesized() { - return any([parenthesized(), this]); - } - - /// Parses `this`, wrapped in parentheses. - Parser parenthesized() => - surroundedBy(match('(').space(), match(')').space()); - - /// Consumes any trailing whitespace. - Parser space() => trail(RegExp(r'[ \n\r\t]+')); - - /// Consumes 0 or more instance(s) of this parser. - ListParser star({bool backtrack = true}) => - times(1, exact: false, backtrack: backtrack).opt(); - - /// Shortcut for [chain]-ing two parsers together. - ListParser then(Parser other) => chain([this, other]); - - /// Casts this instance into a [ListParser]. - ListParser toList() => _ToList(this); - - /// Consumes and ignores any trailing occurrences of [pattern]. - Parser trail(Pattern pattern) => - then(match(pattern).opt()).first().cast(); - - /// Expect this pattern a certain number of times. - /// - /// If [exact] is `false` (default: `true`), then the generated parser will accept - /// an infinite amount of occurrences after the specified [count]. - /// - /// You can provide custom error messages for when there are [tooFew] or [tooMany] occurrences. - ListParser times(int count, - {bool exact = true, - String tooFew = 'Too few', - String tooMany = 'Too many', - bool backtrack = true, - SyntaxErrorSeverity? severity}) { - return _Repeat(this, count, exact, tooFew, tooMany, backtrack, - severity ?? SyntaxErrorSeverity.error); - } - - /// Produces an optional copy of this parser. - /// - /// If [backtrack] is `true` (default), then a failed parse will not - /// modify the scanner state. - Parser opt({bool backtrack = true}) => _Opt(this, backtrack); - - /// Sets the value of the [ParseResult]. - Parser value(T Function(ParseResult) f) { - return _Value(this, f); - } - - /// Prints a representation of this parser, ideally without causing a stack overflow. - void stringify(CodeBuffer buffer); -} - -/// A [Parser] that produces [List]s of a type [T]. -abstract class ListParser extends Parser> { - /// Shortcut for calling [index] with `0`. - Parser first() => index(0); - - /// Modifies this parser to only return the value at the given index [i]. - Parser index(int i) => _Index(this, i); - - /// Shortcut for calling [index] with the greatest-possible index. - Parser last() => index(-1); - - /// Modifies this parser to call `List.reduce` on the parsed values. - Parser reduce(T Function(T, T) combine) => _Reduce(this, combine); - - /// Sorts the parsed values, using the given [Comparator]. - ListParser sort(Comparator compare) => _Compare(this, compare); - - @override - ListParser opt({bool backtrack = true}) => _ListOpt(this, backtrack); - - /// Modifies this parser, returning only the values that match a predicate. - Parser> where(bool Function(T) f) => - map>((r) => r.value?.where(f).toList() ?? []); - - /// Condenses a [ListParser] into having a value of the combined span's text. - Parser flatten() => map((r) => r.span?.text ?? ''); -} - -/// Prevents stack overflow in recursive parsers. -class Trampoline { - final Map> _active = {}; - final Map>> _memo = {}; - - bool hasMemoized(Parser parser, int position) { - var list = _memo[parser]; - return list?.any((t) => t.item1 == position) == true; - } - - ParseResult getMemoized(Parser parser, int position) { - return _memo[parser]?.firstWhere((t) => t.item1 == position).item2 - as ParseResult; - } - - void memoize(Parser parser, int position, ParseResult? result) { - if (result != null) { - var list = _memo.putIfAbsent(parser, () => []); - var tuple = Tuple2(position, result); - if (!list.contains(tuple)) list.add(tuple); - } - } - - bool isActive(Parser parser, int position) { - if (!_active.containsKey(parser)) { - return false; - } - var q = _active[parser]!; - if (q.isEmpty) return false; - //return q.contains(position); - return q.first == position; - } - - void enter(Parser parser, int position) { - _active.putIfAbsent(parser, () => Queue()).addFirst(position); - } - - void exit(Parser parser) { - if (_active.containsKey(parser)) _active[parser]?.removeFirst(); - } -} - -/// The result generated by a [Parser]. -class ParseResult { - final Parser parser; - final bool successful; - final Iterable errors; - final FileSpan? span; - final T? value; - final SpanScanner scanner; - final Trampoline trampoline; - - ParseResult( - this.trampoline, this.scanner, this.parser, this.successful, this.errors, - {this.span, this.value}); - - ParseResult change( - {Parser? parser, - bool? successful, - Iterable errors = const [], - FileSpan? span, - T? value}) { - return ParseResult( - trampoline, - scanner, - parser ?? this.parser, - successful ?? this.successful, - errors.isNotEmpty ? errors : this.errors, - span: span ?? this.span, - value: value ?? this.value, - ); - } - - ParseResult addErrors(Iterable errors) { - return change( - errors: List.from(this.errors)..addAll(errors), - ); - } -} diff --git a/packages/combinator/lib/src/combinator/compare.dart b/packages/combinator/lib/src/combinator/compare.dart deleted file mode 100644 index 3a5e36d5..00000000 --- a/packages/combinator/lib/src/combinator/compare.dart +++ /dev/null @@ -1,38 +0,0 @@ -part of lex.src.combinator; - -class _Compare extends ListParser { - final ListParser parser; - final Comparator compare; - - _Compare(this.parser, this.compare); - - @override - ParseResult> __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()); - if (!result.successful) return result; - - result = result.change( - value: result.value?.isNotEmpty == true ? result.value : []); - result = result.change(value: List.from(result.value!)); - return ParseResult>( - args.trampoline, - args.scanner, - this, - true, - [], - span: result.span, - value: result.value?..sort(compare), - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('sort($compare) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/fold_errors.dart b/packages/combinator/lib/src/combinator/fold_errors.dart deleted file mode 100644 index 6d15c69a..00000000 --- a/packages/combinator/lib/src/combinator/fold_errors.dart +++ /dev/null @@ -1,29 +0,0 @@ -part of lex.src.combinator; - -class _FoldErrors extends Parser { - final Parser parser; - final bool Function(SyntaxError, SyntaxError) equal; - - _FoldErrors(this.parser, this.equal); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()).change(parser: this); - var errors = result.errors.fold>([], (out, e) { - if (!out.any((b) => equal(e, b))) out.add(e); - return out; - }); - return result.change(errors: errors); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('fold errors (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/index.dart b/packages/combinator/lib/src/combinator/index.dart deleted file mode 100644 index 41d4460a..00000000 --- a/packages/combinator/lib/src/combinator/index.dart +++ /dev/null @@ -1,52 +0,0 @@ -part of lex.src.combinator; - -class _Index extends Parser { - final ListParser parser; - final int index; - - _Index(this.parser, this.index); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()); - Object? value; - - if (result.successful) { - var vList = result.value; - if (vList == null) { - throw ArgumentError('ParseResult is null'); - } - if (index == -1) { - value = vList.last; - } else { - if (index < vList.length) { -// print(">>>>Index: $index, Size: ${vList.length}"); -// value = -// index == -1 ? result.value!.last : result.value!.elementAt(index); - value = result.value!.elementAt(index); - } - } - } - - return ParseResult( - args.trampoline, - args.scanner, - this, - result.successful, - result.errors, - span: result.span, - value: value as T?, - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('index($index) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/longest.dart b/packages/combinator/lib/src/combinator/longest.dart deleted file mode 100644 index 36d9652e..00000000 --- a/packages/combinator/lib/src/combinator/longest.dart +++ /dev/null @@ -1,115 +0,0 @@ -part of lex.src.combinator; - -/// Matches any one of the given [parsers]. -/// -/// You can provide a custom [errorMessage]. -Parser longest(Iterable> parsers, - {Object? errorMessage, SyntaxErrorSeverity? severity}) { - return _Longest(parsers, errorMessage, severity ?? SyntaxErrorSeverity.error); -} - -class _Longest extends Parser { - final Iterable> parsers; - final Object? errorMessage; - final SyntaxErrorSeverity severity; - - _Longest(this.parsers, this.errorMessage, this.severity); - - @override - ParseResult _parse(ParseArgs args) { - var inactive = parsers - .toList() - .where((p) => !args.trampoline.isActive(p, args.scanner.position)); - - if (inactive.isEmpty) { - return ParseResult(args.trampoline, args.scanner, this, false, []); - } - - var replay = args.scanner.position; - var errors = []; - var results = >[]; - - for (var parser in inactive) { - var result = parser._parse(args.increaseDepth()); - - if (result.successful && result.span != null) { - results.add(result); - } else if (parser is _Alt) errors.addAll(result.errors); - - args.scanner.position = replay; - } - - if (results.isNotEmpty) { - results.sort((a, b) => b.span!.length.compareTo(a.span!.length)); - args.scanner.scan(results.first.span!.text); - return results.first; - } - - if (errorMessage != false) { - errors.add( - SyntaxError( - severity, - errorMessage?.toString() ?? - 'No match found for ${parsers.length} alternative(s)', - args.scanner.emptySpan, - ), - ); - } - - return ParseResult(args.trampoline, args.scanner, this, false, errors); - } - - @override - ParseResult __parse(ParseArgs args) { - var replay = args.scanner.position; - var errors = []; - var results = >[]; - - for (var parser in parsers) { - var result = parser._parse(args.increaseDepth()); - - if (result.successful) { - results.add(result); - } else if (parser is _Alt) errors.addAll(result.errors); - - args.scanner.position = replay; - } - - if (results.isNotEmpty) { - results.sort((a, b) => b.span!.length.compareTo(a.span!.length)); - args.scanner.scan(results.first.span!.text); - return results.first; - } - - errors.add( - SyntaxError( - severity, - errorMessage?.toString() ?? - 'No match found for ${parsers.length} alternative(s)', - args.scanner.emptySpan, - ), - ); - - return ParseResult(args.trampoline, args.scanner, this, false, errors); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('longest(${parsers.length}) (') - ..indent(); - var i = 1; - - for (var parser in parsers) { - buffer - ..writeln('#${i++}:') - ..indent(); - parser.stringify(buffer); - buffer.outdent(); - } - - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/map.dart b/packages/combinator/lib/src/combinator/map.dart deleted file mode 100644 index 4dfb326d..00000000 --- a/packages/combinator/lib/src/combinator/map.dart +++ /dev/null @@ -1,56 +0,0 @@ -part of lex.src.combinator; - -class _Map extends Parser { - final Parser parser; - final U Function(ParseResult) f; - - _Map(this.parser, this.f); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()); - return ParseResult( - args.trampoline, - args.scanner, - this, - result.successful, - result.errors, - span: result.span, - value: result.successful ? f(result) : null, - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('map<$U> (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} - -class _Change extends Parser { - final Parser parser; - final ParseResult Function(ParseResult) f; - - _Change(this.parser, this.f); - - @override - ParseResult __parse(ParseArgs args) { - return f(parser._parse(args.increaseDepth())).change(parser: this); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('change($f) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/match.dart b/packages/combinator/lib/src/combinator/match.dart deleted file mode 100644 index 837c306d..00000000 --- a/packages/combinator/lib/src/combinator/match.dart +++ /dev/null @@ -1,41 +0,0 @@ -part of lex.src.combinator; - -/// Expects to match a given [pattern]. If it is not matched, you can provide a custom [errorMessage]. -Parser match(Pattern pattern, - {String? errorMessage, SyntaxErrorSeverity? severity}) => - _Match(pattern, errorMessage, severity ?? SyntaxErrorSeverity.error); - -class _Match extends Parser { - final Pattern pattern; - final String? errorMessage; - final SyntaxErrorSeverity severity; - - _Match(this.pattern, this.errorMessage, this.severity); - - @override - ParseResult __parse(ParseArgs args) { - var scanner = args.scanner; - if (!scanner.scan(pattern)) { - return ParseResult(args.trampoline, scanner, this, false, [ - SyntaxError( - severity, - errorMessage ?? 'Expected "$pattern".', - scanner.emptySpan, - ), - ]); - } - return ParseResult( - args.trampoline, - scanner, - this, - true, - [], - span: scanner.lastSpan, - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer.writeln('match($pattern)'); - } -} diff --git a/packages/combinator/lib/src/combinator/max_depth.dart b/packages/combinator/lib/src/combinator/max_depth.dart deleted file mode 100644 index 42befcff..00000000 --- a/packages/combinator/lib/src/combinator/max_depth.dart +++ /dev/null @@ -1,28 +0,0 @@ -part of lex.src.combinator; - -class _MaxDepth extends Parser { - final Parser parser; - final int cap; - - _MaxDepth(this.parser, this.cap); - - @override - ParseResult __parse(ParseArgs args) { - if (args.depth > cap) { - return ParseResult(args.trampoline, args.scanner, this, false, []); - } - - return parser._parse(args.increaseDepth()); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('max depth($cap) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/negate.dart b/packages/combinator/lib/src/combinator/negate.dart deleted file mode 100644 index b507bdcc..00000000 --- a/packages/combinator/lib/src/combinator/negate.dart +++ /dev/null @@ -1,51 +0,0 @@ -part of lex.src.combinator; - -class _Negate extends Parser { - final Parser parser; - final String? errorMessage; - final SyntaxErrorSeverity severity; - - _Negate(this.parser, this.errorMessage, this.severity); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()).change(parser: this); - - if (!result.successful) { - return ParseResult( - args.trampoline, - args.scanner, - this, - true, - [], - span: result.span ?? args.scanner.lastSpan ?? args.scanner.emptySpan, - value: result.value, - ); - } - - result = result.change(successful: false); - - if (errorMessage != null) { - result = result.addErrors([ - SyntaxError( - severity, - errorMessage, - result.span, - ), - ]); - } - - return result; - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('negate (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/opt.dart b/packages/combinator/lib/src/combinator/opt.dart deleted file mode 100644 index 3f31c995..00000000 --- a/packages/combinator/lib/src/combinator/opt.dart +++ /dev/null @@ -1,57 +0,0 @@ -part of lex.src.combinator; - -class _Opt extends Parser { - final Parser parser; - final bool backtrack; - - _Opt(this.parser, this.backtrack); - - @override - ParseResult __parse(ParseArgs args) { - var replay = args.scanner.position; - var result = parser._parse(args.increaseDepth()); - - if (!result.successful) args.scanner.position = replay; - - return result.change(parser: this, successful: true); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('optional (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} - -class _ListOpt extends ListParser { - final ListParser parser; - final bool backtrack; - - _ListOpt(this.parser, this.backtrack); - - @override - ParseResult> __parse(ParseArgs args) { - var replay = args.scanner.position; - var result = parser._parse(args.increaseDepth()); - - if (!result.successful) args.scanner.position = replay; - - return result.change(parser: this, successful: true); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('optional (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/recursion.dart b/packages/combinator/lib/src/combinator/recursion.dart deleted file mode 100644 index 76516943..00000000 --- a/packages/combinator/lib/src/combinator/recursion.dart +++ /dev/null @@ -1,142 +0,0 @@ -part of lex.src.combinator; - -/* -/// Handles left recursion in a grammar using the Pratt algorithm. -class Recursion { - Iterable> prefix; - Map)> infix; - Map)> postfix; - - Recursion({this.prefix, this.infix, this.postfix}) { - prefix ??= []; - infix ??= {}; - postfix ??= {}; - } - - Parser precedence(int p) => _Precedence(this, p); - - void stringify(CodeBuffer buffer) { - buffer - ..writeln('recursion (') - ..indent() - ..writeln('prefix(${prefix.length}') - ..writeln('infix(${infix.length}') - ..writeln('postfix(${postfix.length}') - ..outdent() - ..writeln(')'); - } -} - -class _Precedence extends Parser { - final Recursion r; - final int precedence; - - _Precedence(this.r, this.precedence); - - @override - ParseResult __parse(ParseArgs args) { - int replay = args.scanner.position; - var errors = []; - var start = args.scanner.state; - var reversedKeys = r.infix.keys.toList().reversed; - - for (var pre in r.prefix) { - var result = pre._parse(args.increaseDepth()), originalResult = result; - - if (!result.successful) { - if (pre is _Alt) errors.addAll(result.errors); - args.scanner.position = replay; - } else { - var left = result.value; - replay = args.scanner.position; - //print('${result.span.text}:\n' + scanner.emptySpan.highlight()); - - while (true) { - bool matched = false; - - //for (int i = 0; i < r.infix.length; i++) { - for (int i = r.infix.length - 1; i >= 0; i--) { - //var fix = r.infix.keys.elementAt(r.infix.length - i - 1); - var fix = reversedKeys.elementAt(i); - - if (i < precedence) continue; - - var result = fix._parse(args.increaseDepth()); - - if (!result.successful) { - if (fix is _Alt) errors.addAll(result.errors); - // If this is the last alternative and it failed, don't continue looping. - //if (true || i + 1 < r.infix.length) - args.scanner.position = replay; - } else { - //print('FOUND $fix when left was $left'); - //print('$i vs $precedence\n${originalResult.span.highlight()}'); - result = r.precedence(i)._parse(args.increaseDepth()); - - if (!result.successful) { - } else { - matched = false; - var old = left; - left = r.infix[fix](left, result.value, result); - print( - '$old $fix ${result.value} = $left\n${result.span.highlight()}'); - break; - } - } - } - - if (!matched) break; - } - - replay = args.scanner.position; - //print('f ${result.span.text}'); - - for (var post in r.postfix.keys) { - var result = pre._parse(args.increaseDepth()); - - if (!result.successful) { - if (post is _Alt) errors.addAll(result.errors); - args.scanner.position = replay; - } else { - left = r.infix[post](left, originalResult.value, result); - } - } - - if (!args.scanner.isDone) { - // If we're not done scanning, then we need some sort of guard to ensure the - // that this exact parser does not run again in the exact position. - } - return ParseResult( - args.trampoline, - args.scanner, - this, - true, - errors, - value: left, - span: args.scanner.spanFrom(start), - ); - } - } - - return ParseResult( - args.trampoline, - args.scanner, - this, - false, - errors, - span: args.scanner.spanFrom(start), - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('precedence($precedence) (') - ..indent(); - r.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} -*/ diff --git a/packages/combinator/lib/src/combinator/reduce.dart b/packages/combinator/lib/src/combinator/reduce.dart deleted file mode 100644 index a8779b4b..00000000 --- a/packages/combinator/lib/src/combinator/reduce.dart +++ /dev/null @@ -1,46 +0,0 @@ -part of lex.src.combinator; - -class _Reduce extends Parser { - final ListParser parser; - final T Function(T, T) combine; - - _Reduce(this.parser, this.combine); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()); - - if (!result.successful) { - return ParseResult( - args.trampoline, - args.scanner, - this, - false, - result.errors, - ); - } - - result = result.change( - value: result.value?.isNotEmpty == true ? result.value : []); - return ParseResult( - args.trampoline, - args.scanner, - this, - result.successful, - [], - span: result.span, - value: result.value!.isEmpty ? null : result.value!.reduce(combine), - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('reduce($combine) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/reference.dart b/packages/combinator/lib/src/combinator/reference.dart deleted file mode 100644 index 5088c4ac..00000000 --- a/packages/combinator/lib/src/combinator/reference.dart +++ /dev/null @@ -1,44 +0,0 @@ -part of lex.src.combinator; - -Reference reference() => Reference._(); - -class Reference extends Parser { - Parser? _parser; - bool printed = false; - - Reference._(); - - set parser(Parser value) { - if (_parser != null) { - throw StateError('There is already a parser assigned to this reference.'); - } - _parser = value; - } - - @override - ParseResult __parse(ParseArgs args) { - if (_parser == null) { - throw StateError('There is no parser assigned to this reference.'); - } - return _parser!._parse(args); - } - - @override - ParseResult _parse(ParseArgs args) { - if (_parser == null) { - throw StateError('There is no parser assigned to this reference.'); - } - return _parser!._parse(args); - } - - @override - void stringify(CodeBuffer buffer) { - if (_parser == null) { - buffer.writeln('(undefined reference <$T>)'); - } else if (!printed) { - _parser!.stringify(buffer); - } - printed = true; - buffer.writeln('(previously printed reference)'); - } -} diff --git a/packages/combinator/lib/src/combinator/repeat.dart b/packages/combinator/lib/src/combinator/repeat.dart deleted file mode 100644 index 13dd9f24..00000000 --- a/packages/combinator/lib/src/combinator/repeat.dart +++ /dev/null @@ -1,89 +0,0 @@ -part of lex.src.combinator; - -class _Repeat extends ListParser { - final Parser parser; - final int count; - final bool exact, backtrack; - final String tooFew; - final String tooMany; - final SyntaxErrorSeverity severity; - - _Repeat(this.parser, this.count, this.exact, this.tooFew, this.tooMany, - this.backtrack, this.severity); - - @override - ParseResult> __parse(ParseArgs args) { - var errors = []; - var results = []; - var spans = []; - var success = 0; - var replay = args.scanner.position; - ParseResult result; - - do { - result = parser._parse(args.increaseDepth()); - if (result.successful) { - success++; - if (result.value != null) { - results.add(result.value!); - } - replay = args.scanner.position; - } else if (backtrack) args.scanner.position = replay; - - if (result.span != null) { - spans.add(result.span!); - } - } while (result.successful); - - if (success < count) { - errors.addAll(result.errors); - errors.add( - SyntaxError( - severity, - tooFew, - result.span ?? args.scanner.emptySpan, - ), - ); - - if (backtrack) args.scanner.position = replay; - - return ParseResult>( - args.trampoline, args.scanner, this, false, errors); - } else if (success > count && exact) { - if (backtrack) args.scanner.position = replay; - - return ParseResult>(args.trampoline, args.scanner, this, false, [ - SyntaxError( - severity, - tooMany, - result.span ?? args.scanner.emptySpan, - ), - ]); - } - - var span = spans.reduce((a, b) => a.expand(b)); - return ParseResult>( - args.trampoline, - args.scanner, - this, - true, - [], - span: span, - value: results, - ); - } - - @override - void stringify(CodeBuffer buffer) { - var r = StringBuffer('{$count'); - if (!exact) r.write(','); - r.write('}'); - buffer - ..writeln('repeat($r) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/safe.dart b/packages/combinator/lib/src/combinator/safe.dart deleted file mode 100644 index a2542295..00000000 --- a/packages/combinator/lib/src/combinator/safe.dart +++ /dev/null @@ -1,47 +0,0 @@ -part of lex.src.combinator; - -class _Safe extends Parser { - final Parser parser; - final bool backtrack; - final String errorMessage; - final SyntaxErrorSeverity severity; - bool _triggered = false; - - _Safe(this.parser, this.backtrack, this.errorMessage, this.severity); - - @override - ParseResult __parse(ParseArgs args) { - var replay = args.scanner.position; - - try { - if (_triggered) throw Exception(); - return parser._parse(args.increaseDepth()); - } catch (_) { - _triggered = true; - if (backtrack) args.scanner.position = replay; - var errors = []; - - errors.add( - SyntaxError( - severity, - errorMessage, - args.scanner.lastSpan ?? args.scanner.emptySpan, - ), - ); - - return ParseResult(args.trampoline, args.scanner, this, false, errors); - } - } - - @override - void stringify(CodeBuffer buffer) { - var t = _triggered ? 'triggered' : 'not triggered'; - buffer - ..writeln('safe($t) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/to_list.dart b/packages/combinator/lib/src/combinator/to_list.dart deleted file mode 100644 index 320be1fc..00000000 --- a/packages/combinator/lib/src/combinator/to_list.dart +++ /dev/null @@ -1,41 +0,0 @@ -part of lex.src.combinator; - -class _ToList extends ListParser { - final Parser parser; - - _ToList(this.parser); - - @override - ParseResult> __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()); - - if (result.value is List) { - return (result as ParseResult>).change(parser: this); - } - - var values = []; - if (result.value != null) { - values.add(result.value!); - } - return ParseResult( - args.trampoline, - args.scanner, - this, - result.successful, - result.errors, - span: result.span, - value: values, - ); - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('to list (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/combinator/util.dart b/packages/combinator/lib/src/combinator/util.dart deleted file mode 100644 index cb5dcdc7..00000000 --- a/packages/combinator/lib/src/combinator/util.dart +++ /dev/null @@ -1,57 +0,0 @@ -part of lex.src.combinator; - -/// A typed parser that parses a sequence of 2 values of different types. -Parser> tuple2(Parser a, Parser b) { - return chain([a, b]).map((r) { - return Tuple2(r.value?[0] as A, r.value?[1] as B); - }); -} - -/// A typed parser that parses a sequence of 3 values of different types. -Parser> tuple3(Parser a, Parser b, Parser c) { - return chain([a, b, c]).map((r) { - return Tuple3(r.value?[0] as A, r.value?[1] as B, r.value?[2] as C); - }); -} - -/// A typed parser that parses a sequence of 4 values of different types. -Parser> tuple4( - Parser a, Parser b, Parser c, Parser d) { - return chain([a, b, c, d]).map((r) { - return Tuple4( - r.value?[0] as A, r.value?[1] as B, r.value?[2] as C, r.value?[3] as D); - }); -} - -/// A typed parser that parses a sequence of 5 values of different types. -Parser> tuple5( - Parser a, Parser b, Parser c, Parser d, Parser e) { - return chain([a, b, c, d, e]).map((r) { - return Tuple5(r.value?[0] as A, r.value?[1] as B, r.value?[2] as C, - r.value?[3] as D, r.value?[4] as E); - }); -} - -/// A typed parser that parses a sequence of 6 values of different types. -Parser> tuple6(Parser a, - Parser b, Parser c, Parser d, Parser e, Parser f) { - return chain([a, b, c, d, e, f]).map((r) { - return Tuple6(r.value?[0] as A, r.value?[1] as B, r.value?[2] as C, - r.value?[3] as D, r.value?[4] as E, r.value?[5] as F); - }); -} - -/// A typed parser that parses a sequence of 7 values of different types. -Parser> tuple7( - Parser a, - Parser b, - Parser c, - Parser d, - Parser e, - Parser f, - Parser g) { - return chain([a, b, c, d, e, f, g]).map((r) { - return Tuple7(r.value?[0] as A, r.value?[1] as B, r.value?[2] as C, - r.value?[3] as D, r.value?[4] as E, r.value?[5] as F, r.value?[6] as G); - }); -} diff --git a/packages/combinator/lib/src/combinator/value.dart b/packages/combinator/lib/src/combinator/value.dart deleted file mode 100644 index b0612073..00000000 --- a/packages/combinator/lib/src/combinator/value.dart +++ /dev/null @@ -1,25 +0,0 @@ -part of lex.src.combinator; - -class _Value extends Parser { - final Parser parser; - final T Function(ParseResult) f; - - _Value(this.parser, this.f); - - @override - ParseResult __parse(ParseArgs args) { - var result = parser._parse(args.increaseDepth()).change(parser: this); - return result.successful ? result.change(value: f(result)) : result; - } - - @override - void stringify(CodeBuffer buffer) { - buffer - ..writeln('set value($f) (') - ..indent(); - parser.stringify(buffer); - buffer - ..outdent() - ..writeln(')'); - } -} diff --git a/packages/combinator/lib/src/error.dart b/packages/combinator/lib/src/error.dart deleted file mode 100644 index 6c7b5f51..00000000 --- a/packages/combinator/lib/src/error.dart +++ /dev/null @@ -1,23 +0,0 @@ -import 'package:source_span/source_span.dart'; - -class SyntaxError implements Exception { - final SyntaxErrorSeverity severity; - final String? message; - final FileSpan? span; - String? _toolString; - - SyntaxError(this.severity, this.message, this.span); - - String? get toolString { - if (_toolString != null) return _toolString; - var type = severity == SyntaxErrorSeverity.warning ? 'warning' : 'error'; - return _toolString = '$type: ${span!.start.toolString}: $message'; - } -} - -enum SyntaxErrorSeverity { - warning, - error, - info, - hint, -} diff --git a/packages/combinator/pubspec.yaml b/packages/combinator/pubspec.yaml deleted file mode 100644 index 1f190118..00000000 --- a/packages/combinator/pubspec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: angel3_combinator -version: 2.0.2 -description: Packrat parser combinators that support static typing, generics, file spans, memoization, and more. -homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/combinator -environment: - sdk: '>=2.12.0 <3.0.0' -dependencies: - angel3_code_buffer: ^2.0.0 - matcher: ^0.12.10 - source_span: ^1.8.1 - string_scanner: ^1.1.0 - tuple: ^2.0.0 -dev_dependencies: - test: ^1.17.4 - pedantic: ^1.11.0 diff --git a/packages/combinator/test/all.dart b/packages/combinator/test/all.dart deleted file mode 100644 index 9022d5fa..00000000 --- a/packages/combinator/test/all.dart +++ /dev/null @@ -1,12 +0,0 @@ -import 'package:test/test.dart'; -import 'list_test.dart' as list; -import 'match_test.dart' as match; -import 'misc_test.dart' as misc; -import 'value_test.dart' as value; - -void main() { - group('list', list.main); - group('match', match.main); - group('value', value.main); - misc.main(); -} diff --git a/packages/combinator/test/common.dart b/packages/combinator/test/common.dart deleted file mode 100644 index 9ccc542b..00000000 --- a/packages/combinator/test/common.dart +++ /dev/null @@ -1,3 +0,0 @@ -import 'package:string_scanner/string_scanner.dart'; - -SpanScanner scan(String text) => SpanScanner(text); diff --git a/packages/combinator/test/list_test.dart b/packages/combinator/test/list_test.dart deleted file mode 100644 index 9489bbee..00000000 --- a/packages/combinator/test/list_test.dart +++ /dev/null @@ -1,22 +0,0 @@ -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:test/test.dart'; -import 'common.dart'; - -void main() { - var number = chain([ - match(RegExp(r'[0-9]+')).value((r) => int.parse(r.span!.text)), - match(',').opt(), - ]).first().cast(); - - var numbers = number.plus(); - - test('sort', () { - var parser = numbers.sort((a, b) => a.compareTo(b)); - expect(parser.parse(scan('21,2,3,34,20')).value, [2, 3, 20, 21, 34]); - }); - test('reduce', () { - var parser = numbers.reduce((a, b) => a + b); - expect(parser.parse(scan('21,2,3,34,20')).value, 80); - expect(parser.parse(scan('not numbers')).value, isNull); - }); -} diff --git a/packages/combinator/test/match_test.dart b/packages/combinator/test/match_test.dart deleted file mode 100644 index b2a4bcc4..00000000 --- a/packages/combinator/test/match_test.dart +++ /dev/null @@ -1,16 +0,0 @@ -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:test/test.dart'; -import 'common.dart'; - -void main() { - test('match string', () { - expect(match('hello').parse(scan('hello world')).successful, isTrue); - }); - test('match start only', () { - expect(match('hello').parse(scan('goodbye hello')).successful, isFalse); - }); - - test('fail if no match', () { - expect(match('hello').parse(scan('world')).successful, isFalse); - }); -} diff --git a/packages/combinator/test/misc_test.dart b/packages/combinator/test/misc_test.dart deleted file mode 100644 index aecdc1fb..00000000 --- a/packages/combinator/test/misc_test.dart +++ /dev/null @@ -1,66 +0,0 @@ -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:matcher/matcher.dart'; -import 'package:test/test.dart'; -import 'common.dart'; - -void main() { - test('advance', () { - var scanner = scan('hello world'); - - // Casted -> dynamic just for the sake of coverage. - var parser = match('he').forward(2).castDynamic(); - parser.parse(scanner); - expect(scanner.position, 4); - }); - - test('change', () { - var parser = match('hello').change((r) => r.change(value: 23)); - expect(parser.parse(scan('helloworld')).value, 23); - }); - - test('check', () { - var parser = match(RegExp(r'[A-Za-z]+')) - .value((r) => r.span!.length) - .check(greaterThan(3)); - expect(parser.parse(scan('helloworld')).successful, isTrue); - expect(parser.parse(scan('yo')).successful, isFalse); - }); - - test('map', () { - var parser = match(RegExp(r'[A-Za-z]+')).map((r) => r.span!.length); - expect(parser.parse(scan('hello')).value, 5); - }); - - test('negate', () { - var parser = match('hello').negate(errorMessage: 'world'); - expect(parser.parse(scan('goodbye world')).successful, isTrue); - expect(parser.parse(scan('hello world')).successful, isFalse); - expect(parser.parse(scan('hello world')).errors.first.message, 'world'); - }); - - group('opt', () { - var single = match('hello').opt(backtrack: true); - var list = match('hel').then(match('lo')).opt(); - - test('succeeds if present', () { - expect(single.parse(scan('hello')).successful, isTrue); - expect(list.parse(scan('hello')).successful, isTrue); - }); - - test('succeeds if not present', () { - expect(single.parse(scan('goodbye')).successful, isTrue); - expect(list.parse(scan('goodbye')).successful, isTrue); - }); - - test('backtracks if not present', () { - for (var parser in [single, list]) { - var scanner = scan('goodbye'); - var pos = scanner.position; - parser.parse(scanner); - expect(scanner.position, pos); - } - }); - }); - - test('safe', () {}); -} diff --git a/packages/combinator/test/recursion_test.dart b/packages/combinator/test/recursion_test.dart deleted file mode 100644 index d91cebb9..00000000 --- a/packages/combinator/test/recursion_test.dart +++ /dev/null @@ -1,53 +0,0 @@ -void main() {} - -/* -void main() { - var number = match( RegExp(r'-?[0-9]+(\.[0-9]+)?')) - .map((r) => num.parse(r.span.text)); - - var term = reference(); - - var r = Recursion(); - - r.prefix = [number]; - - r.infix.addAll({ - match('*'): (l, r, _) => l * r, - match('/'): (l, r, _) => l / r, - match('+'): (l, r, _) => l + r, - match('-'): (l, r, _) => l - r, - - - match('-'): (l, r, _) => l - r, - match('+'): (l, r, _) => l + r, - match('/'): (l, r, _) => l / r, - match('*'): (l, r, _) => l * r, - - }); - - term.parser = r.precedence(0); - - num parse(String text) { - var scanner = SpanScanner(text); - var result = term.parse(scanner); - print(result.span.highlight()); - return result.value; - } - - test('prefix', () { - expect(parse('24'), 24); - }); - - test('infix', () { - expect(parse('12/6'), 2); - expect(parse('24+23'), 47); - expect(parse('24-23'), 1); - expect(parse('4*3'), 12); - }); - - test('precedence', () { - expect(parse('2+3*5*2'), 15); - //expect(parse('2+3+5-2*2'), 15); - }); -} -*/ diff --git a/packages/combinator/test/value_test.dart b/packages/combinator/test/value_test.dart deleted file mode 100644 index 7f2cb102..00000000 --- a/packages/combinator/test/value_test.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:angel3_combinator/angel3_combinator.dart'; -import 'package:test/test.dart'; -import 'common.dart'; - -void main() { - var parser = match('hello').value((r) => 'world'); - - test('sets value', () { - expect(parser.parse(scan('hello world')).value, 'world'); - }); - - test('no value if no match', () { - expect(parser.parse(scan('goodbye world')).value, isNull); - }); -} diff --git a/packages/pub_sub/.gitignore b/packages/pub_sub/.gitignore deleted file mode 100644 index 24d68312..00000000 --- a/packages/pub_sub/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.dart_tool -.packages -.pub/ -build/ - -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# SDK 1.20 and later (no longer creates packages directories) - -# Older SDK versions -# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) -.project -.buildlog -**/packages/ - - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: - -## VsCode -.vscode/ - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -.idea/ -/out/ -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties diff --git a/packages/user_agent/user_agent/.gitignore b/packages/user_agent/user_agent/.gitignore deleted file mode 100644 index 83f976e2..00000000 --- a/packages/user_agent/user_agent/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# Files and directories created by pub -.packages -.pub/ -build/ -packages -# Remove the following pattern if you wish to check in your lock file -pubspec.lock - -# Files created by dart2js -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc -doc/api/ - -# JetBrains IDEs -.idea/ -*.iml -*.ipr -*.iws - -.dart_tool \ No newline at end of file diff --git a/packages/user_agent/user_agent/.travis.yml b/packages/user_agent/user_agent/.travis.yml deleted file mode 100644 index de2210c9..00000000 --- a/packages/user_agent/user_agent/.travis.yml +++ /dev/null @@ -1 +0,0 @@ -language: dart \ No newline at end of file diff --git a/packages/user_agent/user_agent/AUTHORS.md b/packages/user_agent/user_agent/AUTHORS.md deleted file mode 100644 index ac95ab58..00000000 --- a/packages/user_agent/user_agent/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -Primary Authors -=============== - -* __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - - 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)__ - - Tobe has written much of the original code prior to NNBD migration. He has moved on and - is no longer involved with the project. diff --git a/packages/user_agent/user_agent/CHANGELOG.md b/packages/user_agent/user_agent/CHANGELOG.md deleted file mode 100644 index 4a1e9ff4..00000000 --- a/packages/user_agent/user_agent/CHANGELOG.md +++ /dev/null @@ -1,17 +0,0 @@ -# Change Log - -## 3.0.1 - -* Updated to use non nullable results - -## 3.0.0 - -* Migrated to support Dart SDK 2.12.x NNBD - -## 2.0.0 - -* Dart 2 updates. - -## 0.0.1 - -* Initial version, created by Stagehand diff --git a/packages/user_agent/user_agent/LICENSE b/packages/user_agent/user_agent/LICENSE deleted file mode 100644 index b593ac86..00000000 --- a/packages/user_agent/user_agent/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2021 dukefirehawk.com - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/packages/user_agent/user_agent/LICENSE.orig b/packages/user_agent/user_agent/LICENSE.orig deleted file mode 100644 index 05c76b04..00000000 --- a/packages/user_agent/user_agent/LICENSE.orig +++ /dev/null @@ -1,25 +0,0 @@ -BSD 2-Clause License - -Copyright (c) 2017, Tobe O -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -* Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -* Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/user_agent/user_agent/README.md b/packages/user_agent/user_agent/README.md index 8dce655d..aa6b9af3 100644 --- a/packages/user_agent/user_agent/README.md +++ b/packages/user_agent/user_agent/README.md @@ -1,28 +1,3 @@ # 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) - -[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/user_agent/user_agent/LICENSE) - -**Forked from `user_agent` to support NNBD** - -A library to identify the type of devices and web browsers based on `User-Agent` string. - -Runs anywhere. - -```dart -void main() async { - app.get('/', (req, res) async { - var ua = UserAgent(req.headers.value('user-agent')); - - if (ua.isChrome) { - res.redirect('/upgrade-your-browser'); - return; - } else { - // ... - } - }); -} -``` +Moved to [`Belatuk Common Utilities`]() diff --git a/packages/user_agent/user_agent/analysis_options.yaml b/packages/user_agent/user_agent/analysis_options.yaml deleted file mode 100644 index c230cee7..00000000 --- a/packages/user_agent/user_agent/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file diff --git a/packages/user_agent/user_agent/example/example.dart b/packages/user_agent/user_agent/example/example.dart deleted file mode 100644 index 3918e9d3..00000000 --- a/packages/user_agent/user_agent/example/example.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:user_agent_analyzer/user_agent_analyzer.dart'; - -void main() { - var ua = UserAgent( - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36'); - print(ua.isChrome); -} diff --git a/packages/user_agent/user_agent/lib/user_agent_analyzer.dart b/packages/user_agent/user_agent/lib/user_agent_analyzer.dart deleted file mode 100644 index f86757f4..00000000 --- a/packages/user_agent/user_agent/lib/user_agent_analyzer.dart +++ /dev/null @@ -1,235 +0,0 @@ -library user_agent_analyzer; - -/// Utils for device detection. -class UserAgent { - bool _isChrome = false; - bool _isOpera = false; - bool _isIE = false; - bool _isFirefox = false; - bool _isWebKit = false; - String? _cachedCssPrefix; - String? _cachedPropertyPrefix; - - final String value, _lowerValue; - - static const List knownMobileUserAgentPrefixes = [ - 'w3c ', - 'w3c-', - 'acs-', - 'alav', - 'alca', - 'amoi', - 'audi', - 'avan', - 'benq', - 'bird', - 'blac', - 'blaz', - 'brew', - 'cell', - 'cldc', - 'cmd-', - 'dang', - 'doco', - 'eric', - 'hipt', - 'htc_', - 'inno', - 'ipaq', - 'ipod', - 'jigs', - 'kddi', - 'keji', - 'leno', - 'lg-c', - 'lg-d', - 'lg-g', - 'lge-', - 'lg/u', - 'maui', - 'maxo', - 'midp', - 'mits', - 'mmef', - 'mobi', - 'mot-', - 'moto', - 'mwbp', - 'nec-', - 'newt', - 'noki', - 'palm', - 'pana', - 'pant', - 'phil', - 'play', - 'port', - 'prox', - 'qwap', - 'sage', - 'sams', - 'sany', - 'sch-', - 'sec-', - 'send', - 'seri', - 'sgh-', - 'shar', - 'sie-', - 'siem', - 'smal', - 'smar', - 'sony', - 'sph-', - 'symb', - 't-mo', - 'teli', - 'tim-', - 'tosh', - 'tsm-', - 'upg1', - 'upsi', - 'vk-v', - 'voda', - 'wap-', - 'wapa', - 'wapi', - 'wapp', - 'wapr', - 'webc', - 'winw', - 'winw', - 'xda ', - 'xda-' - ]; - - static const List knownMobileUserAgentKeywords = [ - 'blackberry', - 'webos', - 'ipod', - 'lge vx', - 'midp', - 'maemo', - 'mmp', - 'mobile', - 'netfront', - 'hiptop', - 'nintendo DS', - 'novarra', - 'openweb', - 'opera mobi', - 'opera mini', - 'palm', - 'psp', - 'phone', - 'smartphone', - 'symbian', - 'up.browser', - 'up.link', - 'wap', - 'windows ce' - ]; - - static const List knownTabletUserAgentKeywords = [ - 'ipad', - 'playbook', - 'hp-tablet', - 'kindle' - ]; - - UserAgent(this.value) : _lowerValue = value.toLowerCase(); - - /// Determines if the user agent string contains the desired string. Case-insensitive. - bool contains(String needle) => _lowerValue.contains(needle.toLowerCase()); - - bool get isDesktop => isMacOS || (!isMobile && !isTablet); - - bool get isTablet => knownTabletUserAgentKeywords.any(contains); - - bool get isMobile => knownMobileUserAgentKeywords.any(contains); - - bool get isMacOS => contains('Macintosh') || contains('Mac OS X'); - - bool get isSafari => contains('Safari'); - - bool get isAndroid => contains('android'); - - bool get isAndroidPhone => contains('android') && contains('mobile'); - - bool get isAndroidTablet => contains('android') && !contains('mobile'); - - bool get isWindows => contains('windows'); - - bool get isWindowsPhone => isWindows && contains('phone'); - - bool get isWindowsTablet => isWindows && contains('touch'); - - bool get isBlackberry => - contains('blackberry') || contains('bb10') || contains('rim'); - - bool get isBlackberryPhone => isBlackberry && !contains('tablet'); - - bool get isBlackberryTablet => isBlackberry && contains('tablet'); - - /// Determines if the current device is running Chrome. - 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); - return _isOpera; - } - - /// Determines if the current device is running Internet Explorer. - 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); - return _isFirefox; - } - - /// Determines if the current device is running WebKit. - bool get isWebKit { - _isWebKit = !isOpera && value.contains('WebKit', 0); - return _isWebKit; - } - - /// Gets the CSS property prefix for the current platform. - String get cssPrefix { - var prefix = _cachedCssPrefix; - if (prefix != null) return prefix; - if (isFirefox) { - prefix = '-moz-'; - } else if (isIE) { - prefix = '-ms-'; - } else if (isOpera) { - prefix = '-o-'; - } else { - prefix = '-webkit-'; - } - return _cachedCssPrefix = prefix; - } - - /// Prefix as used for JS property names. - String get propertyPrefix { - var prefix = _cachedPropertyPrefix; - if (prefix != null) return prefix; - if (isFirefox) { - prefix = 'moz'; - } else if (isIE) { - prefix = 'ms'; - } else if (isOpera) { - prefix = 'o'; - } else { - prefix = 'webkit'; - } - return _cachedPropertyPrefix = prefix; - } -} diff --git a/packages/user_agent/user_agent/pubspec.yaml b/packages/user_agent/user_agent/pubspec.yaml deleted file mode 100644 index 79e17f8d..00000000 --- a/packages/user_agent/user_agent/pubspec.yaml +++ /dev/null @@ -1,9 +0,0 @@ -name: user_agent_analyzer -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: - sdk: '>=2.12.0 <3.0.0' -dev_dependencies: - test: ^1.17.8 - pedantic: ^1.11.1 diff --git a/packages/user_agent/user_agent/test/user_agent_test.dart b/packages/user_agent/user_agent/test/user_agent_test.dart deleted file mode 100644 index 4721765c..00000000 --- a/packages/user_agent/user_agent/test/user_agent_test.dart +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) 2017, thosakwe. All rights reserved. Use of this source code -// is governed by a BSD-style license that can be found in the LICENSE file. - -import 'package:user_agent_analyzer/user_agent_analyzer.dart'; -import 'package:test/test.dart'; - -void main() { - test('chrome', () { - var ua = UserAgent( - 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.95 Safari/537.36'); - expect([ua.isChrome, ua.isWebKit, ua.isSafari, ua.isDesktop, ua.isMacOS], - everyElement(isTrue)); - expect([ua.isFirefox, ua.isIE, ua.isOpera, ua.isMobile, ua.isTablet], - everyElement(isFalse)); - expect([ - ua.isAndroid, - ua.isAndroidPhone, - ua.isAndroidTablet, - ua.isBlackberry, - ua.isBlackberryPhone, - ua.isBlackberryTablet, - ua.isWindows, - ua.isWindowsPhone, - ua.isWindowsTablet - ], everyElement(isFalse)); - - expect(ua.cssPrefix, equals('-webkit-')); - expect(ua.propertyPrefix, equals('webkit')); - }); -} From 96ea1b16116b81739515a5e77926ad24a0f6a232 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 10:41:14 +0800 Subject: [PATCH 10/22] Moved html_builder to belatuk repo --- packages/html_builder/AUTHORS.md | 12 - packages/html_builder/CHANGELOG.md | 37 - packages/html_builder/LICENSE | 29 - packages/html_builder/README.md | 116 +- packages/html_builder/analysis_options.yaml | 1 - packages/html_builder/example/main.dart | 15 - .../html_builder/lib/angel3_html_builder.dart | 4 - packages/html_builder/lib/elements.dart | 1841 ----------------- packages/html_builder/lib/src/mutations.dart | 20 - packages/html_builder/lib/src/node.dart | 63 - .../html_builder/lib/src/node_builder.dart | 108 - packages/html_builder/lib/src/renderer.dart | 136 -- packages/html_builder/pubspec.yaml | 12 - packages/html_builder/test/render_test.dart | 34 - 14 files changed, 1 insertion(+), 2427 deletions(-) delete mode 100644 packages/html_builder/AUTHORS.md delete mode 100644 packages/html_builder/CHANGELOG.md delete mode 100644 packages/html_builder/LICENSE delete mode 100644 packages/html_builder/analysis_options.yaml delete mode 100644 packages/html_builder/example/main.dart delete mode 100644 packages/html_builder/lib/angel3_html_builder.dart delete mode 100644 packages/html_builder/lib/elements.dart delete mode 100644 packages/html_builder/lib/src/mutations.dart delete mode 100644 packages/html_builder/lib/src/node.dart delete mode 100644 packages/html_builder/lib/src/node_builder.dart delete mode 100644 packages/html_builder/lib/src/renderer.dart delete mode 100644 packages/html_builder/pubspec.yaml delete mode 100644 packages/html_builder/test/render_test.dart diff --git a/packages/html_builder/AUTHORS.md b/packages/html_builder/AUTHORS.md deleted file mode 100644 index ac95ab58..00000000 --- a/packages/html_builder/AUTHORS.md +++ /dev/null @@ -1,12 +0,0 @@ -Primary Authors -=============== - -* __[Thomas Hii](dukefirehawk.apps@gmail.com)__ - - 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)__ - - Tobe has written much of the original code prior to NNBD migration. He has moved on and - is no longer involved with the project. diff --git a/packages/html_builder/CHANGELOG.md b/packages/html_builder/CHANGELOG.md deleted file mode 100644 index cc1b46ce..00000000 --- a/packages/html_builder/CHANGELOG.md +++ /dev/null @@ -1,37 +0,0 @@ -# Change Log - -## 2.0.4 - -* Upgraded from `pendantic` to `lints` linter -* Removed deprecated parameters -* Final release. Replaced by `belatuk_html_builder` package. - -## 2.0.3 - -* Added an example -* Updated README - -## 2.0.2 - -* Run `dartfmt -w .` - -## 2.0.1 - -* Added pedantic dart rules - -## 2.0.0 - -* Migrated to work with Dart SDK 2.12.x NNBD - -## 1.0.4 - -* Added `rebuild`, `rebuildRecursive`, and `NodeBuilder`. - -## 1.0.3 - -* Dart 2 ready! - -## 1.0.2 - -Changed `h` and the `Node` constructor to take `Iterable`s of children, -instead of just `List`s. diff --git a/packages/html_builder/LICENSE b/packages/html_builder/LICENSE deleted file mode 100644 index df5e0635..00000000 --- a/packages/html_builder/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2021, dukefirehawk.com -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/html_builder/README.md b/packages/html_builder/README.md index 0a8ed41a..67fe57ef 100644 --- a/packages/html_builder/README.md +++ b/packages/html_builder/README.md @@ -1,117 +1,3 @@ # Angel3 Html Builder -[![version](https://img.shields.io/badge/pub-v2.0.4-brightgreen)](https://pub.dartlang.org/packages/angel3_html_builder) -[![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/html_builder/LICENSE) - -**DEPRECATED: Replaced by [`belatuk_html_builder`](https://pub.dartlang.org/packages/belatuk_html_builder) package** - -Build HTML AST's and render them to HTML. - -This can be used as an internal DSL, i.e. for a templating engine. - -## Installation - -In your `pubspec.yaml`: - -```yaml -dependencies: - angel3_html_builder: ^2.0.0 -``` - -## Usage - -```dart -import 'package:angel3_html_builder/angel3_html_builder.dart'; - -void main() { - // Akin to React.createElement(...); - var $el = h('my-element', p: {}, c: []); - - // Attributes can be plain Strings. - h('foo', p: { - 'bar': 'baz' - }); - - // Null attributes do not appear. - h('foo', p: { - 'does-not-appear': null - }); - - // If an attribute is a bool, then it will only appear if its value is true. - h('foo', p: { - 'appears': true, - 'does-not-appear': false - }); - - // Or, a String or Map. - h('foo', p: { - 'style': 'background-color: white; color: red;' - }); - - h('foo', p: { - 'style': { - 'background-color': 'white', - 'color': 'red' - } - }); - - // Or, a String or Iterable. - h('foo', p: { - 'class': 'a b' - }); - - h('foo', p: { - 'class': ['a', 'b'] - }); -} -``` - -Standard HTML5 elements: - -```dart -import 'package:angel3_html_builder/elements.dart'; - -void main() { - var $dom = html(lang: 'en', c: [ - head(c: [ - title(c: [text('Hello, world!')]) - ]), - body(c: [ - h1(c: [text('Hello, world!')]), - p(c: [text('Ok')]) - ]) - ]); -} -``` - -Rendering to HTML: - -```dart -String html = StringRenderer().render($dom); -``` - -Example with the [Angel](https://github.com/dukefirehawk/angel/tree/angel3) server-side framework, -which has [dedicated html_builder support](https://github.com/dukefirehawk/angel/tree/html): - -```dart -import 'dart:io'; -import 'package:angel3_framework/angel3_framework.dart'; -import 'package:angel3_html_builder/elements.dart'; - -configureViews(Angel app) async { - app.get('/foo/:id', (req, res) async { - var foo = await app.service('foo').read(req.params['id']); - return html(c: [ - head(c: [ - title(c: [text(foo.name)]) - ]), - body(c: [ - h1(c: [text(foo.name)]) - ]) - ]); - }); -} -``` +`angel3_html_builder` package has been deprecated and replaced by `belatuk_html_builder`package at [`Belatuk Common Utilities`]() diff --git a/packages/html_builder/analysis_options.yaml b/packages/html_builder/analysis_options.yaml deleted file mode 100644 index ea2c9e94..00000000 --- a/packages/html_builder/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/html_builder/example/main.dart b/packages/html_builder/example/main.dart deleted file mode 100644 index ad113b34..00000000 --- a/packages/html_builder/example/main.dart +++ /dev/null @@ -1,15 +0,0 @@ -import 'package:angel3_html_builder/elements.dart'; - -void main() { - var dom = html(lang: 'en', c: [ - head(c: [ - title(c: [text('Hello, world!')]) - ]), - body(c: [ - h1(c: [text('Hello, world!')]), - p(c: [text('Ok')]) - ]) - ]); - - print(dom); -} diff --git a/packages/html_builder/lib/angel3_html_builder.dart b/packages/html_builder/lib/angel3_html_builder.dart deleted file mode 100644 index ebf01f4c..00000000 --- a/packages/html_builder/lib/angel3_html_builder.dart +++ /dev/null @@ -1,4 +0,0 @@ -export 'src/mutations.dart'; -export 'src/node.dart'; -export 'src/node_builder.dart'; -export 'src/renderer.dart'; diff --git a/packages/html_builder/lib/elements.dart b/packages/html_builder/lib/elements.dart deleted file mode 100644 index d4cbb249..00000000 --- a/packages/html_builder/lib/elements.dart +++ /dev/null @@ -1,1841 +0,0 @@ -/// Helper functions to build common HTML5 elements. -library angel3_html_builder.elements; - -import 'angel3_html_builder.dart'; -export 'angel3_html_builder.dart'; - -Map _apply(Iterable> props, - [Map? attrs]) { - var map = {}; - attrs?.forEach((k, attr) { - if (attr is String && attr.isNotEmpty == true) { - map[k] = attr; - } else if (attr is Iterable && attr.isNotEmpty == true) { - map[k] = attr.toList(); - } else if (attr != null) { - map[k] = attr; - } - }); - - for (var p in props) { - map.addAll(p); - } - - return map.cast(); -} - -Node text(String text) => TextNode(text); - -Node a( - {String? href, - String? rel, - String? target, - String? id, - className, - style, - Map p = const {}, - Iterable c = const []}) => - h( - 'a', - _apply([ - p, - ], { - 'href': href, - 'rel': rel, - 'target': target, - 'id': id, - 'class': className, - 'style': style, - }), - [...c]); - -Node abbr( - {String? title, - String? id, - className, - style, - Map p = const {}, - Iterable c = const []}) => - h( - 'addr', - _apply([p], - {'title': title, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node address({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('address', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node area({ - String? alt, - Iterable? coordinates, - String? download, - String? href, - String? hreflang, - String? media, - String? nohref, - String? rel, - String? shape, - String? target, - String? type, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'area', - _apply([ - p - ], { - 'alt': alt, - 'coordinates': coordinates, - 'download': download, - 'href': href, - 'hreflang': hreflang, - 'media': media, - 'nohref': nohref, - 'rel': rel, - 'shape': shape, - 'target': target, - 'type': type, - 'id': id, - 'class': className, - 'style': style - })); - -Node article({ - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('article', _apply([p], {'class': className, 'style': style}), [...c]); - -Node aside({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('aside', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node audio({ - bool? autoplay, - bool? controls, - bool? loop, - bool? muted, - String? preload, - String? src, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'audio', - _apply([ - p - ], { - 'autoplay': autoplay, - 'controls': controls, - 'loop': loop, - 'muted': muted, - 'preload': preload, - 'src': src, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node b({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('b', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); - -Node base({ - String? href, - String? target, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'base', - _apply([ - p - ], { - 'href': href, - 'target': target, - 'id': id, - 'class': className, - 'style': style - })); - -Node bdi({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('bdi', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node bdo({ - String? dir, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'bdo', - _apply([p], {'dir': dir, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node blockquote({ - String? cite, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'blockquote', - _apply( - [p], {'cite': cite, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node body({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('body', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node br() => SelfClosingNode('br'); - -Node button({ - bool? autofocus, - bool? disabled, - form, - String? formaction, - String? formenctype, - String? formmethod, - bool? formnovalidate, - String? formtarget, - String? name, - String? type, - String? value, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'button', - _apply([ - p - ], { - 'autofocus': autofocus, - 'disabled': disabled, - 'form': form, - 'formaction': formaction, - 'formenctype': formenctype, - 'formmethod': formmethod, - 'formnovalidate': formnovalidate, - 'formtarget': formtarget, - 'name': name, - 'type': type, - 'value': value, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node canvas({ - num? height, - num? width, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'canvas', - _apply([ - p - ], { - 'height': height, - 'width': width, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node cite({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('cite', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node caption({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('caption', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node code({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('code', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node col({ - num? span, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'col', - _apply( - [p], {'span': span, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node colgroup({ - num? span, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'colgroup', - _apply( - [p], {'span': span, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node datalist({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('datalist', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node dd({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('dd', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node del({ - String? cite, - String? datetime, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'del', - _apply([ - p - ], { - 'cite': cite, - 'datetime': datetime, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node details({ - bool? open, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'details', - _apply( - [p], {'open': open, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node dfn({ - String? title, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'dfn', - _apply([p], - {'title': title, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node dialog({ - bool? open, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'dialog', - _apply( - [p], {'open': open, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node div({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('div', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node dl({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('dl', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node dt({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('dt', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node em({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('em', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node embed({ - num? height, - String? src, - String? type, - num? width, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'embed', - _apply([ - p - ], { - 'height': height, - 'src': src, - 'type': type, - 'width': width, - 'id': id, - 'class': className, - 'style': style - })); - -Node fieldset({ - bool? disabled, - String? form, - String? name, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'fieldset', - _apply([ - p - ], { - 'disabled': disabled, - 'form': form, - 'name': name, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node figcaption({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('figcaption', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node figure({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('figure', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node footer({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('footer', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node form({ - String? accept, - String? acceptCharset, - String? action, - bool? autocomplete, - String? enctype, - String? method, - String? name, - bool? novalidate, - String? target, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'form', - _apply([ - p - ], { - 'accept': accept, - 'accept-charset': acceptCharset, - 'action': action, - 'autocomplete': - autocomplete != null ? (autocomplete ? 'on' : 'off') : null, - 'enctype': enctype, - 'method': method, - 'name': name, - 'novalidate': novalidate, - 'target': target, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node h1({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('h1', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node h2({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('h2', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); -Node h3({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('h3', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node h4({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('h4', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node h5({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('h5', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node h6({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('h6', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node head({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('head', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node header({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('header', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node hr() => SelfClosingNode('hr'); - -Node html({ - String? manifest, - String? xmlns, - String? lang, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'html', - _apply([ - p - ], { - 'manifest': manifest, - 'xmlns': xmlns, - 'lang': lang, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node i({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('i', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); - -Node iframe({ - num? height, - String? name, - sandbox, - String? src, - String? srcdoc, - num? width, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'iframe', - _apply([ - p - ], { - 'height': height, - 'name': name, - 'sandbox': sandbox, - 'src': src, - 'srcdoc': srcdoc, - 'width': width, - 'id': id, - 'class': className, - 'style': style - })); - -Node img({ - String? alt, - String? crossorigin, - num? height, - String? ismap, - String? longdesc, - sizes, - String? src, - String? srcset, - String? usemap, - num? width, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'img', - _apply([ - p - ], { - 'alt': alt, - 'crossorigin': crossorigin, - 'height': height, - 'ismap': ismap, - 'longdesc': longdesc, - 'sizes': sizes, - 'src': src, - 'srcset': srcset, - 'usemap': usemap, - 'width': width, - 'id': id, - 'class': className, - 'style': style - })); - -Node input({ - String? accept, - String? alt, - bool? autocomplete, - bool? autofocus, - bool? checked, - String? dirname, - bool? disabled, - String? form, - String? formaction, - String? formenctype, - String? method, - String? formnovalidate, - String? formtarget, - num? height, - String? list, - max, - num? maxlength, - min, - bool? multiple, - String? name, - String? pattern, - String? placeholder, - bool? readonly, - bool? required, - num? size, - String? src, - num? step, - String? type, - String? value, - num? width, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'input', - _apply([ - p - ], { - 'accept': accept, - 'alt': alt, - 'autocomplete': - autocomplete == null ? null : (autocomplete ? 'on' : 'off'), - 'autofocus': autofocus, - 'checked': checked, - 'dirname': dirname, - 'disabled': disabled, - 'form': form, - 'formaction': formaction, - 'formenctype': formenctype, - 'method': method, - 'formnovalidate': formnovalidate, - 'formtarget': formtarget, - 'height': height, - 'list': list, - 'max': max, - 'maxlength': maxlength, - 'min': min, - 'multiple': multiple, - 'name': name, - 'pattern': pattern, - 'placeholder': placeholder, - 'readonly': readonly, - 'required': required, - 'size': size, - 'src': src, - 'step': step, - 'type': type, - 'value': value, - 'width': width, - 'id': id, - 'class': className, - 'style': style - })); - -Node ins({ - String? cite, - String? datetime, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'ins', - _apply([ - p - ], { - 'cite': cite, - 'datetime': datetime, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node kbd({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('kbd', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node keygen({ - bool? autofocus, - String? challenge, - bool? disabled, - String? from, - String? keytype, - String? name, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'keygen', - _apply([ - p - ], { - 'autofocus': autofocus, - 'challenge': challenge, - 'disabled': disabled, - 'from': from, - 'keytype': keytype, - 'name': name, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node label({ - String? for_, - String? form, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'label', - _apply([ - p - ], { - 'for': for_, - 'form': form, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node legend({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('legend', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node li({ - num? value, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'li', - _apply([p], - {'value': value, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node link({ - String? crossorigin, - String? href, - String? hreflang, - String? media, - String? rel, - sizes, - String? target, - String? type, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'link', - _apply([ - p - ], { - 'crossorigin': crossorigin, - 'href': href, - 'hreflang': hreflang, - 'media': media, - 'rel': rel, - 'sizes': sizes, - 'target': target, - 'type': type, - 'id': id, - 'class': className, - 'style': style - })); - -Node main({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('main', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node map({ - String? name, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'map', - _apply( - [p], {'name': name, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node mark({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('mark', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node menu({ - String? label, - String? type, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'menu', - _apply([ - p - ], { - 'label': label, - 'type': type, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node menuitem({ - bool? checked, - command, - bool? default_, - bool? disabled, - String? icon, - String? label, - String? radiogroup, - String? type, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'menuitem', - _apply([ - p - ], { - 'checked': checked, - 'command': command, - 'default': default_, - 'disabled': disabled, - 'icon': icon, - 'label': label, - 'radiogroup': radiogroup, - 'type': type, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node meta({ - String? charset, - String? content, - String? httpEquiv, - String? name, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'meta', - _apply([ - p - ], { - 'charset': charset, - 'content': content, - 'http-equiv': httpEquiv, - 'name': name, - 'id': id, - 'class': className, - 'style': style - })); - -Node nav({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('nav', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node noscript({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('noscript', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node object({ - String? data, - String? form, - num? height, - String? name, - String? type, - String? usemap, - num? width, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'object', - _apply([ - p - ], { - 'data': data, - 'form': form, - 'height': height, - 'name': name, - 'type': type, - 'usemap': usemap, - 'width': width, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node ol({ - bool? reversed, - num? start, - String? type, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'ol', - _apply([ - p - ], { - 'reversed': reversed, - 'start': start, - 'type': type, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node optgroup({ - bool? disabled, - String? label, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'optgroup', - _apply([ - p - ], { - 'disabled': disabled, - 'label': label, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node option({ - bool? disabled, - String? label, - bool? selected, - String? value, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'option', - _apply([ - p - ], { - 'disabled': disabled, - 'label': label, - 'selected': selected, - 'value': value, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node output({ - String? for_, - String? form, - String? name, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'output', - _apply([ - p - ], { - 'for': for_, - 'form': form, - 'name': name, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node p({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('p', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); - -Node param({ - String? name, - value, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'param', - _apply([ - p - ], { - 'name': name, - 'value': value, - 'id': id, - 'class': className, - 'style': style - })); - -Node picture({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('picture', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node pre({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('pre', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node progress({ - num? max, - num? value, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'progress', - _apply([ - p - ], { - 'max': max, - 'value': value, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node q({ - String? cite, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'q', - _apply( - [p], {'cite': cite, 'id': id, 'class': className, 'style': style}), - [...c]); - -Node rp({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('rp', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node rt({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('rt', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node ruby({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('ruby', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node s({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('s', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); - -Node samp({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('samp', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node script({ - bool? async, - String? charset, - bool? defer, - String? src, - String? type, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'script', - _apply([ - p - ], { - 'async': async, - 'charset': charset, - 'defer': defer, - 'src': src, - 'type': type, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node section({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('section', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node select({ - bool? autofocus, - bool? disabled, - String? form, - bool? multiple, - bool? required, - num? size, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'select', - _apply([ - p - ], { - 'autofocus': autofocus, - 'disabled': disabled, - 'form': form, - 'multiple': multiple, - 'required': required, - 'size': size, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node small({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('small', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node source({ - String? src, - String? srcset, - String? media, - sizes, - String? type, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'source', - _apply([ - p - ], { - 'src': src, - 'srcset': srcset, - 'media': media, - 'sizes': sizes, - 'type': type, - 'id': id, - 'class': className, - 'style': style - })); - -Node span({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('span', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node strong({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('strong', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node style({ - String? media, - bool? scoped, - String? type, - String? id, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'style', - _apply([p], {'media': media, 'scoped': scoped, 'type': type, 'id': id}), - [...c]); - -Node sub({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('sub', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node summary({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('summary', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node sup({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('sup', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node table({ - bool? sortable, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'table', - _apply([ - p - ], { - 'sortable': sortable, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node tbody({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('tbody', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node td({ - num? colspan, - headers, - num? rowspan, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'td', - _apply([ - p - ], { - 'colspan': colspan, - 'headers': headers, - 'rowspan': rowspan, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node textarea({ - bool? autofocus, - num? cols, - String? dirname, - bool? disabled, - String? form, - num? maxlength, - String? name, - String? placeholder, - bool? readonly, - bool? required, - num? rows, - String? wrap, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'textarea', - _apply([ - p - ], { - 'autofocus': autofocus, - 'cols': cols, - 'dirname': dirname, - 'disabled': disabled, - 'form': form, - 'maxlength': maxlength, - 'name': name, - 'placeholder': placeholder, - 'readonly': readonly, - 'required': required, - 'rows': rows, - 'wrap': wrap, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node tfoot({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('tfoot', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node th({ - String? abbr, - num? colspan, - headers, - num? rowspan, - String? scope, - sorted, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'th', - _apply([ - p - ], { - 'abbr': abbr, - 'colspan': colspan, - 'headers': headers, - 'rowspan': rowspan, - 'scope': scope, - 'sorted': sorted, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node thead({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('thead', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node time({ - String? datetime, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'time', - _apply([ - p - ], { - 'datetime': datetime, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node title({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('title', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node tr({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('tr', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node track({ - bool? default_, - String? kind, - String? label, - String? src, - String? srclang, - String? id, - className, - style, - Map p = const {}, -}) => - SelfClosingNode( - 'track', - _apply([ - p - ], { - 'default': default_, - 'kind': kind, - 'label': label, - 'src': src, - 'srclang': srclang, - 'id': id, - 'class': className, - 'style': style - })); - -Node u({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('u', _apply([p], {'id': id, 'class': className, 'style': style}), [...c]); - -Node ul({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('ul', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node var_({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('var', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); - -Node video({ - bool? autoplay, - bool? controls, - num? height, - bool? loop, - bool? muted, - String? poster, - String? preload, - String? src, - num? width, - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h( - 'video', - _apply([ - p - ], { - 'autoplay': autoplay, - 'controls': controls, - 'height': height, - 'loop': loop, - 'muted': muted, - 'poster': poster, - 'preload': preload, - 'src': src, - 'width': width, - 'id': id, - 'class': className, - 'style': style - }), - [...c]); - -Node wbr({ - String? id, - className, - style, - Map p = const {}, - Iterable c = const [], -}) => - h('wbr', _apply([p], {'id': id, 'class': className, 'style': style}), - [...c]); diff --git a/packages/html_builder/lib/src/mutations.dart b/packages/html_builder/lib/src/mutations.dart deleted file mode 100644 index 3173163f..00000000 --- a/packages/html_builder/lib/src/mutations.dart +++ /dev/null @@ -1,20 +0,0 @@ -import 'node.dart'; -import 'node_builder.dart'; - -/// Returns a function that rebuilds an arbitrary [Node] by applying the [transform] to it. -Node Function(Node) rebuild(NodeBuilder Function(NodeBuilder) transform, - {bool selfClosing = false}) { - return (node) => - transform(NodeBuilder.from(node)).build(selfClosing: selfClosing); -} - -/// Applies [f] to all children of this node, recursively. -/// -/// Use this alongside [rebuild]. -Node Function(Node) rebuildRecursive(Node Function(Node) f) { - Node _build(Node node) { - return NodeBuilder.from(f(node)).mapChildren(_build).build(); - } - - return _build; -} diff --git a/packages/html_builder/lib/src/node.dart b/packages/html_builder/lib/src/node.dart deleted file mode 100644 index b547077e..00000000 --- a/packages/html_builder/lib/src/node.dart +++ /dev/null @@ -1,63 +0,0 @@ -import 'package:collection/collection.dart'; - -/// Shorthand function to generate a new [Node]. -Node h(String tagName, - [Map attributes = const {}, - Iterable children = const []]) => - Node(tagName, attributes, children); - -/// Represents an HTML node. -class Node { - final String tagName; - final Map attributes = {}; - final List children = []; - - Node(this.tagName, - [Map attributes = const {}, - Iterable children = const []]) { - this - ..attributes.addAll(attributes) - ..children.addAll(children); - } - - Node._selfClosing(this.tagName, - [Map attributes = const {}]) { - this.attributes.addAll(attributes); - } - - @override - bool operator ==(other) { - return other is Node && - other.tagName == tagName && - const ListEquality().equals(other.children, children) && - const MapEquality() - .equals(other.attributes, attributes); - } -} - -/// Represents a self-closing tag, i.e. `
`. -class SelfClosingNode extends Node { - /* - @override - final String tagName; - - @override - final Map attributes = {}; - */ - - @override - List get children => List.unmodifiable([]); - - SelfClosingNode(tagName, [Map attributes = const {}]) - : super._selfClosing(tagName, attributes); -} - -/// Represents a text node. -class TextNode extends Node { - final String text; - - TextNode(this.text) : super(':text'); - - @override - bool operator ==(other) => other is TextNode && other.text == text; -} diff --git a/packages/html_builder/lib/src/node_builder.dart b/packages/html_builder/lib/src/node_builder.dart deleted file mode 100644 index ab566c86..00000000 --- a/packages/html_builder/lib/src/node_builder.dart +++ /dev/null @@ -1,108 +0,0 @@ -import 'node.dart'; - -/// Helper class to build nodes. -class NodeBuilder { - final String tagName; - final Map attributes; - final Iterable children; - Node? _existing; - - NodeBuilder(this.tagName, - {this.attributes = const {}, this.children = const []}); - - /// Creates a [NodeBuilder] that just spits out an already-existing [Node]. - factory NodeBuilder.existing(Node existingNode) => - NodeBuilder(existingNode.tagName).._existing = existingNode; - - factory NodeBuilder.from(Node node) => NodeBuilder(node.tagName, - attributes: Map.from(node.attributes), - children: List.from(node.children)); - - /// Builds the node. - Node build({bool selfClosing = false}) => - _existing ?? - (selfClosing - ? SelfClosingNode(tagName, attributes) - : Node(tagName, attributes, children)); - - /// Produce a modified copy of this builder. - NodeBuilder change( - {String? tagName, - Map? attributes, - Iterable? children}) { - return NodeBuilder(tagName ?? this.tagName, - attributes: attributes ?? this.attributes, - children: children ?? this.children); - } - - NodeBuilder changeTagName(String tagName) => change(tagName: tagName); - - NodeBuilder changeAttributes(Map attributes) => - change(attributes: attributes); - - NodeBuilder changeChildren(Iterable children) => - change(children: children); - - NodeBuilder changeAttributesMapped( - Map Function(Map) f) { - var map = Map.from(attributes); - return changeAttributes(f(map)); - } - - NodeBuilder changeChildrenMapped(Iterable Function(List) f) { - var list = List.from(children); - return changeChildren(f(list)); - } - - NodeBuilder mapChildren(Node Function(Node) f) => - changeChildrenMapped((list) => list.map(f)); - - NodeBuilder mapAttributes( - MapEntry Function(String, dynamic) f) => - changeAttributesMapped((map) => map.map(f)); - - NodeBuilder setAttribute(String name, dynamic value) => - changeAttributesMapped((map) => map..[name] = value); - - NodeBuilder addChild(Node child) => - changeChildrenMapped((list) => list..add(child)); - - NodeBuilder removeChild(Node child) => - changeChildrenMapped((list) => list..remove(child)); - - NodeBuilder removeAttribute(String name) => - changeAttributesMapped((map) => map..remove(name)); - - NodeBuilder setId(String id) => setAttribute('id', id); - - NodeBuilder setClassName(String className) => - setAttribute('class', className); - - NodeBuilder setClasses(Iterable classes) => - setClassName(classes.join(' ')); - - NodeBuilder setClassesMapped(Iterable Function(List) f) { - var clazz = attributes['class']; - var classes = []; - - if (clazz is String) { - classes.addAll(clazz.split(' ')); - } else if (clazz is Iterable) { - classes.addAll(clazz.map((s) => s.toString())); - } - - return setClasses(f(classes)); - } - - NodeBuilder addClass(String className) => setClassesMapped( - (classes) => classes.contains(className) ? classes : classes - ..add(className)); - - NodeBuilder removeClass(String className) => - setClassesMapped((classes) => classes..remove(className)); - - NodeBuilder toggleClass(String className) => - setClassesMapped((classes) => classes.contains(className) - ? (classes..remove(className)) - : (classes..add(className))); -} diff --git a/packages/html_builder/lib/src/renderer.dart b/packages/html_builder/lib/src/renderer.dart deleted file mode 100644 index 31b2434d..00000000 --- a/packages/html_builder/lib/src/renderer.dart +++ /dev/null @@ -1,136 +0,0 @@ -import 'node.dart'; - -/// An object that can render a DOM tree into another representation, i.e. a `String`. -abstract class Renderer { - /// Renders a DOM tree into another representation. - T render(Node rootNode); -} - -/// Renders a DOM tree into a HTML string. -abstract class StringRenderer implements Renderer { - /// Initializes a new [StringRenderer]. - /// - /// If [html5] is not `false` (default: `true`), then self-closing elements will be rendered with a slash before the last angle bracket, ex. `
`. - /// If [pretty] is `true` (default), then [whitespace] (default: `' '`) will be inserted between nodes. - /// You can also provide a [doctype] (default: `html`). - factory StringRenderer( - {bool html5 = true, - bool pretty = true, - String doctype = 'html', - String whitespace = ' '}) => - pretty == true - ? _PrettyStringRendererImpl( - html5: html5 != false, doctype: doctype, whitespace: whitespace) - : _StringRendererImpl(html5: html5 != false, doctype: doctype); -} - -class _StringRendererImpl implements StringRenderer { - final String? doctype; - final bool? html5; - - _StringRendererImpl({this.html5, this.doctype}); - - void _renderInto(Node node, StringBuffer buf) { - if (node is TextNode) { - buf.write(node.text); - } else { - buf.write('<${node.tagName}'); - - node.attributes.forEach((k, v) { - if (v == true) { - buf.write(' $k'); - } else if (v == false || v == null) { - // Ignore - } else if (v is Iterable) { - var val = v.join(' ').replaceAll('"', '\\"'); - buf.write(' $k="$val"'); - } else if (v is Map) { - var val = v.keys - .fold('', (out, k) => out += '$k: ${v[k]};') - .replaceAll('"', '\\"'); - buf.write(' $k="$val"'); - } else { - var val = v.toString().replaceAll('"', '\\"'); - buf.write(' $k="$val"'); - } - }); - - if (node is SelfClosingNode) { - buf.write((html5 != false) ? '>' : '/>'); - } else { - buf.write('>'); - node.children.forEach((child) => _renderInto(child, buf)); - buf.write(''); - } - } - } - - @override - String render(Node rootNode) { - var buf = StringBuffer(); - if (doctype?.isNotEmpty == true) buf.write(''); - _renderInto(rootNode, buf); - return buf.toString(); - } -} - -class _PrettyStringRendererImpl implements StringRenderer { - final bool? html5; - final String? doctype, whitespace; - - _PrettyStringRendererImpl({this.html5, this.whitespace, this.doctype}); - - void _applyTabs(int tabs, StringBuffer buf) { - for (var i = 0; i < tabs; i++) { - buf.write(whitespace ?? ' '); - } - } - - void _renderInto(int tabs, Node node, StringBuffer buf) { - if (tabs > 0) buf.writeln(); - _applyTabs(tabs, buf); - - if (node is TextNode) { - buf.write(node.text); - } else { - buf.write('<${node.tagName}'); - - node.attributes.forEach((k, v) { - if (v == true) { - buf.write(' $k'); - } else if (v == false || v == null) { - // Ignore - } else if (v is Iterable) { - var val = v.join(' ').replaceAll('"', '\\"'); - buf.write(' $k="$val"'); - } else if (v is Map) { - var val = v.keys - .fold('', (out, k) => out += '$k: ${v[k]};') - .replaceAll('"', '\\"'); - buf.write(' $k="$val"'); - } else { - var val = v.toString().replaceAll('"', '\\"'); - buf.write(' $k="$val"'); - } - }); - - if (node is SelfClosingNode) { - buf.write((html5 != false) ? '>' : '/>'); - } else { - buf.write('>'); - node.children.forEach((child) => _renderInto(tabs + 1, child, buf)); - buf.writeln(); - _applyTabs(tabs, buf); - buf.write(''); - } - } - } - - @override - String render(Node rootNode) { - var buf = StringBuffer(); - if (doctype?.isNotEmpty == true) buf.writeln(''); - _renderInto(0, rootNode, buf); - return buf.toString(); - } -} diff --git a/packages/html_builder/pubspec.yaml b/packages/html_builder/pubspec.yaml deleted file mode 100644 index 8b31a293..00000000 --- a/packages/html_builder/pubspec.yaml +++ /dev/null @@ -1,12 +0,0 @@ -name: angel3_html_builder -description: Build HTML AST's and render them to HTML. This can be used as an internal DSL, i.e. for a templating engine. -version: 2.0.4 -homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/html_builder -environment: - sdk: '>=2.12.0 <3.0.0' -dependencies: - collection: ^1.15.0 -dev_dependencies: - html: ^0.15.0 - test: ^1.17.4 - lints: ^1.0.1 diff --git a/packages/html_builder/test/render_test.dart b/packages/html_builder/test/render_test.dart deleted file mode 100644 index d26de0ae..00000000 --- a/packages/html_builder/test/render_test.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:html/parser.dart' as html5; -import 'package:angel3_html_builder/elements.dart'; -import 'package:angel3_html_builder/angel3_html_builder.dart'; -import 'package:test/test.dart'; - -void main() { - test('pretty', () { - var $dom = html( - lang: 'en', - c: [ - head(c: [ - title(c: [text('Hello, world!')]) - ]), - body( - p: {'unresolved': true}, - c: [ - h1(c: [text('Hello, world!')]), - br(), - hr(), - ], - ) - ], - ); - - var rendered = StringRenderer().render($dom); - print(rendered); - - var $parsed = html5.parse(rendered); - var $title = $parsed.querySelector('title')!; - expect($title.text.trim(), 'Hello, world!'); - var $h1 = $parsed.querySelector('h1')!; - expect($h1.text.trim(), 'Hello, world!'); - }); -} From b46356898816aca206751e3a51ddd895b551063f Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 10:52:19 +0800 Subject: [PATCH 11/22] Updated sync --- packages/sync/.gitignore | 13 --------- packages/sync/CHANGELOG.md | 5 ++++ packages/sync/LICENSE | 42 +++++++++++++++++------------ packages/sync/README.md | 8 +++--- packages/sync/analysis_options.yaml | 5 +--- packages/sync/example/main.dart | 4 +-- packages/sync/lib/angel3_sync.dart | 2 +- packages/sync/pubspec.yaml | 8 +++--- packages/sync/test/all_test.dart | 4 +-- 9 files changed, 44 insertions(+), 47 deletions(-) delete mode 100644 packages/sync/.gitignore diff --git a/packages/sync/.gitignore b/packages/sync/.gitignore deleted file mode 100644 index 321543c9..00000000 --- a/packages/sync/.gitignore +++ /dev/null @@ -1,13 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.packages -.pub/ -build/ -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ -.dart_tool \ No newline at end of file diff --git a/packages/sync/CHANGELOG.md b/packages/sync/CHANGELOG.md index c2a1dcd5..e593cb2f 100644 --- a/packages/sync/CHANGELOG.md +++ b/packages/sync/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 4.1.0 + +* Updated to use `belatuk_pub_sub` package +* Upgraded from `pendantic` to `lints` linter + ## 4.0.0 * Updated to use `angel3` packages diff --git a/packages/sync/LICENSE b/packages/sync/LICENSE index b593ac86..df5e0635 100644 --- a/packages/sync/LICENSE +++ b/packages/sync/LICENSE @@ -1,21 +1,29 @@ -MIT License +BSD 3-Clause License -Copyright (c) 2021 dukefirehawk.com +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/sync/README.md b/packages/sync/README.md index 1f46dbca..ddf43ecf 100644 --- a/packages/sync/README.md +++ b/packages/sync/README.md @@ -1,23 +1,23 @@ # Angel3 Sync -[![version](https://img.shields.io/badge/pub-v4.0.0-brightgreen)](https://pub.dartlang.org/packages/angel3_sync) +[![version](https://img.shields.io/badge/pub-v4.1.0-brightgreen)](https://pub.dev/packages/angel3_sync) [![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/sync/LICENSE) -Easily synchronize and scale WebSockets using package:angel3_pub_sub. +Easily synchronize and scale WebSockets using package:belatuk_pub_sub. ## Usage This package exposes `PubSubSynchronizationChannel`, which can simply be dropped into any `AngelWebSocket` constructor. Once you've set that up, instances of your application will automatically fire events in-sync. That's all you have to do -to scale a real-time application with Angel! +to scale a real-time application with Angel3! ```dart await app.configure(AngelWebSocket( - synchronizationChannel: new PubSubSynchronizationChannel( + synchronizationChannel: PubSubSynchronizationChannel( pub_sub.IsolateClient('', adapter.receivePort.sendPort), ), )); diff --git a/packages/sync/analysis_options.yaml b/packages/sync/analysis_options.yaml index c230cee7..ea2c9e94 100644 --- a/packages/sync/analysis_options.yaml +++ b/packages/sync/analysis_options.yaml @@ -1,4 +1 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/sync/example/main.dart b/packages/sync/example/main.dart index f654f10c..9699bfa5 100644 --- a/packages/sync/example/main.dart +++ b/packages/sync/example/main.dart @@ -5,8 +5,8 @@ import 'package:angel3_sync/angel3_sync.dart'; import 'package:angel3_test/angel3_test.dart'; import 'package:angel3_websocket/io.dart' as client; import 'package:angel3_websocket/server.dart'; -import 'package:angel3_pub_sub/isolate.dart' as pub_sub; -import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub; +import 'package:belatuk_pub_sub/isolate.dart' as pub_sub; +import 'package:belatuk_pub_sub/belatuk_pub_sub.dart' as pub_sub; import 'package:test/test.dart'; void main() { diff --git a/packages/sync/lib/angel3_sync.dart b/packages/sync/lib/angel3_sync.dart index 6c463bd9..e9cc4e05 100644 --- a/packages/sync/lib/angel3_sync.dart +++ b/packages/sync/lib/angel3_sync.dart @@ -1,6 +1,6 @@ import 'dart:async'; import 'package:angel3_websocket/angel3_websocket.dart'; -import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub; +import 'package:belatuk_pub_sub/belatuk_pub_sub.dart' as pub_sub; import 'package:stream_channel/stream_channel.dart'; /// Synchronizes WebSockets using `package:pub_sub`. diff --git a/packages/sync/pubspec.yaml b/packages/sync/pubspec.yaml index e18fc0fe..6ce1b401 100644 --- a/packages/sync/pubspec.yaml +++ b/packages/sync/pubspec.yaml @@ -1,6 +1,6 @@ name: angel3_sync -version: 4.0.0 -description: Easily synchronize and scale WebSockets using package:angel3_pub_sub for Angel3. +version: 4.1.0 +description: Easily synchronize and scale WebSockets using belatuk_pub_sub in Angel3. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/sync environment: @@ -8,9 +8,9 @@ environment: dependencies: angel3_framework: ^4.1.0 angel3_websocket: ^4.0.0 - angel3_pub_sub: ^3.0.0 + belatuk_pub_sub: ^4.0.0 stream_channel: ^2.1.0 dev_dependencies: angel3_test: ^4.0.0 test: ^1.17.8 - pedantic: ^1.11.1 \ No newline at end of file + lints: ^1.0.0 \ No newline at end of file diff --git a/packages/sync/test/all_test.dart b/packages/sync/test/all_test.dart index 4f628ce4..e732e841 100644 --- a/packages/sync/test/all_test.dart +++ b/packages/sync/test/all_test.dart @@ -5,8 +5,8 @@ import 'package:angel3_sync/angel3_sync.dart'; import 'package:angel3_test/angel3_test.dart'; import 'package:angel3_websocket/io.dart' as client; import 'package:angel3_websocket/server.dart'; -import 'package:angel3_pub_sub/isolate.dart' as pub_sub; -import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub; +import 'package:belatuk_pub_sub/isolate.dart' as pub_sub; +import 'package:belatuk_pub_sub/belatuk_pub_sub.dart' as pub_sub; import 'package:test/test.dart'; void main() { From fa42ce7294eef74005768a9a4e4507eb6a0bd56b Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 11:00:15 +0800 Subject: [PATCH 12/22] Updated production --- packages/production/CHANGELOG.md | 4 ++++ packages/production/README.md | 4 ++-- packages/production/example/main.dart | 2 +- packages/production/lib/src/runner.dart | 4 ++-- packages/production/pubspec.yaml | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/production/CHANGELOG.md b/packages/production/CHANGELOG.md index f1a655e3..c6225ab3 100644 --- a/packages/production/CHANGELOG.md +++ b/packages/production/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 3.1.0 + +* Updated to use `belatuk_pub_sub` package + ## 3.0.3 * Upgraded from `pendantic` to `lints` linter diff --git a/packages/production/README.md b/packages/production/README.md index 531a36db..1c2c8913 100644 --- a/packages/production/README.md +++ b/packages/production/README.md @@ -1,6 +1,6 @@ # Angel3 Production Runner -[![version](https://img.shields.io/badge/pub-v3.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_production) +[![version](https://img.shields.io/badge/pub-v3.1.0-brightgreen)](https://pub.dev/packages/angel3_production) [![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) @@ -45,7 +45,7 @@ When combined with `systemd`, deploying Angel3 applications on Linux can be very ## Message Passing -The `Runner` class uses [`package:angel3_pub_sub`](https://github.com/dukefirehawk/angel/tree/angel3/packages/pub_sub) to coordinate +The `Runner` class uses [`belatuk_pub_sub`]() to coordinate message passing between isolates. When one isolate sends a message, all other isolates will receive the same message, except for the isolate that sent it. diff --git a/packages/production/example/main.dart b/packages/production/example/main.dart index 7e50928b..19871d48 100644 --- a/packages/production/example/main.dart +++ b/packages/production/example/main.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:isolate'; import 'package:angel3_framework/angel3_framework.dart'; import 'package:angel3_production/angel3_production.dart'; -import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub; +import 'package:belatuk_pub_sub/belatuk_pub_sub.dart' as pub_sub; void main(List args) => Runner('example', configureServer).run(args); diff --git a/packages/production/lib/src/runner.dart b/packages/production/lib/src/runner.dart index d9560409..ad7154f7 100644 --- a/packages/production/lib/src/runner.dart +++ b/packages/production/lib/src/runner.dart @@ -9,8 +9,8 @@ import 'package:args/args.dart'; import 'package:io/ansi.dart'; import 'package:io/io.dart'; import 'package:logging/logging.dart'; -import 'package:angel3_pub_sub/isolate.dart' as pub_sub; -import 'package:angel3_pub_sub/angel3_pub_sub.dart' as pub_sub; +import 'package:belatuk_pub_sub/isolate.dart' as pub_sub; +import 'package:belatuk_pub_sub/belatuk_pub_sub.dart' as pub_sub; import 'instance_info.dart'; import 'options.dart'; diff --git a/packages/production/pubspec.yaml b/packages/production/pubspec.yaml index d6b42449..1763a5cd 100644 --- a/packages/production/pubspec.yaml +++ b/packages/production/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_production -version: 3.0.3 +version: 3.1.0 description: Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel3. homepage: https://angel3-framework.web.app repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/production @@ -8,7 +8,7 @@ environment: dependencies: angel3_container: ^3.0.0 angel3_framework: ^4.1.0 - angel3_pub_sub: ^3.0.0 + belatuk_pub_sub: ^4.0.0 args: ^2.1.0 io: ^1.0.0 logging: ^1.0.1 From d788b83ab7d6e86e94b929d0fd3bb222b6e22206 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 12:08:37 +0800 Subject: [PATCH 13/22] Updated license --- LICENSE | 2 +- packages/production/README.md | 3 +-- packages/sync/README.md | 3 +-- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/LICENSE b/LICENSE index 8f65b579..bb161745 100644 --- a/LICENSE +++ b/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/packages/production/README.md b/packages/production/README.md index 1c2c8913..a37a1cb2 100644 --- a/packages/production/README.md +++ b/packages/production/README.md @@ -3,8 +3,7 @@ [![version](https://img.shields.io/badge/pub-v3.1.0-brightgreen)](https://pub.dev/packages/angel3_production) [![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/production/LICENSE) +[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dukefirehawk/angel/tree/angel3/packages/production/LICENSE) Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel3 framework. diff --git a/packages/sync/README.md b/packages/sync/README.md index ddf43ecf..db04e14d 100644 --- a/packages/sync/README.md +++ b/packages/sync/README.md @@ -3,8 +3,7 @@ [![version](https://img.shields.io/badge/pub-v4.1.0-brightgreen)](https://pub.dev/packages/angel3_sync) [![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/sync/LICENSE) +[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dukefirehawk/angel/tree/angel3/packages/sync/LICENSE) Easily synchronize and scale WebSockets using package:belatuk_pub_sub. From e985327fe3fe2929f3611249e7a6ccb1fcae6852 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 12:33:41 +0800 Subject: [PATCH 14/22] Updated license link --- packages/production/CHANGELOG.md | 4 ++++ packages/production/README.md | 2 +- packages/production/pubspec.yaml | 2 +- packages/sync/CHANGELOG.md | 4 ++++ packages/sync/README.md | 4 ++-- packages/sync/pubspec.yaml | 2 +- 6 files changed, 13 insertions(+), 5 deletions(-) diff --git a/packages/production/CHANGELOG.md b/packages/production/CHANGELOG.md index c6225ab3..e0748c35 100644 --- a/packages/production/CHANGELOG.md +++ b/packages/production/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 3.1.1 + +* Fixed license link + ## 3.1.0 * Updated to use `belatuk_pub_sub` package diff --git a/packages/production/README.md b/packages/production/README.md index a37a1cb2..c5974902 100644 --- a/packages/production/README.md +++ b/packages/production/README.md @@ -1,6 +1,6 @@ # Angel3 Production Runner -[![version](https://img.shields.io/badge/pub-v3.1.0-brightgreen)](https://pub.dev/packages/angel3_production) +[![version](https://img.shields.io/badge/pub-v3.1.1-brightgreen)](https://pub.dev/packages/angel3_production) [![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/dart-backend/belatuk-common-utilities)](https://github.com/dukefirehawk/angel/tree/angel3/packages/production/LICENSE) diff --git a/packages/production/pubspec.yaml b/packages/production/pubspec.yaml index 1763a5cd..da2f1069 100644 --- a/packages/production/pubspec.yaml +++ b/packages/production/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_production -version: 3.1.0 +version: 3.1.1 description: Helpers for concurrency, message-passing, rotating loggers, and other production functionality in Angel3. homepage: https://angel3-framework.web.app repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/production diff --git a/packages/sync/CHANGELOG.md b/packages/sync/CHANGELOG.md index e593cb2f..f7393147 100644 --- a/packages/sync/CHANGELOG.md +++ b/packages/sync/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 4.1.1 + +* Fixed license link + ## 4.1.0 * Updated to use `belatuk_pub_sub` package diff --git a/packages/sync/README.md b/packages/sync/README.md index db04e14d..6f988d9b 100644 --- a/packages/sync/README.md +++ b/packages/sync/README.md @@ -1,11 +1,11 @@ # Angel3 Sync -[![version](https://img.shields.io/badge/pub-v4.1.0-brightgreen)](https://pub.dev/packages/angel3_sync) +[![version](https://img.shields.io/badge/pub-v4.1.1-brightgreen)](https://pub.dev/packages/angel3_sync) [![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/dart-backend/belatuk-common-utilities)](https://github.com/dukefirehawk/angel/tree/angel3/packages/sync/LICENSE) -Easily synchronize and scale WebSockets using package:belatuk_pub_sub. +Easily synchronize and scale WebSockets using [belatuk_pub_sub](). ## Usage diff --git a/packages/sync/pubspec.yaml b/packages/sync/pubspec.yaml index 6ce1b401..cce64fb5 100644 --- a/packages/sync/pubspec.yaml +++ b/packages/sync/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_sync -version: 4.1.0 +version: 4.1.1 description: Easily synchronize and scale WebSockets using belatuk_pub_sub in Angel3. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/sync From 6371c69bfe2cee95efff3ba0a2350d17416bf23e Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 12:54:37 +0800 Subject: [PATCH 15/22] Updated license --- TODO.md | 11 +++++------ packages/hot/CHANGELOG.md | 4 ++++ packages/hot/README.md | 5 ++--- packages/hot/pubspec.yaml | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/TODO.md b/TODO.md index 4fac4d47..952ef19a 100644 --- a/TODO.md +++ b/TODO.md @@ -1,16 +1,15 @@ -# Road Map +# Development Blueprint ## Short Term Goal -* Fixing issues - * ORM source code generator - * OAuth2 - * Proxy * Update examples * Update User Guide -* Update website * Performance testing ## Long Term Goal * Optimise Angel3 architecture + +### In Progress + +* Migrate generic packages that has no dependencies on Angel3 to [Common Utilities Repository](). All of these packages operate under the hood with no impact to the application build on Angel3. Updating to newer version of Angel3 packages will automatically upgrade them. diff --git a/packages/hot/CHANGELOG.md b/packages/hot/CHANGELOG.md index f973940c..625f539b 100644 --- a/packages/hot/CHANGELOG.md +++ b/packages/hot/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 4.2.1 + +* Fixed license link + ## 4.2.0 * Updated to use `belatuk_html_builder` package diff --git a/packages/hot/README.md b/packages/hot/README.md index 55bdf3de..7f87fd0f 100644 --- a/packages/hot/README.md +++ b/packages/hot/README.md @@ -1,10 +1,9 @@ # Angel3 Hot Reloader -[![version](https://img.shields.io/badge/pub-v4.2.0-brightgreen)](https://pub.dartlang.org/packages/angel3_hot) +[![version](https://img.shields.io/badge/pub-v4.2.1-brightgreen)](https://pub.dev/packages/angel3_hot) [![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/hot/LICENSE) +[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dukefirehawk/angel/tree/angel3/packages/hot/LICENSE) ![Screenshot of terminal](screenshots/angel3-screenshot.png) diff --git a/packages/hot/pubspec.yaml b/packages/hot/pubspec.yaml index c0e0186d..fce80dec 100644 --- a/packages/hot/pubspec.yaml +++ b/packages/hot/pubspec.yaml @@ -1,6 +1,6 @@ name: angel3_hot description: Supports hot reloading/hot code push of Angel3 servers on file changes. -version: 4.2.0 +version: 4.2.1 homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/hot environment: From 03a2a9385c4f8b433ede0d9fa0af34095d992d03 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 13:04:10 +0800 Subject: [PATCH 16/22] Update pub_sub --- packages/pub_sub/CHANGELOG.md | 33 +++++++++++++++++++++++---------- packages/pub_sub/README.md | 19 +++++++++++++++---- packages/pub_sub/pubspec.yaml | 2 +- 3 files changed, 39 insertions(+), 15 deletions(-) diff --git a/packages/pub_sub/CHANGELOG.md b/packages/pub_sub/CHANGELOG.md index 9b3491e5..dc6a7382 100644 --- a/packages/pub_sub/CHANGELOG.md +++ b/packages/pub_sub/CHANGELOG.md @@ -1,21 +1,34 @@ -# 3.0.2 +# Change Log + +## 3.0.3 + +* Final release. Replaced by `belatuk_pub_sub` package. + +## 3.0.2 + * Resolved static analysis warnings -# 3.0.1 +## 3.0.1 + * Resolved static analysis warnings -# 3.0.0 + +## 3.0.0 + * Migrated to work with Dart SDK 2.12.x NNBD -# 2.3.0 +## 2.3.0 + * Allow `2.x` versions of `stream_channel`. * Apply `package:pedantic` lints. -# 2.2.0 +## 2.2.0 + * Upgrade `uuid`. -# 2.1.0 -* Allow for "trusted clients," which are implicitly-registered clients. -This makes using `package:pub_sub` easier, as well making it easier to scale. +## 2.1.0 -# 2.0.0 -* Dart 2 updates. \ No newline at end of file +* Allow for "trusted clients," which are implicitly-registered clients. This makes using `package:pub_sub` easier, as well making it easier to scale. + +## 2.0.0 + +* Dart 2 updates. diff --git a/packages/pub_sub/README.md b/packages/pub_sub/README.md index d2d84569..62e9a395 100644 --- a/packages/pub_sub/README.md +++ b/packages/pub_sub/README.md @@ -1,13 +1,17 @@ -# angel3_pub_sub -[![version](https://img.shields.io/badge/pub-v3.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_pub_sub) +# Angel3 Pub Sub + +[![version](https://img.shields.io/badge/pub-v3.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_pub_sub) [![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/pub_sub/LICENSE) +**DEPRECATED: Replaced by [`belatuk_pub_sub`](https://pub.dartlang.org/packages/belatuk_pub_sub) package** + Keep application instances in sync with a simple pub/sub API. # Installation + Add `angel3_pub_sub` as a dependency in your `pubspec.yaml` file: ```yaml @@ -18,6 +22,7 @@ dependencies: Then, be sure to run `pub get` in your terminal. # Usage + `pub_sub` is your typical pub/sub API. However, `angel3_pub_sub` enforces authentication of every request. It is very possible that `angel3_pub_sub` will run on both servers and in the browser, or on a platform angel3_pub_sublike Flutter. Thus, there are provisions available to limit @@ -46,7 +51,9 @@ main() async { server.start(); } ``` + ### Trusted Clients + You can use `package:angel3_pub_sub` without explicitly registering clients, *if and only if* those clients come from trusted sources. @@ -63,6 +70,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; if it is impossible to register new clients, then malicious users cannot grant themselves additional @@ -89,8 +97,9 @@ main() async { ``` ## Isolates + If you are just running multiple instances of a server, -use `package:angel3_pub_sub/isolate.dart`. +use `package:angel3_pub_sub/isolate.dart`. You'll need one isolate to be the master. Typically this is the first isolate you create. @@ -140,6 +149,7 @@ void isolateMain(List args) { ``` ## JSON RPC 2.0 + If you are not running on isolates, you need to import `package:angel3_pub_sub/json_rpc_2.dart`. This library leverages `package:json_rpc_2` and `package:stream_channel` to create clients and servers that can hypothetically run on any @@ -148,6 +158,7 @@ medium, i.e. WebSockets, or TCP Sockets. Check out `test/json_rpc_2_test.dart` for an example of serving `angel3_pub_sub` over TCP sockets. # Protocol + `angel3_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`. @@ -220,4 +231,4 @@ The client and server in `package:angel3_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. \ No newline at end of file +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 9e6eff82..b135f12c 100644 --- a/packages/pub_sub/pubspec.yaml +++ b/packages/pub_sub/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_pub_sub -version: 3.0.2 +version: 3.0.3 description: Keep application instances in sync with a simple pub/sub API. homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/pub_sub environment: From 49ccccabf2e34bbbc089fb47357176fb4ab96ec1 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 13:10:53 +0800 Subject: [PATCH 17/22] Updated body_parser --- packages/body_parser/CHANGELOG.md | 4 ++++ packages/body_parser/README.md | 4 ++-- packages/body_parser/pubspec.yaml | 2 +- packages/cli/README.md | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/body_parser/CHANGELOG.md b/packages/body_parser/CHANGELOG.md index 45224779..4d6f97a4 100644 --- a/packages/body_parser/CHANGELOG.md +++ b/packages/body_parser/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 2.1.2 + +* Final release. Replaced by `belatuk_body_parser` package. + ## 2.1.1 * Fixed calling deprecated methods in unit test diff --git a/packages/body_parser/README.md b/packages/body_parser/README.md index b77eeb35..5ae401e1 100644 --- a/packages/body_parser/README.md +++ b/packages/body_parser/README.md @@ -1,12 +1,12 @@ # Angel3 Body Parser -[![version](https://img.shields.io/badge/pub-v2.1.1-brightgreen)](https://pub.dartlang.org/packages/angel3_body_parser) +[![version](https://img.shields.io/badge/pub-v2.1.2-brightgreen)](https://pub.dartlang.org/packages/angel3_body_parser) [![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/body_parser/LICENSE) -**Forked from `body_parser` to support NNBD** +**DEPRECATED: Replaced by [`belatuk_body_parser`](https://pub.dartlang.org/packages/belatuk_body_parser) package** Parse request bodies and query strings in Dart, as well multipart/form-data uploads. No external dependencies required. diff --git a/packages/body_parser/pubspec.yaml b/packages/body_parser/pubspec.yaml index 06bc530b..aa7d54b7 100644 --- a/packages/body_parser/pubspec.yaml +++ b/packages/body_parser/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_body_parser -version: 2.1.1 +version: 2.1.2 description: Parse request bodies and query strings in Dart. Supports JSON, URL-encoded, and multi-part bodies. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/body_parser diff --git a/packages/cli/README.md b/packages/cli/README.md index fdc51728..1f112426 100644 --- a/packages/cli/README.md +++ b/packages/cli/README.md @@ -1,3 +1,3 @@ # Angel3 CLI -Moved to [`Angel3 CLI Repo`](https://github.com/dukefirehawk/angel3-cli) \ No newline at end of file +Moved to [`Angel3 CLI Repository`](https://github.com/dukefirehawk/angel3-cli) From ad3bde2e707c99c63d271600b77abd63d3944c7e Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 13:22:01 +0800 Subject: [PATCH 18/22] Updated static --- packages/static/CHANGELOG.md | 5 +++ packages/static/LICENSE | 42 +++++++++++-------- packages/static/README.md | 5 +-- packages/static/analysis_options.yaml | 9 +--- .../static/lib/src/virtual_directory.dart | 2 +- packages/static/pubspec.yaml | 6 +-- 6 files changed, 37 insertions(+), 32 deletions(-) diff --git a/packages/static/CHANGELOG.md b/packages/static/CHANGELOG.md index 2171e60c..c8207f95 100644 --- a/packages/static/CHANGELOG.md +++ b/packages/static/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 4.1.0 + +* Updated to use `belatuk_range_header` package +* Upgraded from `pendantic` to `lints` linter + ## 4.0.2 * Updated README diff --git a/packages/static/LICENSE b/packages/static/LICENSE index 8f65b579..df5e0635 100644 --- a/packages/static/LICENSE +++ b/packages/static/LICENSE @@ -1,21 +1,29 @@ -MIT License (MIT) +BSD 3-Clause License -Copyright (c) 2021 dukefirehawk.com +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/static/README.md b/packages/static/README.md index 630067f0..855be278 100644 --- a/packages/static/README.md +++ b/packages/static/README.md @@ -1,10 +1,9 @@ # Angel3 Static Files Handler -[![version](https://img.shields.io/badge/pub-v4.0.2-brightgreen)](https://pub.dev/packages/angel3_static) +[![version](https://img.shields.io/badge/pub-v4.1.0-brightgreen)](https://pub.dev/packages/angel3_static) [![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/static/LICENSE) +[![License](https://img.shields.io/github/license/dart-backend/belatuk-common-utilities)](https://github.com/dukefirehawk/angel/tree/angel3/packages/static/LICENSE) This library provides a virtual directory to serve static files such as html, css and js for [Angel3 framework](https://pub.dev/packages/angel3). It can also handle `Range` requests, making it suitable for media streaming, i.e. music, video, etc.* diff --git a/packages/static/analysis_options.yaml b/packages/static/analysis_options.yaml index 085be64d..ea2c9e94 100644 --- a/packages/static/analysis_options.yaml +++ b/packages/static/analysis_options.yaml @@ -1,8 +1 @@ -include: package:pedantic/analysis_options.yaml -analyzer: - strong-mode: - implicit-casts: false -linter: - rules: - - unnecessary_const - - unnecessary_new \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/static/lib/src/virtual_directory.dart b/packages/static/lib/src/virtual_directory.dart index 4c779a6a..d2e6477f 100644 --- a/packages/static/lib/src/virtual_directory.dart +++ b/packages/static/lib/src/virtual_directory.dart @@ -4,7 +4,7 @@ import 'package:file/file.dart'; import 'package:http_parser/http_parser.dart'; import 'package:path/path.dart' as p; import 'package:logging/logging.dart'; -import 'package:angel3_range_header/angel3_range_header.dart'; +import 'package:belatuk_range_header/belatuk_range_header.dart'; final RegExp _param = RegExp(r':([A-Za-z0-9_]+)(\((.+)\))?'); final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)'); diff --git a/packages/static/pubspec.yaml b/packages/static/pubspec.yaml index a9c25aa3..fcb7241c 100644 --- a/packages/static/pubspec.yaml +++ b/packages/static/pubspec.yaml @@ -1,13 +1,13 @@ name: angel3_static description: This library provides a virtual directory to serve static files for Angel3 framework. -version: 4.0.2 +version: 4.1.0 homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/static environment: sdk: '>=2.12.0 <3.0.0' dependencies: angel3_framework: ^4.1.0 - angel3_range_header: ^3.0.0 + belatuk_range_header: ^4.0.0 convert: ^3.0.0 crypto: ^3.0.1 file: ^6.1.0 @@ -18,6 +18,6 @@ dev_dependencies: angel3_test: ^4.0.0 http: ^0.13.2 matcher: ^0.12.10 - pedantic: ^1.11.0 + lints: ^1.0.0 test: ^1.17.4 From 21455a327cb91db8738438b6d7e4887390079ce7 Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 20:17:05 +0800 Subject: [PATCH 19/22] Deprecated range_header --- packages/range_header/.gitignore | 71 ------------------------------ packages/range_header/CHANGELOG.md | 4 ++ packages/range_header/README.md | 4 +- packages/range_header/pubspec.yaml | 2 +- 4 files changed, 8 insertions(+), 73 deletions(-) delete mode 100644 packages/range_header/.gitignore diff --git a/packages/range_header/.gitignore b/packages/range_header/.gitignore deleted file mode 100644 index 24d68312..00000000 --- a/packages/range_header/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.dart_tool -.packages -.pub/ -build/ - -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# SDK 1.20 and later (no longer creates packages directories) - -# Older SDK versions -# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) -.project -.buildlog -**/packages/ - - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: - -## VsCode -.vscode/ - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -.idea/ -/out/ -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties diff --git a/packages/range_header/CHANGELOG.md b/packages/range_header/CHANGELOG.md index 43943b99..eb9e9e6f 100644 --- a/packages/range_header/CHANGELOG.md +++ b/packages/range_header/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 3.0.3 + +* Final release. Replaced by `belatuk_range_header` package. + ## 3.0.2 * Updated README diff --git a/packages/range_header/README.md b/packages/range_header/README.md index 4225172c..8f3dadd7 100644 --- a/packages/range_header/README.md +++ b/packages/range_header/README.md @@ -1,11 +1,13 @@ # Angel3 Range Header -[![version](https://img.shields.io/badge/pub-v3.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_range_header) +[![version](https://img.shields.io/badge/pub-v3.0.3-brightgreen)](https://pub.dartlang.org/packages/angel3_range_header) [![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/range_header/LICENSE) +**DEPRECATED: Replaced by [`belatuk_range_header`](https://pub.dartlang.org/packages/belatuk_range_header) package** + Range header parser for Angel3. Can be used by any dart backend. ## Installation diff --git a/packages/range_header/pubspec.yaml b/packages/range_header/pubspec.yaml index 06891a3d..46caa7bf 100644 --- a/packages/range_header/pubspec.yaml +++ b/packages/range_header/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_range_header -version: 3.0.2 +version: 3.0.3 description: Range header parser for Dart. Beyond parsing, a stream transformer is included. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/range_header From c0457f02044980ed8dcb5e61f486195e00545d1a Mon Sep 17 00:00:00 2001 From: thomashii Date: Sun, 12 Sep 2021 22:12:18 +0800 Subject: [PATCH 20/22] Fixed warnings --- packages/container/angel_container_generator/pubspec.yaml | 1 - packages/eventsource/pubspec.yaml | 1 - packages/framework/example/main.dart | 2 -- packages/framework/example/view.dart | 2 -- packages/framework/lib/src/core/response_context.dart | 4 +++- packages/framework/test/pretty_log.dart | 4 +++- packages/framework/test/server_test.dart | 2 +- packages/orm/angel_orm_test/lib/src/has_map_test.dart | 1 - 8 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/container/angel_container_generator/pubspec.yaml b/packages/container/angel_container_generator/pubspec.yaml index 7e8dc788..7813b67b 100644 --- a/packages/container/angel_container_generator/pubspec.yaml +++ b/packages/container/angel_container_generator/pubspec.yaml @@ -1,6 +1,5 @@ name: angel_container_generator version: 2.0.0 -author: Tobe O description: Codegen support for using pkg:reflectable with pkg:angel_container. homepage: https://github.com/angel-dart/container.git publish_to: none diff --git a/packages/eventsource/pubspec.yaml b/packages/eventsource/pubspec.yaml index 78ed7476..d13748e2 100644 --- a/packages/eventsource/pubspec.yaml +++ b/packages/eventsource/pubspec.yaml @@ -2,7 +2,6 @@ name: angel_eventsource version: 2.0.0 description: Server-sent Events (SSE) plugin for Angel. homepage: https://github.com/angel-dart/eventsource -author: Tobe O publish_to: none environment: sdk: ">=2.10.0 <3.0.0" diff --git a/packages/framework/example/main.dart b/packages/framework/example/main.dart index f0f7f3e2..8a43dca9 100644 --- a/packages/framework/example/main.dart +++ b/packages/framework/example/main.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:angel3_container/mirrors.dart'; import 'package:angel3_framework/angel3_framework.dart'; import 'package:angel3_framework/http.dart'; diff --git a/packages/framework/example/view.dart b/packages/framework/example/view.dart index dfac7d06..ea933b9d 100644 --- a/packages/framework/example/view.dart +++ b/packages/framework/example/view.dart @@ -1,5 +1,3 @@ -import 'dart:io'; - import 'package:angel3_container/mirrors.dart'; import 'package:angel3_framework/angel3_framework.dart'; import 'package:angel3_framework/http.dart'; diff --git a/packages/framework/lib/src/core/response_context.dart b/packages/framework/lib/src/core/response_context.dart index 850c3037..04c4f314 100644 --- a/packages/framework/lib/src/core/response_context.dart +++ b/packages/framework/lib/src/core/response_context.dart @@ -243,7 +243,9 @@ abstract class ResponseContext final m = _findRoute(route.router); if (m != null) return m; - } else if (route.name == name) return route; + } else if (route.name == name) { + return route; + } } return null; diff --git a/packages/framework/test/pretty_log.dart b/packages/framework/test/pretty_log.dart index 83427f07..30296e30 100644 --- a/packages/framework/test/pretty_log.dart +++ b/packages/framework/test/pretty_log.dart @@ -31,6 +31,8 @@ AnsiCode chooseLogColor(Level level) { } else if (level == Level.CONFIG || level == Level.FINE || level == Level.FINER || - level == Level.FINEST) return lightGray; + level == Level.FINEST) { + return lightGray; + } return resetAll; } diff --git a/packages/framework/test/server_test.dart b/packages/framework/test/server_test.dart index ed14183b..de3175a3 100644 --- a/packages/framework/test/server_test.dart +++ b/packages/framework/test/server_test.dart @@ -220,5 +220,5 @@ class CustomCloseService extends Service { @Expose('/foo') class FooController extends Controller { @Expose('/bar') - bar() async => 'baz'; + Future bar() async => 'baz'; } diff --git a/packages/orm/angel_orm_test/lib/src/has_map_test.dart b/packages/orm/angel_orm_test/lib/src/has_map_test.dart index 858c4d2c..97ff210b 100644 --- a/packages/orm/angel_orm_test/lib/src/has_map_test.dart +++ b/packages/orm/angel_orm_test/lib/src/has_map_test.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:convert'; import 'package:angel3_orm/angel3_orm.dart'; import 'package:test/test.dart'; import 'models/has_map.dart'; From 9865ed93d28cab2e12859e4550bca225fbce31f7 Mon Sep 17 00:00:00 2001 From: thomashii Date: Mon, 13 Sep 2021 08:30:02 +0800 Subject: [PATCH 21/22] Updated Jael to use belatuk_symbol_table --- packages/jael/.gitignore | 51 ------------- packages/jael/.idea/misc.xml | 6 -- packages/jael/.idea/modules.xml | 8 --- ...locks_within_blocks_in_block_test_dart.xml | 8 --- .../for_loop_in_render_test_dart.xml | 8 --- .../.idea/runConfigurations/jael__example.xml | 7 -- .../.idea/runConfigurations/main_dart.xml | 7 -- .../tests_in_dsx_test_dart.xml | 7 -- .../.idea/runConfigurations/tests_in_jael.xml | 8 --- packages/jael/.idea/vcs.xml | 6 -- packages/jael/angel_jael/.gitignore | 71 ------------------- packages/jael/angel_jael/CHANGELOG.md | 27 +++++-- packages/jael/angel_jael/LICENSE | 42 ++++++----- packages/jael/angel_jael/README.md | 37 ++++------ .../jael/angel_jael/analysis_options.yaml | 4 +- packages/jael/angel_jael/lib/angel3_jael.dart | 2 +- packages/jael/angel_jael/pubspec.yaml | 15 ++-- packages/jael/jael/.gitignore | 71 ------------------- packages/jael/jael/CHANGELOG.md | 48 +++++++++---- packages/jael/jael/LICENSE | 42 ++++++----- packages/jael/jael/README.md | 19 ++--- packages/jael/jael/analysis_options.yaml | 5 +- packages/jael/jael/bin/jaelfmt.dart | 8 ++- packages/jael/jael/example/main.dart | 2 +- packages/jael/jael/lib/src/ast/call.dart | 2 +- .../jael/jael/lib/src/ast/expression.dart | 2 +- .../jael/jael/lib/src/ast/identifier.dart | 2 +- packages/jael/jael/lib/src/ast/member.dart | 2 +- packages/jael/jael/lib/src/ast/string.dart | 2 +- packages/jael/jael/lib/src/renderer.dart | 6 +- packages/jael/jael/pubspec.yaml | 6 +- .../jael/test/render/custom_element_test.dart | 2 +- packages/jael/jael/test/render/dsx_test.dart | 2 +- .../jael/jael/test/render/render_test.dart | 2 +- packages/jael/jael_language_server/.gitignore | 21 ------ packages/jael/jael_preprocessor/.gitignore | 71 ------------------- packages/jael/jael_preprocessor/CHANGELOG.md | 30 +++++--- packages/jael/jael_preprocessor/LICENSE | 42 ++++++----- packages/jael/jael_preprocessor/README.md | 19 ++--- .../jael_preprocessor/analysis_options.yaml | 5 +- .../lib/jael3_preprocessor.dart | 2 +- packages/jael/jael_preprocessor/pubspec.yaml | 11 +-- .../jael_preprocessor/test/block_test.dart | 2 +- .../jael_preprocessor/test/include_test.dart | 2 +- packages/jael/jael_web/.gitignore | 16 ----- 45 files changed, 231 insertions(+), 527 deletions(-) delete mode 100644 packages/jael/.gitignore delete mode 100644 packages/jael/.idea/misc.xml delete mode 100644 packages/jael/.idea/modules.xml delete mode 100644 packages/jael/.idea/runConfigurations/blocks_within_blocks_in_block_test_dart.xml delete mode 100644 packages/jael/.idea/runConfigurations/for_loop_in_render_test_dart.xml delete mode 100644 packages/jael/.idea/runConfigurations/jael__example.xml delete mode 100644 packages/jael/.idea/runConfigurations/main_dart.xml delete mode 100644 packages/jael/.idea/runConfigurations/tests_in_dsx_test_dart.xml delete mode 100644 packages/jael/.idea/runConfigurations/tests_in_jael.xml delete mode 100644 packages/jael/.idea/vcs.xml delete mode 100644 packages/jael/angel_jael/.gitignore delete mode 100644 packages/jael/jael/.gitignore delete mode 100644 packages/jael/jael_language_server/.gitignore delete mode 100644 packages/jael/jael_preprocessor/.gitignore delete mode 100644 packages/jael/jael_web/.gitignore diff --git a/packages/jael/.gitignore b/packages/jael/.gitignore deleted file mode 100644 index 37e7b7e6..00000000 --- a/packages/jael/.gitignore +++ /dev/null @@ -1,51 +0,0 @@ -# Created by .ignore support plugin (hsz.mobi) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: -.idea/**/workspace.xml -.idea/**/tasks.xml -.idea/dictionaries - -# Sensitive or high-churn files: -.idea/**/dataSources/ -.idea/**/dataSources.ids -.idea/**/dataSources.xml -.idea/**/dataSources.local.xml -.idea/**/sqlDataSources.xml -.idea/**/dynamic.xml -.idea/**/uiDesigner.xml - -# Gradle: -.idea/**/gradle.xml -.idea/**/libraries - -# CMake -cmake-build-debug/ - -# Mongo Explorer plugin: -.idea/**/mongoSettings.xml - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -out/ - -# mpeltonen/sbt-idea plugin -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Cursive Clojure plugin -.idea/replstate.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties diff --git a/packages/jael/.idea/misc.xml b/packages/jael/.idea/misc.xml deleted file mode 100644 index 639900d1..00000000 --- a/packages/jael/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/packages/jael/.idea/modules.xml b/packages/jael/.idea/modules.xml deleted file mode 100644 index d171efec..00000000 --- a/packages/jael/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/packages/jael/.idea/runConfigurations/blocks_within_blocks_in_block_test_dart.xml b/packages/jael/.idea/runConfigurations/blocks_within_blocks_in_block_test_dart.xml deleted file mode 100644 index 5032bd0a..00000000 --- a/packages/jael/.idea/runConfigurations/blocks_within_blocks_in_block_test_dart.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/jael/.idea/runConfigurations/for_loop_in_render_test_dart.xml b/packages/jael/.idea/runConfigurations/for_loop_in_render_test_dart.xml deleted file mode 100644 index de242953..00000000 --- a/packages/jael/.idea/runConfigurations/for_loop_in_render_test_dart.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/jael/.idea/runConfigurations/jael__example.xml b/packages/jael/.idea/runConfigurations/jael__example.xml deleted file mode 100644 index 5b6d4161..00000000 --- a/packages/jael/.idea/runConfigurations/jael__example.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/jael/.idea/runConfigurations/main_dart.xml b/packages/jael/.idea/runConfigurations/main_dart.xml deleted file mode 100644 index 644077c1..00000000 --- a/packages/jael/.idea/runConfigurations/main_dart.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/jael/.idea/runConfigurations/tests_in_dsx_test_dart.xml b/packages/jael/.idea/runConfigurations/tests_in_dsx_test_dart.xml deleted file mode 100644 index 9c1ec0de..00000000 --- a/packages/jael/.idea/runConfigurations/tests_in_dsx_test_dart.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/jael/.idea/runConfigurations/tests_in_jael.xml b/packages/jael/.idea/runConfigurations/tests_in_jael.xml deleted file mode 100644 index b905e806..00000000 --- a/packages/jael/.idea/runConfigurations/tests_in_jael.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/packages/jael/.idea/vcs.xml b/packages/jael/.idea/vcs.xml deleted file mode 100644 index 94a25f7f..00000000 --- a/packages/jael/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/packages/jael/angel_jael/.gitignore b/packages/jael/angel_jael/.gitignore deleted file mode 100644 index 24d68312..00000000 --- a/packages/jael/angel_jael/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.dart_tool -.packages -.pub/ -build/ - -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# SDK 1.20 and later (no longer creates packages directories) - -# Older SDK versions -# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) -.project -.buildlog -**/packages/ - - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: - -## VsCode -.vscode/ - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -.idea/ -/out/ -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties diff --git a/packages/jael/angel_jael/CHANGELOG.md b/packages/jael/angel_jael/CHANGELOG.md index 087530c4..e7cb5908 100644 --- a/packages/jael/angel_jael/CHANGELOG.md +++ b/packages/jael/angel_jael/CHANGELOG.md @@ -1,19 +1,32 @@ -# 4.0.0 +# Change Log + +## 4.1.0 + +* Updated to use `belatuk_symbol_table` package +* Upgraded from `pendantic` to `lints` linter + +## 4.0.0 + * Migrated to support Dart SDK 2.12.x NNBD -# 3.0.0 +## 3.0.0 + * Migrated to work with Dart SDK 2.12.x Non NNBD -# 2.0.0 +## 2.0.0 + * Angel 2 and Dart 2 updates. * Default to `.jael` instead of `.jl`. -# 1.0.3 +## 1.0.3 + * Update for annoying map casting bug. -# 1.0.2 +## 1.0.2 + * Update for DSX support. * Clear the buffer on errors. -# 1.0.1 -* Use `Renderer.errorDocument`. \ No newline at end of file +## 1.0.1 + +* Use `Renderer.errorDocument`. diff --git a/packages/jael/angel_jael/LICENSE b/packages/jael/angel_jael/LICENSE index 8f65b579..df5e0635 100644 --- a/packages/jael/angel_jael/LICENSE +++ b/packages/jael/angel_jael/LICENSE @@ -1,21 +1,29 @@ -MIT License (MIT) +BSD 3-Clause License -Copyright (c) 2021 dukefirehawk.com +Copyright (c) 2021, dukefirehawk.com +All rights reserved. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/packages/jael/angel_jael/README.md b/packages/jael/angel_jael/README.md index f5a827e5..db0b0e3d 100644 --- a/packages/jael/angel_jael/README.md +++ b/packages/jael/angel_jael/README.md @@ -1,25 +1,23 @@ -# angel3_jael -[![version](https://img.shields.io/badge/pub-v4.0.1-brightgreen)](https://pub.dartlang.org/packages/angel3_jael) +# Angel3 Jael + +[![version](https://img.shields.io/badge/pub-v4.1.0-brightgreen)](https://pub.dev/packages/angel3_jael) [![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/dart-backend/belatuk-common-utilities)](https://github.com/dukefirehawk/angel/tree/angel3/packages/jael/angel_jael/LICENSE) -[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/angel3/packages/jael/angel_jael/LICENSE) +[Angel 3](https://github.com/dukefirehawk/angel/tree/angel3) support for [Jael 3](https://github.com/dukefirehawk/angel/tree/angel3/packages/jael/jael). +## Installation - -[Angel](https://github.com/dukefirehawk/angel/tree/angel3) -support for -[Jael](https://github.com/dukefirehawk/angel/tree/angel3/packages/jael/jael). - -# Installation In your `pubspec.yaml`: ```yaml dependencies: - angel3_jael: ^4.0.0 + angel3_jael: ^4.1.0 ``` -# Usage +## Usage + Just like `mustache` and other renderers, configuring Angel to use Jael is as simple as calling `app.configure`: @@ -38,19 +36,15 @@ AngelConfigurer myPlugin(FileSystem fileSystem) { } ``` -`package:angel3_jael` supports caching views, to improve server performance. -You might not want to enable this in development, so consider setting -the flag to `app.isProduction`: +`package:angel3_jael` supports caching views, to improve server performance. You might not want to enable this in development, so consider setting the flag to `app.isProduction`: -``` +```dart jael(viewsDirectory, cacheViews: app.isProduction); ``` -Keep in mind that this package uses `package:file`, rather than -`dart:io`. +Keep in mind that this package uses `package:file`, rather than `dart:io`. -The following is a basic example of a server setup that can render Jael -templates from a directory named `views`: +The following is a basic example of a server setup that can render Jael templates from a directory named `views`: ```dart import 'package:angel3_framework/angel3_framework.dart'; @@ -58,7 +52,7 @@ import 'package:angel3_jael/angel3_jael.dart'; import 'package:file/local.dart'; import 'package:logging/logging.dart'; -main() async { +void main() async { var app = Angel(); var fileSystem = const LocalFileSystem(); @@ -83,5 +77,4 @@ main() async { } ``` -To apply additional transforms to parsed documents, provide a -set of `patch` functions, like in `package:jael3_preprocessor`. \ No newline at end of file +To apply additional transforms to parsed documents, provide a set of `patch` functions, like in `package:jael3_preprocessor`. diff --git a/packages/jael/angel_jael/analysis_options.yaml b/packages/jael/angel_jael/analysis_options.yaml index eae1e42a..ea2c9e94 100644 --- a/packages/jael/angel_jael/analysis_options.yaml +++ b/packages/jael/angel_jael/analysis_options.yaml @@ -1,3 +1 @@ -analyzer: - strong-mode: - implicit-casts: false \ No newline at end of file +include: package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/jael/angel_jael/lib/angel3_jael.dart b/packages/jael/angel_jael/lib/angel3_jael.dart index 1a8e92d9..d126a741 100644 --- a/packages/jael/angel_jael/lib/angel3_jael.dart +++ b/packages/jael/angel_jael/lib/angel3_jael.dart @@ -3,7 +3,7 @@ import 'package:angel3_code_buffer/angel3_code_buffer.dart'; import 'package:file/file.dart'; import 'package:jael3/jael3.dart'; import 'package:jael3_preprocessor/jael3_preprocessor.dart'; -import 'package:angel3_symbol_table/angel3_symbol_table.dart'; +import 'package:belatuk_symbol_table/belatuk_symbol_table.dart'; /// Configures an Angel server to use Jael to render templates. /// diff --git a/packages/jael/angel_jael/pubspec.yaml b/packages/jael/angel_jael/pubspec.yaml index c11e0755..c113b104 100644 --- a/packages/jael/angel_jael/pubspec.yaml +++ b/packages/jael/angel_jael/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_jael -version: 4.0.0 +version: 4.1.0 description: Angel support for the Jael templating engine, similar to Blade or Liquid. homepage: https://github.com/dukefirehawk/angel/tree/angel3/packages/jael/angel_jael environment: @@ -7,15 +7,18 @@ environment: dependencies: angel3_framework: ^4.0.0 angel3_code_buffer: ^2.0.0 - angel3_symbol_table: ^2.0.0 - jael3: ^4.0.0 - jael3_preprocessor: ^4.0.0 + belatuk_symbol_table: ^3.0.0 + jael3: ^4.1.0 + jael3_preprocessor: ^4.1.0 file: ^6.0.0 logging: ^1.0.1 dev_dependencies: angel3_test: ^4.0.0 html: ^0.15.0 test: ^1.17.3 + lints: ^1.0.0 #dependency_overrides: -# web_socket_channel: ^2.0.0 -# http: ^0.13.0 \ No newline at end of file +# jael3: +# path: ../jael +# jael3_preprocessor: +# path: ../jael_preprocessor diff --git a/packages/jael/jael/.gitignore b/packages/jael/jael/.gitignore deleted file mode 100644 index 24d68312..00000000 --- a/packages/jael/jael/.gitignore +++ /dev/null @@ -1,71 +0,0 @@ -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub -.dart_tool -.packages -.pub/ -build/ - -# If you're building an application, you may want to check-in your pubspec.lock -pubspec.lock - -# Directory created by dartdoc -# If you don't generate documentation locally you can remove this line. -doc/api/ - -### Dart template -# See https://www.dartlang.org/tools/private-files.html - -# Files and directories created by pub - -# SDK 1.20 and later (no longer creates packages directories) - -# Older SDK versions -# (Include if the minimum SDK version specified in pubsepc.yaml is earlier than 1.20) -.project -.buildlog -**/packages/ - - -# Files created by dart2js -# (Most Dart developers will use pub build to compile Dart, use/modify these -# rules if you intend to use dart2js directly -# Convention is to use extension '.dart.js' for Dart compiled to Javascript to -# differentiate from explicit Javascript files) -*.dart.js -*.part.js -*.js.deps -*.js.map -*.info.json - -# Directory created by dartdoc - -# Don't commit pubspec lock file -# (Library packages only! Remove pattern if developing an application package) -### JetBrains template -# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm -# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 - -# User-specific stuff: - -## VsCode -.vscode/ - -## File-based project format: -*.iws - -## Plugin-specific files: - -# IntelliJ -.idea/ -/out/ -.idea_modules/ - -# JIRA plugin -atlassian-ide-plugin.xml - -# Crashlytics plugin (for Android Studio and IntelliJ) -com_crashlytics_export_strings.xml -crashlytics.properties -crashlytics-build.properties -fabric.properties diff --git a/packages/jael/jael/CHANGELOG.md b/packages/jael/jael/CHANGELOG.md index 9f064517..09392106 100644 --- a/packages/jael/jael/CHANGELOG.md +++ b/packages/jael/jael/CHANGELOG.md @@ -1,48 +1,68 @@ -# 4.0.0 +# Change Log + +## 4.1.0 + +* Updated to use `belatuk_symbol_table` package +* Upgraded from `pendantic` to `lints` linter + +## 4.0.0 + * Migrated to support Dart SDK 2.12.x NNBD -# 3.0.0 +## 3.0.0 + * Migrated to work with Dart SDK 2.12.x Non NNBD -# 2.0.2 +## 2.0.2 + * Fixed handling of `if` in non-strict mode. * Roll `JaelFormatter` and `jaelfmt`. -# 2.0.1 +## 2.0.1 + * Fixed bug where the `textarea` name check would never return `true`. -# 2.0.0+1 +## 2.0.0+1 + * Meta-update for Pub score. -# 2.0.0 +## 2.0.0 + * Dart 2 updates. * Remove usage of `package:dart2_constant`. -# 1.0.6+1 +## 1.0.6+1 + * Ensure `` passes attributes. -# 1.0.6 +## 1.0.6 + * Add `index-as` to `for-each`. * Support registering + rendering custom elements. * Improve handling of booleans in non-strict mode. -# 1.0.5 +## 1.0.5 + * Add support for DSX, a port of JSX to Dart. -# 1.0.4 +## 1.0.4 + * Skip HTML comments in free text. -# 1.0.3 +## 1.0.3 + * Fix a scanner bug that prevented proper parsing of HTML nodes followed by free text. * Don't trim `