diff --git a/packages/jael/angel_jael/CHANGELOG.md b/packages/jael/angel_jael/CHANGELOG.md index 21a32dbe..d93b153b 100644 --- a/packages/jael/angel_jael/CHANGELOG.md +++ b/packages/jael/angel_jael/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 4.2.2 + +* Set default `cacheViews` to true + ## 4.2.1 * Added `minified` parameter for generating minified HTML output diff --git a/packages/jael/angel_jael/lib/angel3_jael.dart b/packages/jael/angel_jael/lib/angel3_jael.dart index be194ee3..ae51dc8c 100644 --- a/packages/jael/angel_jael/lib/angel3_jael.dart +++ b/packages/jael/angel_jael/lib/angel3_jael.dart @@ -14,19 +14,19 @@ import 'package:belatuk_symbol_table/belatuk_symbol_table.dart'; /// /// To apply additional transforms to parsed documents, provide a set of [patch] functions. AngelConfigurer jael(Directory viewsDirectory, - {String? fileExtension, + {String fileExtension = '.jael', bool strictResolution = false, - bool cacheViews = false, + bool cacheViews = true, Iterable patch = const [], bool asDSX = false, bool minified = false, CodeBuffer Function()? createBuffer}) { - var cache = {}; - fileExtension ??= '.jael'; - if (createBuffer == null && minified) { - createBuffer = () => CodeBuffer(space: '', newline: ''); - } else { - createBuffer ??= () => CodeBuffer(); + var cache = {}; + + var bufferFunc = createBuffer ?? () => CodeBuffer(); + + if (minified) { + bufferFunc = () => CodeBuffer(space: '', newline: ''); } return (Angel app) async { @@ -34,28 +34,33 @@ AngelConfigurer jael(Directory viewsDirectory, var errors = []; Document? processed; - if (cacheViews == true && cache.containsKey(name)) { + if (cacheViews && cache.containsKey(name)) { processed = cache[name]; } else { - var file = viewsDirectory.childFile(name + fileExtension!); + var file = viewsDirectory.childFile(name + fileExtension); var contents = await file.readAsString(); var doc = parseDocument(contents, - sourceUrl: file.uri, asDSX: asDSX, onError: errors.add)!; - processed = doc; + sourceUrl: file.uri, asDSX: asDSX, onError: errors.add); + if (doc == null) { + throw ArgumentError(name + fileExtension + " does not exists"); + } try { processed = await (resolve(doc, viewsDirectory, patch: patch, onError: errors.add)); - } catch (_) { + } catch (e) { // Ignore these errors, so that we can show syntax errors. } + if (processed == null) { + throw ArgumentError(name + fileExtension + " does not exists"); + } - if (cacheViews == true) { + if (cacheViews) { cache[name] = processed; } } - var buf = createBuffer!(); + var buf = bufferFunc(); var scope = SymbolTable( values: locals?.keys.fold>({}, (out, k) => out..[k.toString()] = locals[k]) ?? diff --git a/packages/jael/angel_jael/pubspec.yaml b/packages/jael/angel_jael/pubspec.yaml index 976e08b7..4ae6cf1f 100644 --- a/packages/jael/angel_jael/pubspec.yaml +++ b/packages/jael/angel_jael/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_jael -version: 4.2.1 +version: 4.2.2 description: Angel support for the Jael templating engine, similar to Blade or Liquid. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/jael/angel_jael @@ -17,9 +17,4 @@ dev_dependencies: angel3_test: ^4.0.0 html: ^0.15.0 test: ^1.17.3 - lints: ^1.0.0 -#dependency_overrides: -# jael3: -# path: ../jael -# jael3_preprocessor: -# path: ../jael_preprocessor + lints: ^1.0.0 \ No newline at end of file diff --git a/packages/jael/angel_jael/test/minified_test.dart b/packages/jael/angel_jael/test/minified_test.dart index 5f41fd32..e4d4f27d 100644 --- a/packages/jael/angel_jael/test/minified_test.dart +++ b/packages/jael/angel_jael/test/minified_test.dart @@ -72,4 +72,21 @@ void main() { .trim()) .outerHtml); }); + + test('can render multiples', () async { + var response = await client.get(Uri.parse('/github/thosakwe')); + response = await client.get(Uri.parse('/github/thosakwe')); + response = await client.get(Uri.parse('/github/thosakwe')); + response = await client.get(Uri.parse('/github/thosakwe')); + response = await client.get(Uri.parse('/github/thosakwe')); + + print('Body:\n${response.body}'); + expect( + html.parse(response.body).outerHtml, + html + .parse( + '''Hellothosakwe''' + .trim()) + .outerHtml); + }); } diff --git a/packages/jael/jael_language_server/LICENSE b/packages/jael/jael_language_server/LICENSE index 8f65b579..df5e0635 100644 --- a/packages/jael/jael_language_server/LICENSE +++ b/packages/jael/jael_language_server/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/jael_language_server/analysis_options.yaml b/packages/jael/jael_language_server/analysis_options.yaml index c230cee7..ea2c9e94 100644 --- a/packages/jael/jael_language_server/analysis_options.yaml +++ b/packages/jael/jael_language_server/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/jael/jael_language_server/bin/jael_language_server.dart b/packages/jael/jael_language_server/bin/jael3_language_server.dart similarity index 93% rename from packages/jael/jael_language_server/bin/jael_language_server.dart rename to packages/jael/jael_language_server/bin/jael3_language_server.dart index 39033ce1..8ee56411 100644 --- a/packages/jael/jael_language_server/bin/jael_language_server.dart +++ b/packages/jael/jael_language_server/bin/jael3_language_server.dart @@ -4,8 +4,8 @@ import 'package:args/args.dart'; import 'package:io/ansi.dart'; import 'package:io/io.dart'; //import 'package:dart_language_server/dart_language_server.dart'; -import 'package:jael_language_server/jael_language_server.dart'; -import 'package:jael_language_server/src/protocol/language_server/server.dart'; +import 'package:jael3_language_server/jael3_language_server.dart'; +import 'package:jael3_language_server/src/protocol/language_server/server.dart'; void main(List args) async { var argParser = ArgParser() diff --git a/packages/jael/jael_language_server/lib/jael_language_server.dart b/packages/jael/jael_language_server/lib/jael3_language_server.dart similarity index 100% rename from packages/jael/jael_language_server/lib/jael_language_server.dart rename to packages/jael/jael_language_server/lib/jael3_language_server.dart diff --git a/packages/jael/jael_language_server/lib/src/analyzer.dart b/packages/jael/jael_language_server/lib/src/analyzer.dart index f9944e7d..5ca4084a 100644 --- a/packages/jael/jael_language_server/lib/src/analyzer.dart +++ b/packages/jael/jael_language_server/lib/src/analyzer.dart @@ -1,6 +1,6 @@ -import 'package:jael/jael.dart'; +import 'package:jael3/jael3.dart'; import 'package:logging/logging.dart'; -import 'package:symbol_table/symbol_table.dart'; +import 'package:belatuk_symbol_table/belatuk_symbol_table.dart'; import 'object.dart'; class Analyzer extends Parser { diff --git a/packages/jael/jael_language_server/lib/src/server.dart b/packages/jael/jael_language_server/lib/src/server.dart index 2354ec19..52517cb9 100644 --- a/packages/jael/jael_language_server/lib/src/server.dart +++ b/packages/jael/jael_language_server/lib/src/server.dart @@ -4,13 +4,13 @@ import 'dart:async'; import 'package:file/file.dart'; import 'package:file/local.dart'; import 'package:file/memory.dart'; -import 'package:jael/jael.dart'; +import 'package:jael3/jael3.dart'; import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc_2; import 'package:logging/logging.dart'; import 'package:path/path.dart' as p; import 'package:source_span/source_span.dart'; import 'package:string_scanner/string_scanner.dart'; -import 'package:symbol_table/symbol_table.dart'; +import 'package:belatuk_symbol_table/belatuk_symbol_table.dart'; import 'analyzer.dart'; import 'object.dart'; import 'protocol/language_server/interface.dart'; diff --git a/packages/jael/jael_language_server/pubspec.yaml b/packages/jael/jael_language_server/pubspec.yaml index 70e64626..20f550aa 100644 --- a/packages/jael/jael_language_server/pubspec.yaml +++ b/packages/jael/jael_language_server/pubspec.yaml @@ -1,5 +1,5 @@ -name: jael_language_server -version: 0.0.0 +name: jael3_language_server +version: 1.0.0 description: Language Server Protocol implementation for the Jael templating engine. homepage: https://github.com/angel-dart/vscode publish_to: none @@ -10,27 +10,15 @@ dependencies: # dart_language_server: ^0.1.16 file: ^6.1.2 io: ^1.0.0 - jael: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/jael/jael - jael_preprocessor: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/jael/jael_preprocessor + jael3: ^4.2.0 + jael3_preprocessor: ^4.2.0 json_rpc_2: ^3.0.1 logging: ^1.0.1 path: ^1.8.0 source_span: ^1.8.1 string_scanner: ^1.1.0 - symbol_table: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/symbol_table - pedantic: ^1.11.0 + belatuk_symbol_table: ^3.0.0 + lints: ^1.0.0 executables: - jael_language_server: jael_language_server + jael3_language_server: jael3_language_server \ No newline at end of file diff --git a/packages/jael/jael_web/LICENSE b/packages/jael/jael_web/LICENSE index 89074fd3..df5e0635 100644 --- a/packages/jael/jael_web/LICENSE +++ b/packages/jael/jael_web/LICENSE @@ -1,21 +1,29 @@ -MIT License +BSD 3-Clause License -Copyright (c) 2017 The Angel Framework +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/jael/jael_web/README.md b/packages/jael/jael_web/README.md index bd31ee48..22234379 100644 --- a/packages/jael/jael_web/README.md +++ b/packages/jael/jael_web/README.md @@ -1,6 +1,7 @@ -# jael_web +# JAEL3 Web + [![Pub](https://img.shields.io/pub/v/jael_web.svg)](https://pub.dartlang.org/packages/jael_web) [![build status](https://travis-ci.org/angel-dart/jael_web.svg)](https://travis-ci.org/angel-dart/jael) Experimental virtual DOM/SPA engine built on Jael. Supports SSR. -**Not ready for production use.** \ No newline at end of file +**Not ready for production use.** diff --git a/packages/jael/jael_web/analysis_options.yaml b/packages/jael/jael_web/analysis_options.yaml index eae1e42a..ea2c9e94 100644 --- a/packages/jael/jael_web/analysis_options.yaml +++ b/packages/jael/jael_web/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/jael_web/build.yaml b/packages/jael/jael_web/build.yaml index 9082d3c2..0538161d 100644 --- a/packages/jael/jael_web/build.yaml +++ b/packages/jael/jael_web/build.yaml @@ -1,10 +1,10 @@ builders: jael_web: - import: "package:jael_web/builder.dart" + import: "package:jael3_web/builder.dart" builder_factories: - jaelComponentBuilder build_extensions: .dart: - - .jael_web_cmp.g.part + - .jael3_web_cmp.g.part auto_apply: root_package applies_builders: ["source_gen|combining_builder", "source_gen|part_cleanup"] \ No newline at end of file diff --git a/packages/jael/jael_web/example/main.dart b/packages/jael/jael_web/example/main.dart index 4520daeb..183357a0 100644 --- a/packages/jael/jael_web/example/main.dart +++ b/packages/jael/jael_web/example/main.dart @@ -1,5 +1,5 @@ -import 'package:jael_web/jael_web.dart'; -import 'package:jael_web/elements.dart'; +import 'package:jael3_web/jael3_web.dart'; +import 'package:jael3_web/elements.dart'; part 'main.g.dart'; @Jael(template: ''' @@ -9,6 +9,7 @@ part 'main.g.dart'; ''') class Hello extends Component with _HelloJaelTemplate { + @override DateTime get now => DateTime.now(); } diff --git a/packages/jael/jael_web/example/stateful.dart b/packages/jael/jael_web/example/stateful.dart index 0a10444f..783295e1 100644 --- a/packages/jael/jael_web/example/stateful.dart +++ b/packages/jael/jael_web/example/stateful.dart @@ -1,5 +1,5 @@ import 'dart:async'; -import 'package:jael_web/jael_web.dart'; +import 'package:jael3_web/jael3_web.dart'; part 'stateful.g.dart'; void main() {} diff --git a/packages/jael/jael_web/example/using_components.dart b/packages/jael/jael_web/example/using_components.dart index 955426e8..bf684f67 100644 --- a/packages/jael/jael_web/example/using_components.dart +++ b/packages/jael/jael_web/example/using_components.dart @@ -1,4 +1,4 @@ -import 'package:jael_web/jael_web.dart'; +import 'package:jael3_web/jael3_web.dart'; part 'using_components.g.dart'; @Jael(template: ''' @@ -19,6 +19,7 @@ class MyApp extends Component with _MyAppJaelTemplate {} ''') class LabeledInput extends Component with _LabeledInputJaelTemplate { + @override final String? name; LabeledInput({this.name}); diff --git a/packages/jael/jael_web/lib/jael_web.dart b/packages/jael/jael_web/lib/jael3_web.dart similarity index 100% rename from packages/jael/jael_web/lib/jael_web.dart rename to packages/jael/jael_web/lib/jael3_web.dart diff --git a/packages/jael/jael_web/lib/src/builder/builder.dart b/packages/jael/jael_web/lib/src/builder/builder.dart index 473e7ffe..3b61cf08 100644 --- a/packages/jael/jael_web/lib/src/builder/builder.dart +++ b/packages/jael/jael_web/lib/src/builder/builder.dart @@ -2,9 +2,9 @@ import 'dart:async'; import 'package:analyzer/dart/element/element.dart'; import 'package:build/build.dart'; import 'package:code_builder/code_builder.dart'; -import 'package:jael/jael.dart' as jael; -import 'package:jael_preprocessor/jael_preprocessor.dart' as jael; -import 'package:jael_web/jael_web.dart'; +import 'package:jael3/jael3.dart' as jael; +import 'package:jael3_preprocessor/jael3_preprocessor.dart' as jael; +import 'package:jael3_web/jael3_web.dart'; import 'package:path/path.dart' as p; import 'package:source_gen/source_gen.dart'; import 'util.dart'; @@ -12,7 +12,7 @@ import 'util.dart'; var _upper = RegExp(r'^[A-Z]'); Builder jaelComponentBuilder(_) { - return SharedPartBuilder([JaelComponentGenerator()], 'jael_web_cmp'); + return SharedPartBuilder([JaelComponentGenerator()], 'jael3_web_cmp'); } class JaelComponentGenerator extends GeneratorForAnnotation { @@ -33,9 +33,9 @@ class JaelComponentGenerator extends GeneratorForAnnotation { throw 'Both `template` and `templateUrl` cannot be null.'; } - if (ann.template != null) + if (ann.template != null) { templateString = ann.template; - else { + } else { var dir = p.dirname(inputId.path); var assetId = AssetId(inputId.package, p.join(dir, ann.templateUrl)); if (!await buildStep.canRead(assetId)) { @@ -47,7 +47,7 @@ class JaelComponentGenerator extends GeneratorForAnnotation { var fs = BuildFileSystem(buildStep, inputId.package); var errors = []; - var doc = await jael.parseDocument(templateString!, + var doc = jael.parseDocument(templateString!, sourceUrl: inputId.uri, asDSX: ann.asDsx!, onError: errors.add); if (errors.isEmpty) { doc = await jael.resolve(doc!, fs.file(inputId.uri).parent, diff --git a/packages/jael/jael_web/pubspec.yaml b/packages/jael/jael_web/pubspec.yaml index 0237d4c8..dd02801f 100644 --- a/packages/jael/jael_web/pubspec.yaml +++ b/packages/jael/jael_web/pubspec.yaml @@ -1,5 +1,5 @@ -name: jael_web -version: 0.0.0 +name: jael3_web +version: 1.0.0 description: Experimental virtual DOM/SPA engine built on Jael. Supports SSR. publish_to: none environment: @@ -8,18 +8,10 @@ dependencies: build: ^2.0.2 build_config: ^1.0.0 code_builder: ^4.0.0 - jael: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/jael/jael - jael_preprocessor: - git: - url: https://github.com/dukefirehawk/angel.git - ref: sdk-2.12.x_nnbd - path: packages/jael/jael_preprocessor + jael3: ^4.2.0 + jael3_preprocessor: ^4.2.0 source_gen: ^1.0.2 dev_dependencies: build_runner: ^2.0.4 build_web_compilers: ^3.0.0 - pedantic: ^1.11.1 \ No newline at end of file + lints: ^1.0.0 \ No newline at end of file