Updated deprecated code

This commit is contained in:
Thomas Hii 2024-06-16 10:13:53 +08:00
parent e802de14f1
commit 32a7e88d2d
9 changed files with 26 additions and 35 deletions

View file

@ -1,21 +1,12 @@
# Change Log # Change Log
## 8.2.1
* Updated repository link
## 8.2.0
* Updated `lints` to 3.0.0
* Fixed linter warnings
## 8.1.0
* Upgraded to `analyzer` 6.2.x
## 8.0.0 ## 8.0.0
* Require Dart >= 3.0 * Require Dart >= 3.3
* Updated `lints` to 3.0.0
* Updated `analyzer` to 6.2.x
* Fixed linter warnings
* Updated repository link
## 7.1.1 ## 7.1.1

View file

@ -8,4 +8,4 @@ Experimental virtual DOM/SPA engine built on Jael. Supports SSR.
## TODO ## TODO
* Builder failed to generate the class * Bug: Builder failed to generate the class

View file

@ -12,7 +12,7 @@ import 'package:path/path.dart';
/// Converts a [DartType] to a [TypeReference]. /// Converts a [DartType] to a [TypeReference].
TypeReference convertTypeReference(DartType? t) { TypeReference convertTypeReference(DartType? t) {
return TypeReference((b) { return TypeReference((b) {
b.symbol = t?.getDisplayString(withNullability: false); b.symbol = t?.getDisplayString();
if (t is InterfaceType) { if (t is InterfaceType) {
b.types.addAll(t.typeArguments.map(convertTypeReference)); b.types.addAll(t.typeArguments.map(convertTypeReference));

View file

@ -14,6 +14,5 @@ class Jael {
/// Shorthand for enabling `DSX` syntax when using a [Jael] annotation. /// Shorthand for enabling `DSX` syntax when using a [Jael] annotation.
class Dsx extends Jael { class Dsx extends Jael {
const Dsx({String? template, String? templateUrl}) const Dsx({super.template, super.templateUrl}) : super(asDsx: true);
: super(template: template, templateUrl: templateUrl, asDsx: true);
} }

View file

@ -1,5 +1,5 @@
name: jael3_web name: jael3_web
version: 8.2.0 version: 8.0.0
description: Experimental virtual DOM/SPA engine built on Jael3. Supports SSR. description: Experimental virtual DOM/SPA engine built on Jael3. Supports SSR.
publish_to: none publish_to: none
environment: environment:

View file

@ -1,5 +1,10 @@
# Change Log # Change Log
## 8.2.0
* Require Dart >= 3.3
* Updated `lints` to 4.0.0
## 8.1.1 ## 8.1.1
* Updated repository link * Updated repository link

View file

@ -1,5 +1,5 @@
name: angel3_model name: angel3_model
version: 8.1.1 version: 8.2.0
description: Angel3 basic data model class, no longer with the added weight of the whole framework. description: Angel3 basic data model class, no longer with the added weight of the whole framework.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dart-backend/angel/tree/master/packages/model repository: https://github.com/dart-backend/angel/tree/master/packages/model

View file

@ -100,7 +100,7 @@ String? dartObjectToString(DartObject v) {
return '#${v.toSymbolValue()!}'; return '#${v.toSymbolValue()!}';
} }
if (v.toTypeValue() != null) { if (v.toTypeValue() != null) {
return v.toTypeValue()!.getDisplayString(withNullability: true); return v.toTypeValue()!.getDisplayString();
} }
if (v.toListValue() != null) { if (v.toListValue() != null) {
return 'const [${v.toListValue()!.map(dartObjectToString).join(', ')}]'; return 'const [${v.toListValue()!.map(dartObjectToString).join(', ')}]';

View file

@ -189,12 +189,11 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
// Serialize model classes via `XSerializer.toMap` // Serialize model classes via `XSerializer.toMap`
else if (isModelClass(type)) { else if (isModelClass(type)) {
var rc = ReCase(type.getDisplayString(withNullability: true)); var rc = ReCase(type.getDisplayString());
serializedRepresentation = serializerToMap(rc, 'model.${field.name}'); serializedRepresentation = serializerToMap(rc, 'model.${field.name}');
} else if (type is InterfaceType) { } else if (type is InterfaceType) {
if (isListOfModelType(type)) { if (isListOfModelType(type)) {
var name = var name = type.typeArguments[0].getDisplayString();
type.typeArguments[0].getDisplayString(withNullability: true);
if (name.startsWith('_')) name = name.substring(1); if (name.startsWith('_')) name = name.substring(1);
var rc = ReCase(name); var rc = ReCase(name);
var m = serializerToMap(rc, 'm'); var m = serializerToMap(rc, 'm');
@ -207,8 +206,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
'model.${field.name}$question.map((m) => $m).toList()'; 'model.${field.name}$question.map((m) => $m).toList()';
log.fine('serializedRepresentation => $serializedRepresentation'); log.fine('serializedRepresentation => $serializedRepresentation');
} else if (isMapToModelType(type)) { } else if (isMapToModelType(type)) {
var rc = ReCase( var rc = ReCase(type.typeArguments[1].getDisplayString());
type.typeArguments[1].getDisplayString(withNullability: true));
serializedRepresentation = serializedRepresentation =
'''model.${field.name}.keys.fold({}, (map, key) { '''model.${field.name}.keys.fold({}, (map, key) {
return map..[key] = return map..[key] =
@ -222,7 +220,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
serializedRepresentation = ''' serializedRepresentation = '''
model.${field.name} != null ? model.${field.name} != null ?
${type.getDisplayString(withNullability: false)}.values.indexOf(model.${field.name}$convert) ${type.getDisplayString()}.values.indexOf(model.${field.name}$convert)
: null : null
'''; ''';
} else if (const TypeChecker.fromRuntime(Uint8List) } else if (const TypeChecker.fromRuntime(Uint8List)
@ -357,7 +355,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
// Serialize model classes via `XSerializer.toMap` // Serialize model classes via `XSerializer.toMap`
else if (isModelClass(type)) { else if (isModelClass(type)) {
var rc = ReCase(type.getDisplayString(withNullability: true)); var rc = ReCase(type.getDisplayString());
deserializedRepresentation = "map['$alias'] != null" deserializedRepresentation = "map['$alias'] != null"
" ? ${rc.pascalCase.replaceAll('?', '')}Serializer.fromMap(map['$alias'] as Map)" " ? ${rc.pascalCase.replaceAll('?', '')}Serializer.fromMap(map['$alias'] as Map)"
' : $defaultValue'; ' : $defaultValue';
@ -366,8 +364,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
if (defaultValue == 'null') { if (defaultValue == 'null') {
defaultValue = '[]'; defaultValue = '[]';
} }
var rc = ReCase( var rc = ReCase(type.typeArguments[0].getDisplayString());
type.typeArguments[0].getDisplayString(withNullability: true));
deserializedRepresentation = "map['$alias'] is Iterable" deserializedRepresentation = "map['$alias'] is Iterable"
" ? List.unmodifiable(((map['$alias'] as Iterable)" " ? List.unmodifiable(((map['$alias'] as Iterable)"
@ -380,8 +377,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
defaultValue = '{}'; defaultValue = '{}';
} }
var rc = ReCase( var rc = ReCase(type.typeArguments[1].getDisplayString());
type.typeArguments[1].getDisplayString(withNullability: true));
deserializedRepresentation = ''' deserializedRepresentation = '''
map['$alias'] is Map map['$alias'] is Map
? Map.unmodifiable((map['$alias'] as Map).keys.fold({}, (out, key) { ? Map.unmodifiable((map['$alias'] as Map).keys.fold({}, (out, key) {
@ -392,12 +388,12 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
'''; ''';
} else if (type.element is Enum) { } else if (type.element is Enum) {
deserializedRepresentation = ''' deserializedRepresentation = '''
map['$alias'] is ${type.getDisplayString(withNullability: true)} map['$alias'] is ${type.getDisplayString()}
? (map['$alias'] as ${type.getDisplayString(withNullability: true)}) ?? $defaultValue ? (map['$alias'] as ${type.getDisplayString()}) ?? $defaultValue
: :
( (
map['$alias'] is int map['$alias'] is int
? ${type.getDisplayString(withNullability: true)}.values[map['$alias'] as int] ? ${type.getDisplayString()}.values[map['$alias'] as int]
: $defaultValue : $defaultValue
) )
'''; ''';