Updated deprecated code
This commit is contained in:
parent
e802de14f1
commit
32a7e88d2d
9 changed files with 26 additions and 35 deletions
|
@ -1,21 +1,12 @@
|
|||
# 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
|
||||
|
||||
* 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
|
||||
|
||||
|
|
|
@ -8,4 +8,4 @@ Experimental virtual DOM/SPA engine built on Jael. Supports SSR.
|
|||
|
||||
## TODO
|
||||
|
||||
* Builder failed to generate the class
|
||||
* Bug: Builder failed to generate the class
|
||||
|
|
|
@ -12,7 +12,7 @@ import 'package:path/path.dart';
|
|||
/// Converts a [DartType] to a [TypeReference].
|
||||
TypeReference convertTypeReference(DartType? t) {
|
||||
return TypeReference((b) {
|
||||
b.symbol = t?.getDisplayString(withNullability: false);
|
||||
b.symbol = t?.getDisplayString();
|
||||
|
||||
if (t is InterfaceType) {
|
||||
b.types.addAll(t.typeArguments.map(convertTypeReference));
|
||||
|
|
|
@ -14,6 +14,5 @@ class Jael {
|
|||
|
||||
/// Shorthand for enabling `DSX` syntax when using a [Jael] annotation.
|
||||
class Dsx extends Jael {
|
||||
const Dsx({String? template, String? templateUrl})
|
||||
: super(template: template, templateUrl: templateUrl, asDsx: true);
|
||||
const Dsx({super.template, super.templateUrl}) : super(asDsx: true);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: jael3_web
|
||||
version: 8.2.0
|
||||
version: 8.0.0
|
||||
description: Experimental virtual DOM/SPA engine built on Jael3. Supports SSR.
|
||||
publish_to: none
|
||||
environment:
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# Change Log
|
||||
|
||||
## 8.2.0
|
||||
|
||||
* Require Dart >= 3.3
|
||||
* Updated `lints` to 4.0.0
|
||||
|
||||
## 8.1.1
|
||||
|
||||
* Updated repository link
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dart-backend/angel/tree/master/packages/model
|
||||
|
|
|
@ -100,7 +100,7 @@ String? dartObjectToString(DartObject v) {
|
|||
return '#${v.toSymbolValue()!}';
|
||||
}
|
||||
if (v.toTypeValue() != null) {
|
||||
return v.toTypeValue()!.getDisplayString(withNullability: true);
|
||||
return v.toTypeValue()!.getDisplayString();
|
||||
}
|
||||
if (v.toListValue() != null) {
|
||||
return 'const [${v.toListValue()!.map(dartObjectToString).join(', ')}]';
|
||||
|
|
|
@ -189,12 +189,11 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
|||
|
||||
// Serialize model classes via `XSerializer.toMap`
|
||||
else if (isModelClass(type)) {
|
||||
var rc = ReCase(type.getDisplayString(withNullability: true));
|
||||
var rc = ReCase(type.getDisplayString());
|
||||
serializedRepresentation = serializerToMap(rc, 'model.${field.name}');
|
||||
} else if (type is InterfaceType) {
|
||||
if (isListOfModelType(type)) {
|
||||
var name =
|
||||
type.typeArguments[0].getDisplayString(withNullability: true);
|
||||
var name = type.typeArguments[0].getDisplayString();
|
||||
if (name.startsWith('_')) name = name.substring(1);
|
||||
var rc = ReCase(name);
|
||||
var m = serializerToMap(rc, 'm');
|
||||
|
@ -207,8 +206,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
|||
'model.${field.name}$question.map((m) => $m).toList()';
|
||||
log.fine('serializedRepresentation => $serializedRepresentation');
|
||||
} else if (isMapToModelType(type)) {
|
||||
var rc = ReCase(
|
||||
type.typeArguments[1].getDisplayString(withNullability: true));
|
||||
var rc = ReCase(type.typeArguments[1].getDisplayString());
|
||||
serializedRepresentation =
|
||||
'''model.${field.name}.keys.fold({}, (map, key) {
|
||||
return map..[key] =
|
||||
|
@ -222,7 +220,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
|||
|
||||
serializedRepresentation = '''
|
||||
model.${field.name} != null ?
|
||||
${type.getDisplayString(withNullability: false)}.values.indexOf(model.${field.name}$convert)
|
||||
${type.getDisplayString()}.values.indexOf(model.${field.name}$convert)
|
||||
: null
|
||||
''';
|
||||
} else if (const TypeChecker.fromRuntime(Uint8List)
|
||||
|
@ -357,7 +355,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
|||
|
||||
// Serialize model classes via `XSerializer.toMap`
|
||||
else if (isModelClass(type)) {
|
||||
var rc = ReCase(type.getDisplayString(withNullability: true));
|
||||
var rc = ReCase(type.getDisplayString());
|
||||
deserializedRepresentation = "map['$alias'] != null"
|
||||
" ? ${rc.pascalCase.replaceAll('?', '')}Serializer.fromMap(map['$alias'] as Map)"
|
||||
' : $defaultValue';
|
||||
|
@ -366,8 +364,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
|||
if (defaultValue == 'null') {
|
||||
defaultValue = '[]';
|
||||
}
|
||||
var rc = ReCase(
|
||||
type.typeArguments[0].getDisplayString(withNullability: true));
|
||||
var rc = ReCase(type.typeArguments[0].getDisplayString());
|
||||
|
||||
deserializedRepresentation = "map['$alias'] is Iterable"
|
||||
" ? List.unmodifiable(((map['$alias'] as Iterable)"
|
||||
|
@ -380,8 +377,7 @@ class ${pascal}Decoder extends Converter<Map, $pascal> {
|
|||
defaultValue = '{}';
|
||||
}
|
||||
|
||||
var rc = ReCase(
|
||||
type.typeArguments[1].getDisplayString(withNullability: true));
|
||||
var rc = ReCase(type.typeArguments[1].getDisplayString());
|
||||
deserializedRepresentation = '''
|
||||
map['$alias'] is Map
|
||||
? 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) {
|
||||
deserializedRepresentation = '''
|
||||
map['$alias'] is ${type.getDisplayString(withNullability: true)}
|
||||
? (map['$alias'] as ${type.getDisplayString(withNullability: true)}) ?? $defaultValue
|
||||
map['$alias'] is ${type.getDisplayString()}
|
||||
? (map['$alias'] as ${type.getDisplayString()}) ?? $defaultValue
|
||||
:
|
||||
(
|
||||
map['$alias'] is int
|
||||
? ${type.getDisplayString(withNullability: true)}.values[map['$alias'] as int]
|
||||
? ${type.getDisplayString()}.values[map['$alias'] as int]
|
||||
: $defaultValue
|
||||
)
|
||||
''';
|
||||
|
|
Loading…
Reference in a new issue