From fe6779e53892df87b36179310b606a0f75023c29 Mon Sep 17 00:00:00 2001 From: gonft Date: Wed, 1 Jan 2025 00:17:50 +0900 Subject: [PATCH 01/16] fix: improve attribute name validation regex to support directives Allow validation of directive-style attributes like ':class' and '@scroll.window' by updating the attribute name validation pattern. --- packages/jaspr/lib/src/server/markup_render_object.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jaspr/lib/src/server/markup_render_object.dart b/packages/jaspr/lib/src/server/markup_render_object.dart index 5e6c6c0f..bfd838fa 100644 --- a/packages/jaspr/lib/src/server/markup_render_object.dart +++ b/packages/jaspr/lib/src/server/markup_render_object.dart @@ -164,7 +164,7 @@ class MarkupRenderObject extends RenderObject { /// DOM validator with sane defaults. class DomValidator { - static final _attributeRegExp = RegExp(r'^[a-z](?:[a-zA-Z0-9\-_:.]*[a-z0-9]+)?$'); + static final _attributeRegExp = RegExp(r'^[@a-z:](?:[a-zA-Z0-9\-_:.]*[a-z0-9]+)?$'); static final _elementRegExp = _attributeRegExp; static const _selfClosing = { 'area', From a6009af77308b4f6214865c796944ab83cfdae84 Mon Sep 17 00:00:00 2001 From: gonft Date: Wed, 1 Jan 2025 00:19:19 +0900 Subject: [PATCH 02/16] test: Add test cases for special attribute in DomValidator Add test cases to verify DomValidator accepts attribute: - ':' prefix for binding attributes (e.g. :class) - '@' prefix for event handlers (e.g. @scroll.window) --- .../jaspr/test/server/dom_validator_test.dart | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 packages/jaspr/test/server/dom_validator_test.dart diff --git a/packages/jaspr/test/server/dom_validator_test.dart b/packages/jaspr/test/server/dom_validator_test.dart new file mode 100644 index 00000000..f2fefb32 --- /dev/null +++ b/packages/jaspr/test/server/dom_validator_test.dart @@ -0,0 +1,92 @@ +import 'package:jaspr/src/server/markup_render_object.dart'; +import 'package:test/test.dart'; + +void main() { + group('DomValidator', () { + late DomValidator validator; + + setUp(() { + validator = DomValidator(); + }); + + group('validateElementName', () { + test('accepts valid element names', () { + expect(() => validator.validateElementName('div'), returnsNormally); + expect(() => validator.validateElementName('custom-element'), + returnsNormally); + expect(() => validator.validateElementName('h1'), returnsNormally); + }); + + test('throws on invalid element names', () { + expect( + () => validator.validateElementName('1div'), throwsArgumentError); + expect(() => validator.validateElementName('-element'), + throwsArgumentError); + expect( + () => validator.validateElementName('div!'), throwsArgumentError); + }); + }); + + group('validateAttributeName', () { + test('accepts valid attribute names', () { + expect(() => validator.validateAttributeName('id'), returnsNormally); + expect(() => validator.validateAttributeName('data-test'), + returnsNormally); + expect(() => validator.validateAttributeName('aria-label'), + returnsNormally); + expect( + () => validator.validateAttributeName(':class'), returnsNormally); + expect(() => validator.validateAttributeName('@scroll.window'), + returnsNormally); + }); + + test('throws on invalid attribute names', () { + expect( + () => validator.validateAttributeName('1id'), throwsArgumentError); + expect(() => validator.validateAttributeName('-test'), + throwsArgumentError); + expect(() => validator.validateAttributeName('data!'), + throwsArgumentError); + }); + }); + + group('isSelfClosing', () { + test('returns true for self-closing elements', () { + expect(validator.isSelfClosing('img'), isTrue); + expect(validator.isSelfClosing('br'), isTrue); + expect(validator.isSelfClosing('input'), isTrue); + }); + + test('returns false for non-self-closing elements', () { + expect(validator.isSelfClosing('div'), isFalse); + expect(validator.isSelfClosing('span'), isFalse); + expect(validator.isSelfClosing('p'), isFalse); + }); + }); + + group('hasStrictWhitespace', () { + test('returns true for elements with strict whitespace', () { + expect(validator.hasStrictWhitespace('p'), isTrue); + expect(validator.hasStrictWhitespace('h1'), isTrue); + expect(validator.hasStrictWhitespace('label'), isTrue); + }); + + test('returns false for elements without strict whitespace', () { + expect(validator.hasStrictWhitespace('div'), isFalse); + expect(validator.hasStrictWhitespace('span'), isFalse); + }); + }); + + group('hasStrictFormatting', () { + test('returns true for elements with strict formatting', () { + expect(validator.hasStrictFormatting('pre'), isTrue); + expect(validator.hasStrictFormatting('span'), isTrue); + }); + + test('returns false for elements without strict formatting', () { + expect(validator.hasStrictFormatting('div'), isFalse); + expect(validator.hasStrictFormatting('p'), isFalse); + }); + }); + }); +} From efe29b8a3e30a588e4d9210887219c52de196d85 Mon Sep 17 00:00:00 2001 From: gonft Date: Wed, 1 Jan 2025 00:58:38 +0900 Subject: [PATCH 03/16] fix: resolve analyzer warnings and errors - Implement custom GatherUsedImportedElementsVisitor class to replace removed analyzer functionality - Remove unused import from import_assist.dart - Replace deprecated 'enclosingElement' with 'enclosingElement3' - Add curly braces to if statement in component_assist.dart --- .../lib/src/imports/analyzing_builder.dart | 6 ++-- .../lib/src/styles/styles_module_builder.dart | 8 ++--- .../lib/src/assists/import_assist.dart | 30 +++++++++++++++++-- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart b/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart index ed9706b1..07dad0d9 100644 --- a/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart +++ b/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart @@ -29,9 +29,11 @@ class ImportsModuleBuilder implements Builder { var outputId = buildStep.inputId.changeExtension('.imports.json'); var partId = buildStep.inputId.changeExtension('.imports.dart'); - var import = lib.libraryImports + // Get the library's compilation unit and use its imports instead + var compilationUnit = lib.definingCompilationUnit; + var import = compilationUnit.libraryImports .cast() - .followedBy(lib.libraryExports) + .followedBy(compilationUnit.libraryExports) .where((Element e) => importChecker.hasAnnotationOf(e)) .where((Element e) { var uri = switch (e) { diff --git a/packages/jaspr_builder/lib/src/styles/styles_module_builder.dart b/packages/jaspr_builder/lib/src/styles/styles_module_builder.dart index 5d8022d0..7e1c4e66 100644 --- a/packages/jaspr_builder/lib/src/styles/styles_module_builder.dart +++ b/packages/jaspr_builder/lib/src/styles/styles_module_builder.dart @@ -59,11 +59,11 @@ class StylesModuleBuilder implements Builder { }) .where((element) => stylesChecker.firstAnnotationOfExact(element) != null) .where((element) { - if (element.enclosingElement case ClassElement clazz when clazz.isPrivate || element.isPrivate) { + if (element.enclosingElement3 case ClassElement clazz when clazz.isPrivate || element.isPrivate) { log.severe( '@css cannot be used on private classes or members. Failing element: ${clazz.name}.${element.name} in library ${library.source.fullName}.'); return false; - } else if (element.enclosingElement case ClassElement clazz + } else if (element.enclosingElement3 case ClassElement clazz when (element is FieldElement && !element.isStatic) || (element is PropertyAccessorElement && !element.isStatic)) { log.severe( @@ -84,7 +84,7 @@ class StylesModuleBuilder implements Builder { if (type == null || !type.isDartCoreList || !styleRuleChecker.isAssignableFromType((type as InterfaceType).typeArguments.first)) { - final prefix = switch (element.enclosingElement) { ClassElement(:var name) => '$name.', _ => '' }; + final prefix = switch (element.enclosingElement3) { ClassElement(:var name) => '$name.', _ => '' }; log.severe( '@css can only be applied on variables or getters of type List. Failing element: $prefix${element.name} with type $type in library ${element.source?.fullName}.'); return false; @@ -93,7 +93,7 @@ class StylesModuleBuilder implements Builder { return true; }) .map((e) { - if (e.enclosingElement case ClassElement clazz) { + if (e.enclosingElement3 case ClassElement clazz) { return '${clazz.name}.${e.name}'; } else { return e.name; diff --git a/packages/jaspr_lints/lib/src/assists/import_assist.dart b/packages/jaspr_lints/lib/src/assists/import_assist.dart index 0ac4063e..dc7ca4a1 100644 --- a/packages/jaspr_lints/lib/src/assists/import_assist.dart +++ b/packages/jaspr_lints/lib/src/assists/import_assist.dart @@ -2,8 +2,6 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/source/source_range.dart'; -// ignore: implementation_imports -import 'package:analyzer/src/error/imports_verifier.dart'; import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; @@ -84,3 +82,31 @@ class ReplaceStubbedTypesVisitor extends RecursiveAstVisitor { } } } + +class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor { + GatherUsedImportedElementsVisitor(this.library); + + final LibraryElement library; + final usedElements = _UsedElements(); + + @override + void visitSimpleIdentifier(SimpleIdentifier node) { + var element = node.staticElement; + if (element != null) { + usedElements.elements.add(element); + } + super.visitSimpleIdentifier(node); + } + + @override + void visitExtensionOverride(ExtensionOverride node) { + var element = node.element; + usedElements.usedExtensions.add(element); + super.visitExtensionOverride(node); + } +} + +class _UsedElements { + final elements = {}; + final usedExtensions = {}; +} \ No newline at end of file From 769d5131ecef190c8c9e4b0b19fc517298888050 Mon Sep 17 00:00:00 2001 From: gonft Date: Wed, 1 Jan 2025 01:07:32 +0900 Subject: [PATCH 04/16] chore: update changelogs for jaspr and jaspr_lints --- packages/jaspr/CHANGELOG.md | 3 +++ packages/jaspr_lints/CHANGELOG.md | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/packages/jaspr/CHANGELOG.md b/packages/jaspr/CHANGELOG.md index f57897d9..8342819a 100644 --- a/packages/jaspr/CHANGELOG.md +++ b/packages/jaspr/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.16.4 +- Fixed improved validation regular expressions to support specific attribute names + ## 0.16.3 - Added `table` and related html methods. diff --git a/packages/jaspr_lints/CHANGELOG.md b/packages/jaspr_lints/CHANGELOG.md index 892cdfa1..ab1dde31 100644 --- a/packages/jaspr_lints/CHANGELOG.md +++ b/packages/jaspr_lints/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.3 + + - Resolve analyzer warnings and errors. + ## 0.1.2 - Updated sdk constraint to `>=3.5.0 <4.0.0`. From 1a362c1f1658785734aa3167bf20b003614bce96 Mon Sep 17 00:00:00 2001 From: gonft Date: Thu, 2 Jan 2025 20:18:20 +0900 Subject: [PATCH 05/16] chore: update dependencies and changelog for jaspr_serverpod - Bump `serverpod` to `2.3.0` and `jaspr` to `0.16.3` - Update CHANGELOG.md to reflect version 0.5.0 changes --- apps/dart_quotes/pubspec.yaml | 2 +- apps/dart_quotes_server/config/passwords.yaml | 4 ++-- apps/dart_quotes_server/pubspec.yaml | 4 ++-- apps/fluttercon/pubspec.yaml | 2 +- apps/jaspr_pad/pubspec.yaml | 2 +- examples/backend_dart_frog/pubspec.yaml | 4 ++-- examples/backend_serverpod/example_server/pubspec.yaml | 2 +- examples/backend_shelf/pubspec.yaml | 2 +- examples/flutter_embedding/pubspec.yaml | 2 +- examples/flutter_multi_view/pubspec.yaml | 6 +++--- examples/flutter_plugin_interop/pubspec.yaml | 2 +- examples/package_riverpod/pubspec.yaml | 2 +- packages/jaspr/CHANGELOG.md | 2 +- packages/jaspr_lints/CHANGELOG.md | 2 +- packages/jaspr_serverpod/CHANGELOG.md | 5 +++++ packages/jaspr_serverpod/pubspec.yaml | 10 +++++----- 16 files changed, 29 insertions(+), 24 deletions(-) diff --git a/apps/dart_quotes/pubspec.yaml b/apps/dart_quotes/pubspec.yaml index 8e5c7611..44ce4639 100644 --- a/apps/dart_quotes/pubspec.yaml +++ b/apps/dart_quotes/pubspec.yaml @@ -17,7 +17,7 @@ dependencies: dev_dependencies: build_runner: ^2.4.0 jaspr_web_compilers: ^4.0.10 - jaspr_builder: ^0.15.1 + jaspr_builder: ^0.16.3 lints: ^4.0.0 jaspr: diff --git a/apps/dart_quotes_server/config/passwords.yaml b/apps/dart_quotes_server/config/passwords.yaml index 18d7130d..db6de4d6 100644 --- a/apps/dart_quotes_server/config/passwords.yaml +++ b/apps/dart_quotes_server/config/passwords.yaml @@ -15,8 +15,8 @@ shared: # These are passwords used when running the server locally in development mode development: - database: 'CHANGE_ME' - redis: 'CHANGE_ME' + database: "CHANGE_ME" + redis: "CHANGE_ME" # The service secret is used to communicate between servers and to access the # service protocol. diff --git a/apps/dart_quotes_server/pubspec.yaml b/apps/dart_quotes_server/pubspec.yaml index a839997c..5f117957 100644 --- a/apps/dart_quotes_server/pubspec.yaml +++ b/apps/dart_quotes_server/pubspec.yaml @@ -11,7 +11,7 @@ dependencies: path: ./client jaspr: ^0.16.0 jaspr_router: ^0.6.0 - jaspr_serverpod: ^0.4.0 + jaspr_serverpod: ^0.5.0 serverpod: 2.1.1 serverpod_auth_google_flutter: 2.1.1 serverpod_auth_server: 2.1.1 @@ -21,7 +21,7 @@ dependencies: dev_dependencies: build_runner: ^2.4.0 jaspr_web_compilers: ^4.0.10 - jaspr_builder: ^0.15.1 + jaspr_builder: ^0.16.3 lints: ^4.0.0 jaspr: diff --git a/apps/fluttercon/pubspec.yaml b/apps/fluttercon/pubspec.yaml index 8b83fc69..a71015dd 100644 --- a/apps/fluttercon/pubspec.yaml +++ b/apps/fluttercon/pubspec.yaml @@ -21,7 +21,7 @@ dev_dependencies: build_runner: ^2.4.0 dart_mappable_builder: ^4.2.3 jaspr_web_compilers: ^4.0.10 - jaspr_builder: ^0.15.1 + jaspr_builder: ^0.16.3 lints: ^4.0.0 jaspr: diff --git a/apps/jaspr_pad/pubspec.yaml b/apps/jaspr_pad/pubspec.yaml index db04e478..9e300d6d 100644 --- a/apps/jaspr_pad/pubspec.yaml +++ b/apps/jaspr_pad/pubspec.yaml @@ -32,7 +32,7 @@ dev_dependencies: build_runner: ^2.4.0 build_web_compilers: ^4.0.0 dart_mappable_builder: ^4.2.0 - jaspr_builder: ^0.15.1 + jaspr_builder: ^0.16.3 jaspr_test: ^0.15.1 lints: ^4.0.0 test: ^1.25.0 diff --git a/examples/backend_dart_frog/pubspec.yaml b/examples/backend_dart_frog/pubspec.yaml index 7424b735..46076302 100644 --- a/examples/backend_dart_frog/pubspec.yaml +++ b/examples/backend_dart_frog/pubspec.yaml @@ -13,12 +13,12 @@ dependencies: dev_dependencies: build_runner: ^2.4.0 build_web_compilers: ^4.0.0 - jaspr_builder: ^0.15.0 + jaspr_builder: ^0.16.3 lints: ^2.1.0 dependency_overrides: hotreloader: ^4.1.0 - + jaspr: mode: server dev-command: dart_frog dev diff --git a/examples/backend_serverpod/example_server/pubspec.yaml b/examples/backend_serverpod/example_server/pubspec.yaml index 3827776b..3edef648 100644 --- a/examples/backend_serverpod/example_server/pubspec.yaml +++ b/examples/backend_serverpod/example_server/pubspec.yaml @@ -8,7 +8,7 @@ environment: dependencies: jaspr: ^0.15.0 - jaspr_serverpod: ^0.3.3 + jaspr_serverpod: ^0.5.0 serverpod: 2.1.1 dev_dependencies: diff --git a/examples/backend_shelf/pubspec.yaml b/examples/backend_shelf/pubspec.yaml index 22d4c076..7f8cb857 100644 --- a/examples/backend_shelf/pubspec.yaml +++ b/examples/backend_shelf/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: dev_dependencies: build_runner: ^2.4.0 build_web_compilers: ^4.0.0 - jaspr_builder: ^0.15.0 + jaspr_builder: ^0.16.3 lints: ^2.1.0 jaspr: diff --git a/examples/flutter_embedding/pubspec.yaml b/examples/flutter_embedding/pubspec.yaml index 0e4c0bd1..6e525198 100644 --- a/examples/flutter_embedding/pubspec.yaml +++ b/examples/flutter_embedding/pubspec.yaml @@ -21,7 +21,7 @@ dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^4.0.0 - jaspr_builder: ^0.16.1 + jaspr_builder: ^0.16.3 jaspr_web_compilers: ^4.0.10 flutter: diff --git a/examples/flutter_multi_view/pubspec.yaml b/examples/flutter_multi_view/pubspec.yaml index 3a38554f..093ec7df 100644 --- a/examples/flutter_multi_view/pubspec.yaml +++ b/examples/flutter_multi_view/pubspec.yaml @@ -7,18 +7,18 @@ environment: dependencies: flutter: - sdk: flutter + sdk: flutter jaspr: ^0.16.0 jaspr_flutter_embed: ^0.4.0 dev_dependencies: build_runner: ^2.4.0 jaspr_web_compilers: ^4.0.10 - jaspr_builder: ^0.15.1 + jaspr_builder: ^0.16.3 flutter_test: sdk: flutter flutter_lints: ^5.0.0 - jaspr_lints: ^0.1.1 + jaspr_lints: ^0.1.2 jaspr: mode: static diff --git a/examples/flutter_plugin_interop/pubspec.yaml b/examples/flutter_plugin_interop/pubspec.yaml index 1ece6f39..67072f4a 100644 --- a/examples/flutter_plugin_interop/pubspec.yaml +++ b/examples/flutter_plugin_interop/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: dev_dependencies: build_runner: ^2.4.0 - jaspr_builder: ^0.15.1 + jaspr_builder: ^0.16.3 jaspr_web_compilers: ^4.0.10 lints: ^4.0.0 diff --git a/examples/package_riverpod/pubspec.yaml b/examples/package_riverpod/pubspec.yaml index 2c54824c..6625d871 100644 --- a/examples/package_riverpod/pubspec.yaml +++ b/examples/package_riverpod/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: dev_dependencies: build_runner: ^2.4.0 build_web_compilers: ^4.0.0 - jaspr_builder: ^0.15.1 + jaspr_builder: ^0.16.3 lints: ^4.0.0 jaspr: diff --git a/packages/jaspr/CHANGELOG.md b/packages/jaspr/CHANGELOG.md index 8342819a..5216b5b3 100644 --- a/packages/jaspr/CHANGELOG.md +++ b/packages/jaspr/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.16.4 +## Unreleased 0.16.4 - Fixed improved validation regular expressions to support specific attribute names ## 0.16.3 diff --git a/packages/jaspr_lints/CHANGELOG.md b/packages/jaspr_lints/CHANGELOG.md index ab1dde31..1145b2b7 100644 --- a/packages/jaspr_lints/CHANGELOG.md +++ b/packages/jaspr_lints/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.1.3 +## Unreleased 0.1.3 - Resolve analyzer warnings and errors. diff --git a/packages/jaspr_serverpod/CHANGELOG.md b/packages/jaspr_serverpod/CHANGELOG.md index 2b1f42d9..c234391d 100644 --- a/packages/jaspr_serverpod/CHANGELOG.md +++ b/packages/jaspr_serverpod/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.5.0 + +- Bump `serverpod` to `2.3.0` +- `jaspr` upgraded to `0.15.0` + ## 0.4.0 - Bump `serverpod` to `2.1.1` diff --git a/packages/jaspr_serverpod/pubspec.yaml b/packages/jaspr_serverpod/pubspec.yaml index ae80444a..0f431c4a 100644 --- a/packages/jaspr_serverpod/pubspec.yaml +++ b/packages/jaspr_serverpod/pubspec.yaml @@ -1,6 +1,6 @@ name: jaspr_serverpod description: Serverpod integration for jaspr. -version: 0.4.0 +version: 0.5.0 homepage: https://github.com/schultek/jaspr issue_tracker: https://github.com/schultek/jaspr/issues documentation: https://docs.page/schultek/jaspr @@ -13,12 +13,12 @@ topics: - serverpod environment: - sdk: '>=3.0.0 <4.0.0' + sdk: ">=3.0.0 <4.0.0" dependencies: - jaspr: ^0.16.0 - serverpod: 2.1.1 - serverpod_client: 2.1.1 + jaspr: ^0.16.3 + serverpod: 2.3.0 + serverpod_client: 2.3.0 shelf: ^1.4.0 web: ^1.0.0 From 064026df44ab656e0ac969f72af0978a47f79c22 Mon Sep 17 00:00:00 2001 From: gonft Date: Thu, 2 Jan 2025 20:23:30 +0900 Subject: [PATCH 06/16] chore: update serverpod dependencies to version 2.3.0 - Bump `serverpod`, `serverpod_auth_client`, and `serverpod_client` to `2.3.0` across multiple files. - Ensure compatibility with the latest version of the serverpod packages. --- apps/dart_quotes_server/client/pubspec.yaml | 4 ++-- apps/dart_quotes_server/pubspec.yaml | 10 +++++----- examples/backend_serverpod/example_client/pubspec.yaml | 2 +- examples/backend_serverpod/example_server/pubspec.yaml | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/dart_quotes_server/client/pubspec.yaml b/apps/dart_quotes_server/client/pubspec.yaml index 4a2301cd..a0202ae0 100644 --- a/apps/dart_quotes_server/client/pubspec.yaml +++ b/apps/dart_quotes_server/client/pubspec.yaml @@ -5,5 +5,5 @@ environment: sdk: '>=3.1.0 <4.0.0' dependencies: - serverpod_auth_client: 2.1.1 - serverpod_client: 2.1.1 + serverpod_auth_client: 2.3.0 + serverpod_client: 2.3.0 diff --git a/apps/dart_quotes_server/pubspec.yaml b/apps/dart_quotes_server/pubspec.yaml index 5f117957..b5bb9478 100644 --- a/apps/dart_quotes_server/pubspec.yaml +++ b/apps/dart_quotes_server/pubspec.yaml @@ -12,11 +12,11 @@ dependencies: jaspr: ^0.16.0 jaspr_router: ^0.6.0 jaspr_serverpod: ^0.5.0 - serverpod: 2.1.1 - serverpod_auth_google_flutter: 2.1.1 - serverpod_auth_server: 2.1.1 - serverpod_auth_shared_flutter: 2.1.1 - serverpod_serialization: 2.1.1 + serverpod: 2.3.0 + serverpod_auth_google_flutter: 2.3.0 + serverpod_auth_server: 2.3.0 + serverpod_auth_shared_flutter: 2.3.0 + serverpod_serialization: 2.3.0 dev_dependencies: build_runner: ^2.4.0 diff --git a/examples/backend_serverpod/example_client/pubspec.yaml b/examples/backend_serverpod/example_client/pubspec.yaml index 15dd7ccb..444836c4 100644 --- a/examples/backend_serverpod/example_client/pubspec.yaml +++ b/examples/backend_serverpod/example_client/pubspec.yaml @@ -7,4 +7,4 @@ environment: sdk: '>=3.0.0 <4.0.0' dependencies: - serverpod_client: 2.1.1 + serverpod_client: 2.3.0 diff --git a/examples/backend_serverpod/example_server/pubspec.yaml b/examples/backend_serverpod/example_server/pubspec.yaml index 3edef648..a7f10119 100644 --- a/examples/backend_serverpod/example_server/pubspec.yaml +++ b/examples/backend_serverpod/example_server/pubspec.yaml @@ -9,7 +9,7 @@ environment: dependencies: jaspr: ^0.15.0 jaspr_serverpod: ^0.5.0 - serverpod: 2.1.1 + serverpod: 2.3.0 dev_dependencies: build_runner: ^2.4.8 From 1052f373a50302852d1a255c3957ae9c077290af Mon Sep 17 00:00:00 2001 From: gonft Date: Thu, 2 Jan 2025 22:41:56 +0900 Subject: [PATCH 07/16] refactor: update generated files via serverpod generate - Update generated files to reflect the renaming of _Modules to Modules and improved class structure using 'serverpod generate' command. --- .../client/lib/src/protocol/client.dart | 14 +++++++----- .../client/lib/src/protocol/protocol.dart | 15 ++++++++----- .../lib/src/generated/protocol.dart | 22 +++++++++++-------- .../lib/src/generated/quote.dart | 9 +++++--- .../lib/src/generated/quote_init.dart | 3 ++- 5 files changed, 38 insertions(+), 25 deletions(-) diff --git a/apps/dart_quotes_server/client/lib/src/protocol/client.dart b/apps/dart_quotes_server/client/lib/src/protocol/client.dart index 88b99cf8..e1da83dc 100644 --- a/apps/dart_quotes_server/client/lib/src/protocol/client.dart +++ b/apps/dart_quotes_server/client/lib/src/protocol/client.dart @@ -44,8 +44,8 @@ class EndpointQuotes extends _i1.EndpointRef { ); } -class _Modules { - _Modules(Client client) { +class Modules { + Modules(Client client) { auth = _i4.Caller(client); } @@ -75,19 +75,21 @@ class Client extends _i1.ServerpodClientShared { connectionTimeout: connectionTimeout, onFailedCall: onFailedCall, onSucceededCall: onSucceededCall, - disconnectStreamsOnLostInternetConnection: disconnectStreamsOnLostInternetConnection, + disconnectStreamsOnLostInternetConnection: + disconnectStreamsOnLostInternetConnection, ) { quotes = EndpointQuotes(this); - modules = _Modules(this); + modules = Modules(this); } late final EndpointQuotes quotes; - late final _Modules modules; + late final Modules modules; @override Map get endpointRefLookup => {'quotes': quotes}; @override - Map get moduleLookup => {'auth': modules.auth}; + Map get moduleLookup => + {'auth': modules.auth}; } diff --git a/apps/dart_quotes_server/client/lib/src/protocol/protocol.dart b/apps/dart_quotes_server/client/lib/src/protocol/protocol.dart index afe10e21..c8a29212 100644 --- a/apps/dart_quotes_server/client/lib/src/protocol/protocol.dart +++ b/apps/dart_quotes_server/client/lib/src/protocol/protocol.dart @@ -8,8 +8,7 @@ // ignore_for_file: type_literal_in_constant_pattern // ignore_for_file: use_super_parameters -library protocol; // ignore_for_file: no_leading_underscores_for_library_prefixes - +// ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:serverpod_client/serverpod_client.dart' as _i1; import 'quote.dart' as _i2; import 'quote_init.dart' as _i3; @@ -71,14 +70,18 @@ class Protocol extends _i1.SerializationManager { @override dynamic deserializeByClassName(Map data) { - if (data['className'] == 'Quote') { + var dataClassName = data['className']; + if (dataClassName is! String) { + return super.deserializeByClassName(data); + } + if (dataClassName == 'Quote') { return deserialize<_i2.Quote>(data['data']); } - if (data['className'] == 'QuoteInit') { + if (dataClassName == 'QuoteInit') { return deserialize<_i3.QuoteInit>(data['data']); } - if (data['className'].startsWith('serverpod_auth.')) { - data['className'] = data['className'].substring(15); + if (dataClassName.startsWith('serverpod_auth.')) { + data['className'] = dataClassName.substring(15); return _i4.Protocol().deserializeByClassName(data); } return super.deserializeByClassName(data); diff --git a/apps/dart_quotes_server/lib/src/generated/protocol.dart b/apps/dart_quotes_server/lib/src/generated/protocol.dart index a82fd5b1..fc817cb9 100644 --- a/apps/dart_quotes_server/lib/src/generated/protocol.dart +++ b/apps/dart_quotes_server/lib/src/generated/protocol.dart @@ -8,8 +8,7 @@ // ignore_for_file: type_literal_in_constant_pattern // ignore_for_file: use_super_parameters -library protocol; // ignore_for_file: no_leading_underscores_for_library_prefixes - +// ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:serverpod/serverpod.dart' as _i1; import 'package:serverpod/protocol.dart' as _i2; import 'package:serverpod_auth_server/serverpod_auth_server.dart' as _i3; @@ -133,18 +132,22 @@ class Protocol extends _i1.SerializationManagerServer { @override dynamic deserializeByClassName(Map data) { - if (data['className'] == 'Quote') { + var dataClassName = data['className']; + if (dataClassName is! String) { + return super.deserializeByClassName(data); + } + if (dataClassName == 'Quote') { return deserialize<_i4.Quote>(data['data']); } - if (data['className'] == 'QuoteInit') { + if (dataClassName == 'QuoteInit') { return deserialize<_i5.QuoteInit>(data['data']); } - if (data['className'].startsWith('serverpod.')) { - data['className'] = data['className'].substring(10); + if (dataClassName.startsWith('serverpod.')) { + data['className'] = dataClassName.substring(10); return _i2.Protocol().deserializeByClassName(data); } - if (data['className'].startsWith('serverpod_auth.')) { - data['className'] = data['className'].substring(15); + if (dataClassName.startsWith('serverpod_auth.')) { + data['className'] = dataClassName.substring(15); return _i3.Protocol().deserializeByClassName(data); } return super.deserializeByClassName(data); @@ -172,7 +175,8 @@ class Protocol extends _i1.SerializationManagerServer { } @override - List<_i2.TableDefinition> getTargetTableDefinitions() => targetTableDefinitions; + List<_i2.TableDefinition> getTargetTableDefinitions() => + targetTableDefinitions; @override String getModuleName() => 'dart_quotes'; diff --git a/apps/dart_quotes_server/lib/src/generated/quote.dart b/apps/dart_quotes_server/lib/src/generated/quote.dart index c3128e39..e107112a 100644 --- a/apps/dart_quotes_server/lib/src/generated/quote.dart +++ b/apps/dart_quotes_server/lib/src/generated/quote.dart @@ -11,13 +11,13 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:serverpod/serverpod.dart' as _i1; -abstract class Quote extends _i1.TableRow implements _i1.ProtocolSerialization { +abstract class Quote implements _i1.TableRow, _i1.ProtocolSerialization { Quote._({ - int? id, + this.id, required this.quote, required this.author, required this.likes, - }) : super(id); + }); factory Quote({ int? id, @@ -39,6 +39,9 @@ abstract class Quote extends _i1.TableRow implements _i1.ProtocolSerialization { static const db = QuoteRepository._(); + @override + int? id; + String quote; String author; diff --git a/apps/dart_quotes_server/lib/src/generated/quote_init.dart b/apps/dart_quotes_server/lib/src/generated/quote_init.dart index 96edfc5b..f5f81939 100644 --- a/apps/dart_quotes_server/lib/src/generated/quote_init.dart +++ b/apps/dart_quotes_server/lib/src/generated/quote_init.dart @@ -11,7 +11,8 @@ // ignore_for_file: no_leading_underscores_for_library_prefixes import 'package:serverpod/serverpod.dart' as _i1; -abstract class QuoteInit implements _i1.SerializableModel, _i1.ProtocolSerialization { +abstract class QuoteInit + implements _i1.SerializableModel, _i1.ProtocolSerialization { QuoteInit._({required this.id}); factory QuoteInit({required int id}) = _QuoteInitImpl; From fae95e1aff4a49a1af006beb57414cc1e6bc1627 Mon Sep 17 00:00:00 2001 From: gonft Date: Thu, 2 Jan 2025 23:08:19 +0900 Subject: [PATCH 08/16] revert: Roll back to a previous code --- .../lib/src/assists/import_assist.dart | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/packages/jaspr_lints/lib/src/assists/import_assist.dart b/packages/jaspr_lints/lib/src/assists/import_assist.dart index dc7ca4a1..0ac4063e 100644 --- a/packages/jaspr_lints/lib/src/assists/import_assist.dart +++ b/packages/jaspr_lints/lib/src/assists/import_assist.dart @@ -2,6 +2,8 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/source/source_range.dart'; +// ignore: implementation_imports +import 'package:analyzer/src/error/imports_verifier.dart'; import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; @@ -82,31 +84,3 @@ class ReplaceStubbedTypesVisitor extends RecursiveAstVisitor { } } } - -class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor { - GatherUsedImportedElementsVisitor(this.library); - - final LibraryElement library; - final usedElements = _UsedElements(); - - @override - void visitSimpleIdentifier(SimpleIdentifier node) { - var element = node.staticElement; - if (element != null) { - usedElements.elements.add(element); - } - super.visitSimpleIdentifier(node); - } - - @override - void visitExtensionOverride(ExtensionOverride node) { - var element = node.element; - usedElements.usedExtensions.add(element); - super.visitExtensionOverride(node); - } -} - -class _UsedElements { - final elements = {}; - final usedExtensions = {}; -} \ No newline at end of file From 7999053c00b9bea8d9d845e13300fd0a6b4ccb61 Mon Sep 17 00:00:00 2001 From: gonft Date: Thu, 2 Jan 2025 23:14:17 +0900 Subject: [PATCH 09/16] chore: update changelogs for jaspr, jaspr_lints, and jaspr_serverpod - Update CHANGELOG.md files to reflect the latest changes and versioning. - Mark jaspr and jaspr_lints as unreleased patches. - Adjust jaspr_serverpod to indicate an unreleased minor version with a bump to serverpod 2.3.0. --- packages/jaspr/CHANGELOG.md | 2 +- packages/jaspr_lints/CHANGELOG.md | 2 +- packages/jaspr_serverpod/CHANGELOG.md | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/jaspr/CHANGELOG.md b/packages/jaspr/CHANGELOG.md index 5216b5b3..b72aafbb 100644 --- a/packages/jaspr/CHANGELOG.md +++ b/packages/jaspr/CHANGELOG.md @@ -1,4 +1,4 @@ -## Unreleased 0.16.4 +## Unreleased patch - Fixed improved validation regular expressions to support specific attribute names ## 0.16.3 diff --git a/packages/jaspr_lints/CHANGELOG.md b/packages/jaspr_lints/CHANGELOG.md index 1145b2b7..de3e2189 100644 --- a/packages/jaspr_lints/CHANGELOG.md +++ b/packages/jaspr_lints/CHANGELOG.md @@ -1,4 +1,4 @@ -## Unreleased 0.1.3 +## Unreleased patch - Resolve analyzer warnings and errors. diff --git a/packages/jaspr_serverpod/CHANGELOG.md b/packages/jaspr_serverpod/CHANGELOG.md index c234391d..317192ac 100644 --- a/packages/jaspr_serverpod/CHANGELOG.md +++ b/packages/jaspr_serverpod/CHANGELOG.md @@ -1,7 +1,6 @@ -## 0.5.0 +## Unreleased minor - Bump `serverpod` to `2.3.0` -- `jaspr` upgraded to `0.15.0` ## 0.4.0 From 27684776b5e3e0a91f29cedcb60ca77fe64db2fc Mon Sep 17 00:00:00 2001 From: gonft Date: Thu, 2 Jan 2025 23:16:08 +0900 Subject: [PATCH 10/16] revert: keep existing import handling in analyzing_builder.dart - Revert changes to import retrieval process to maintain compatibility with analyzer ^6.5.0 - compilationUnit.libraryImports requires analyzer >=6.10.0 which is above our current constraint --- .../jaspr_builder/lib/src/imports/analyzing_builder.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart b/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart index 07dad0d9..ed9706b1 100644 --- a/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart +++ b/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart @@ -29,11 +29,9 @@ class ImportsModuleBuilder implements Builder { var outputId = buildStep.inputId.changeExtension('.imports.json'); var partId = buildStep.inputId.changeExtension('.imports.dart'); - // Get the library's compilation unit and use its imports instead - var compilationUnit = lib.definingCompilationUnit; - var import = compilationUnit.libraryImports + var import = lib.libraryImports .cast() - .followedBy(compilationUnit.libraryExports) + .followedBy(lib.libraryExports) .where((Element e) => importChecker.hasAnnotationOf(e)) .where((Element e) { var uri = switch (e) { From 6aecd5e0546dcebc40867aead29415cd2f591497 Mon Sep 17 00:00:00 2001 From: gonft Date: Thu, 2 Jan 2025 23:18:36 +0900 Subject: [PATCH 11/16] revert: rollback version from 0.5.0 to 0.4.0 CI automatically manages version numbers, reverting manual version change. --- packages/jaspr_serverpod/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jaspr_serverpod/pubspec.yaml b/packages/jaspr_serverpod/pubspec.yaml index 0f431c4a..cb941b83 100644 --- a/packages/jaspr_serverpod/pubspec.yaml +++ b/packages/jaspr_serverpod/pubspec.yaml @@ -1,6 +1,6 @@ name: jaspr_serverpod description: Serverpod integration for jaspr. -version: 0.5.0 +version: 0.4.0 homepage: https://github.com/schultek/jaspr issue_tracker: https://github.com/schultek/jaspr/issues documentation: https://docs.page/schultek/jaspr From 10f31ef90163d591155f925689b0aebbbc31e509 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 3 Jan 2025 10:54:42 +0900 Subject: [PATCH 12/16] chore: downgrade jaspr dependency to version 0.16.0 - Keep the constraint at the minor level --- packages/jaspr_serverpod/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jaspr_serverpod/pubspec.yaml b/packages/jaspr_serverpod/pubspec.yaml index cb941b83..27cf697f 100644 --- a/packages/jaspr_serverpod/pubspec.yaml +++ b/packages/jaspr_serverpod/pubspec.yaml @@ -16,7 +16,7 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - jaspr: ^0.16.3 + jaspr: ^0.16.0 serverpod: 2.3.0 serverpod_client: 2.3.0 shelf: ^1.4.0 From c759ba40dd646353ea0cb1d75383b7c4db880a85 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 3 Jan 2025 14:17:22 +0900 Subject: [PATCH 13/16] fix: implement GatherUsedImportedElementsVisitor and clean up imports - Fix GatherUsedImportedElementsVisitor instantiation - Remove unused import 'package:analyzer/src/error/imports_verifier.dart' --- .../lib/src/assists/import_assist.dart | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/packages/jaspr_lints/lib/src/assists/import_assist.dart b/packages/jaspr_lints/lib/src/assists/import_assist.dart index 0ac4063e..dc7ca4a1 100644 --- a/packages/jaspr_lints/lib/src/assists/import_assist.dart +++ b/packages/jaspr_lints/lib/src/assists/import_assist.dart @@ -2,8 +2,6 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/source/source_range.dart'; -// ignore: implementation_imports -import 'package:analyzer/src/error/imports_verifier.dart'; import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; @@ -84,3 +82,31 @@ class ReplaceStubbedTypesVisitor extends RecursiveAstVisitor { } } } + +class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor { + GatherUsedImportedElementsVisitor(this.library); + + final LibraryElement library; + final usedElements = _UsedElements(); + + @override + void visitSimpleIdentifier(SimpleIdentifier node) { + var element = node.staticElement; + if (element != null) { + usedElements.elements.add(element); + } + super.visitSimpleIdentifier(node); + } + + @override + void visitExtensionOverride(ExtensionOverride node) { + var element = node.element; + usedElements.usedExtensions.add(element); + super.visitExtensionOverride(node); + } +} + +class _UsedElements { + final elements = {}; + final usedExtensions = {}; +} \ No newline at end of file From fb53533db73769de5f7ba291d8c373700cab6251 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 3 Jan 2025 15:31:15 +0900 Subject: [PATCH 14/16] refactor: enhance import handling in analyzing_builder.dart - Update import retrieval to use the library's compilation unit for better accuracy - Replace direct access to libraryImports and libraryExports with compilationUnit properties - Improve compatibility with the analyzer package by ensuring correct import processing - Remove lint warnings by properly handling nullable types and type casting --- .../jaspr_builder/lib/src/imports/analyzing_builder.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart b/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart index ed9706b1..07dad0d9 100644 --- a/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart +++ b/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart @@ -29,9 +29,11 @@ class ImportsModuleBuilder implements Builder { var outputId = buildStep.inputId.changeExtension('.imports.json'); var partId = buildStep.inputId.changeExtension('.imports.dart'); - var import = lib.libraryImports + // Get the library's compilation unit and use its imports instead + var compilationUnit = lib.definingCompilationUnit; + var import = compilationUnit.libraryImports .cast() - .followedBy(lib.libraryExports) + .followedBy(compilationUnit.libraryExports) .where((Element e) => importChecker.hasAnnotationOf(e)) .where((Element e) { var uri = switch (e) { From e6b5f3e9aefffbbb59cd6e1934fdb87d1074b348 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 3 Jan 2025 19:47:19 +0900 Subject: [PATCH 15/16] Revert "refactor: enhance import handling in analyzing_builder.dart" This reverts commit fb53533db73769de5f7ba291d8c373700cab6251. --- .../jaspr_builder/lib/src/imports/analyzing_builder.dart | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart b/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart index 07dad0d9..ed9706b1 100644 --- a/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart +++ b/packages/jaspr_builder/lib/src/imports/analyzing_builder.dart @@ -29,11 +29,9 @@ class ImportsModuleBuilder implements Builder { var outputId = buildStep.inputId.changeExtension('.imports.json'); var partId = buildStep.inputId.changeExtension('.imports.dart'); - // Get the library's compilation unit and use its imports instead - var compilationUnit = lib.definingCompilationUnit; - var import = compilationUnit.libraryImports + var import = lib.libraryImports .cast() - .followedBy(compilationUnit.libraryExports) + .followedBy(lib.libraryExports) .where((Element e) => importChecker.hasAnnotationOf(e)) .where((Element e) { var uri = switch (e) { From a8ee2c6459ef684785012dc404f6caeb0f5eac12 Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 3 Jan 2025 19:47:40 +0900 Subject: [PATCH 16/16] Revert "fix: implement GatherUsedImportedElementsVisitor and clean up imports" This reverts commit c759ba40dd646353ea0cb1d75383b7c4db880a85. --- .../lib/src/assists/import_assist.dart | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/packages/jaspr_lints/lib/src/assists/import_assist.dart b/packages/jaspr_lints/lib/src/assists/import_assist.dart index dc7ca4a1..0ac4063e 100644 --- a/packages/jaspr_lints/lib/src/assists/import_assist.dart +++ b/packages/jaspr_lints/lib/src/assists/import_assist.dart @@ -2,6 +2,8 @@ import 'package:analyzer/dart/ast/ast.dart'; import 'package:analyzer/dart/ast/visitor.dart'; import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/source/source_range.dart'; +// ignore: implementation_imports +import 'package:analyzer/src/error/imports_verifier.dart'; import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart'; import 'package:custom_lint_builder/custom_lint_builder.dart'; @@ -82,31 +84,3 @@ class ReplaceStubbedTypesVisitor extends RecursiveAstVisitor { } } } - -class GatherUsedImportedElementsVisitor extends RecursiveAstVisitor { - GatherUsedImportedElementsVisitor(this.library); - - final LibraryElement library; - final usedElements = _UsedElements(); - - @override - void visitSimpleIdentifier(SimpleIdentifier node) { - var element = node.staticElement; - if (element != null) { - usedElements.elements.add(element); - } - super.visitSimpleIdentifier(node); - } - - @override - void visitExtensionOverride(ExtensionOverride node) { - var element = node.element; - usedElements.usedExtensions.add(element); - super.visitExtensionOverride(node); - } -} - -class _UsedElements { - final elements = {}; - final usedExtensions = {}; -} \ No newline at end of file