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/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/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/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/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; diff --git a/apps/dart_quotes_server/pubspec.yaml b/apps/dart_quotes_server/pubspec.yaml index a839997c..b5bb9478 100644 --- a/apps/dart_quotes_server/pubspec.yaml +++ b/apps/dart_quotes_server/pubspec.yaml @@ -11,17 +11,17 @@ dependencies: path: ./client jaspr: ^0.16.0 jaspr_router: ^0.6.0 - jaspr_serverpod: ^0.4.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 + jaspr_serverpod: ^0.5.0 + 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 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_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 3827776b..a7f10119 100644 --- a/examples/backend_serverpod/example_server/pubspec.yaml +++ b/examples/backend_serverpod/example_server/pubspec.yaml @@ -8,8 +8,8 @@ environment: dependencies: jaspr: ^0.15.0 - jaspr_serverpod: ^0.3.3 - serverpod: 2.1.1 + jaspr_serverpod: ^0.5.0 + serverpod: 2.3.0 dev_dependencies: build_runner: ^2.4.8 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 f57897d9..b72aafbb 100644 --- a/packages/jaspr/CHANGELOG.md +++ b/packages/jaspr/CHANGELOG.md @@ -1,3 +1,6 @@ +## Unreleased patch +- Fixed improved validation regular expressions to support specific attribute names + ## 0.16.3 - Added `table` and related html methods. 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', 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); + }); + }); + }); +} diff --git a/packages/jaspr_serverpod/CHANGELOG.md b/packages/jaspr_serverpod/CHANGELOG.md index 2b1f42d9..317192ac 100644 --- a/packages/jaspr_serverpod/CHANGELOG.md +++ b/packages/jaspr_serverpod/CHANGELOG.md @@ -1,3 +1,7 @@ +## Unreleased minor + +- Bump `serverpod` to `2.3.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..27cf697f 100644 --- a/packages/jaspr_serverpod/pubspec.yaml +++ b/packages/jaspr_serverpod/pubspec.yaml @@ -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 + serverpod: 2.3.0 + serverpod_client: 2.3.0 shelf: ^1.4.0 web: ^1.0.0