Skip to content

Commit

Permalink
Merge remote-tracking branch 'offical/main' into fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
zmtzawqlp committed Jan 10, 2024
2 parents dd3d814 + 247c705 commit 46eeac6
Show file tree
Hide file tree
Showing 534 changed files with 30,264 additions and 4,631 deletions.
72 changes: 72 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,78 @@
"contributions": [
"code"
]
},
{
"login": "woshixiaohuhu",
"name": "woshixiaohuhu",
"avatar_url": "https://avatars.githubusercontent.com/u/152966201?v=4",
"profile": "https://github.com/woshixiaohuhu",
"contributions": [
"code"
]
},
{
"login": "hc2088",
"name": "woshixiaohuhu",
"avatar_url": "https://avatars.githubusercontent.com/u/6659505?v=4",
"profile": "https://github.com/hc2088",
"contributions": [
"code"
]
},
{
"login": "yukixut",
"name": "yukixut",
"avatar_url": "https://avatars.githubusercontent.com/u/45286155?v=4",
"profile": "https://github.com/yukixut",
"contributions": [
"code"
]
},
{
"login": "pearone",
"name": "pearone",
"avatar_url": "https://avatars.githubusercontent.com/u/23350428?v=4",
"profile": "https://github.com/pearone",
"contributions": [
"code"
]
},
{
"login": "JOYINF1189",
"name": "JOYINF1189",
"avatar_url": "https://avatars.githubusercontent.com/u/46019591?v=4",
"profile": "https://github.com/JOYINF1189",
"contributions": [
"code"
]
},
{
"login": "Blues9527",
"name": "Blues9527",
"avatar_url": "https://avatars.githubusercontent.com/u/35455720?v=4",
"profile": "https://github.com/Blues9527",
"contributions": [
"code"
]
},
{
"login": "miserydx",
"name": "miserydx",
"avatar_url": "https://avatars.githubusercontent.com/u/17892391?v=4",
"profile": "https://github.com/miserydx",
"contributions": [
"code"
]
},
{
"login": "CindyMini",
"name": "CICI Chan",
"avatar_url": "https://avatars.githubusercontent.com/u/16411182?v=4",
"profile": "https://github.com/CindyMini",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 8
Expand Down
11 changes: 10 additions & 1 deletion README-zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,16 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/xxliang"><img src="https://avatars.githubusercontent.com/u/5005255?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sunlight Xie</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=xxliang" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/a303268287"><img src="https://avatars.githubusercontent.com/u/19368353?v=4?s=100" width="100px;" alt=""/><br /><sub><b>lhdycxgghb</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=a303268287" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/hlwhl"><img src="https://avatars.githubusercontent.com/u/7610615?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Prome</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=hlwhl" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/hlwhl"><img src="https://avatars.githubusercontent.com/u/16477333?v=4" width="100px;" alt=""/><br /><sub><b>zmtzawqlp</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=zmtzawqlp" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/zmtzawqlp"><img src="https://avatars.githubusercontent.com/u/16477333?v=4" width="100px;" alt=""/><br /><sub><b>zmtzawqlp</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=zmtzawqlp" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/hc2088"><img src="https://avatars.githubusercontent.com/u/6659505?v=4?s=100" width="100px;" alt=""/><br /><sub><b>woshixiaohuhu</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=hc2088" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/yukixut"><img src="https://avatars.githubusercontent.com/u/45286155?v=4?s=100" width="100px;" alt=""/><br /><sub><b>yukixut</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=yukixut" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/pearone"><img src="https://avatars.githubusercontent.com/u/23350428?v=4?s=100" width="100px;" alt=""/><br /><sub><b>pearone</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=pearone" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/JOYINF1189"><img src="https://avatars.githubusercontent.com/u/46019591?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JOYINF1189</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=JOYINF1189" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Blues9527"><img src="https://avatars.githubusercontent.com/u/35455720?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Blues9527</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=Blues9527" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/miserydx"><img src="https://avatars.githubusercontent.com/u/17892391?v=4?s=100" width="100px;" alt=""/><br /><sub><b>miserydx</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=miserydx" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/CindyMini"><img src="https://avatars.githubusercontent.com/u/16411182?v=4?s=100" width="100px;" alt=""/><br /><sub><b>CICI Chan</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=CindyMini" title="Code">💻</a></td>
</tr>
</table>

Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,16 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/xxliang"><img src="https://avatars.githubusercontent.com/u/5005255?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sunlight Xie</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=xxliang" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/a303268287"><img src="https://avatars.githubusercontent.com/u/19368353?v=4?s=100" width="100px;" alt=""/><br /><sub><b>lhdycxgghb</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=a303268287" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/hlwhl"><img src="https://avatars.githubusercontent.com/u/7610615?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Prome</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=hlwhl" title="Code">💻</a></td>
</td>
<td align="center"><a href="https://github.com/hlwhl"><img src="https://avatars.githubusercontent.com/u/16477333?v=4" width="100px;" alt=""/><br /><sub><b>zmtzawqlp</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=zmtzawqlp" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/zmtzawqlp"><img src="https://avatars.githubusercontent.com/u/16477333?v=4" width="100px;" alt=""/><br /><sub><b>zmtzawqlp</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=zmtzawqlp" title="Code">💻</a></td>
</tr>
<tr>
<td align="center"><a href="https://github.com/hc2088"><img src="https://avatars.githubusercontent.com/u/6659505?v=4?s=100" width="100px;" alt=""/><br /><sub><b>woshixiaohuhu</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=hc2088" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/yukixut"><img src="https://avatars.githubusercontent.com/u/45286155?v=4?s=100" width="100px;" alt=""/><br /><sub><b>yukixut</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=yukixut" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/pearone"><img src="https://avatars.githubusercontent.com/u/23350428?v=4?s=100" width="100px;" alt=""/><br /><sub><b>pearone</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=pearone" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/JOYINF1189"><img src="https://avatars.githubusercontent.com/u/46019591?v=4?s=100" width="100px;" alt=""/><br /><sub><b>JOYINF1189</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=JOYINF1189" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Blues9527"><img src="https://avatars.githubusercontent.com/u/35455720?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Blues9527</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=Blues9527" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/miserydx"><img src="https://avatars.githubusercontent.com/u/17892391?v=4?s=100" width="100px;" alt=""/><br /><sub><b>miserydx</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=miserydx" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/CindyMini"><img src="https://avatars.githubusercontent.com/u/16411182?v=4?s=100" width="100px;" alt=""/><br /><sub><b>CICI Chan</b></sub></a><br /><a href="https://github.com/wuba/fair/commits?author=CindyMini" title="Code">💻</a></td>
</tr>
</table>

Expand Down
5 changes: 5 additions & 0 deletions compiler/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [1.9.0]
* Support TypeArgumentList.
* Support negative value.
* Fix js isNotEmpty bug.

## [1.8.0]
* Compiler log optimized.

Expand Down
6 changes: 3 additions & 3 deletions compiler/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: fair_compiler
description: A complier which can generate Fair bundle for widget with annotation.
version: 1.8.0
version: 1.9.0
homepage: https://fair.58.com/

environment:
Expand Down Expand Up @@ -28,11 +28,11 @@ dependencies:
# fair_annotation:
# path: ../annotation

fair_dart2dsl: ^1.4.0
fair_dart2dsl: ^1.5.0
# fair_dart2dsl:
# path: ../dart2dsl

fair_dart2js: ^1.4.0
fair_dart2js: ^1.5.0
# fair_dart2js:
# path: ../dart2js

Expand Down
5 changes: 5 additions & 0 deletions dart2dsl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.5.0

- Support TypeArgumentList.
- Support Negative Value.

## 1.4.0

- Log optimized.
Expand Down
35 changes: 22 additions & 13 deletions dart2dsl/lib/fairdsl/fair_ast_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,25 @@ class CustomAstVisitor extends SimpleAstVisitor<Map> {
return _buildArgumentList(_visitNodeList(node.arguments));
}

@override
Map visitTypeArgumentList(TypeArgumentList node) {
var map = {};
for (var argument in node.arguments) {
var displayString =
argument.type?.getDisplayString(withNullability: true);
var list = [];
if (displayString != null) {
// map[displayString] = displayString;
list.add(displayString);
}
if (list.isNotEmpty) {
map['typeArgumentListDisplayString'] = list;
}
}
map.addAll(_buildTypeArgumentList(_visitNodeList(node.arguments)));
return map;
}

@override
Map? visitLabel(Label node) {
return _visitNode(node.label);
Expand All @@ -541,19 +560,6 @@ class CustomAstVisitor extends SimpleAstVisitor<Map> {
return _buildVariableExpression(expression);
}

@override
Map? visitTypeArgumentList(TypeArgumentList node) {
var map = {};
for (var argument in node.arguments) {
var displayString =
argument.type?.getDisplayString(withNullability: true);
if (displayString != null) {
map[displayString] = displayString;
}
}
return map;
}

@override
Map? visitPrefixExpression(PrefixExpression node) {
return _buildPrefixExpression(
Expand Down Expand Up @@ -705,6 +711,9 @@ class CustomAstVisitor extends SimpleAstVisitor<Map> {
'body': body,
};

Map _buildTypeArgumentList(List<Map> typeArgumentList) =>
{'type': 'TypeArgumentList', 'typeArgumentList': typeArgumentList};

Map _buildArgumentList(List<Map> argumentList) =>
{'type': 'ArgumentList', 'argumentList': argumentList};

Expand Down
22 changes: 22 additions & 0 deletions dart2dsl/lib/fairdsl/fair_ast_node.dart
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,10 @@ class MethodInvocation extends AstNode {
Expression? callee;
List<Expression?>? argumentList;
SelectAstClass? selectAstClass;
List<Expression?>? typeArgumentList;

MethodInvocation(this.callee, this.argumentList, this.selectAstClass,
this.typeArgumentList,
{Map? ast})
: super(ast: ast);

Expand All @@ -444,6 +446,7 @@ class MethodInvocation extends AstNode {
Expression.fromAst(ast['callee']),
_parseArgumentList(ast['argumentList']),
SelectAstClass.fromAst(ast['selectAstClass']),
_parseTypeArgumentList(ast['typeArguments']),
ast: ast);
}
return null;
Expand Down Expand Up @@ -1097,6 +1100,7 @@ class Expression extends AstNode {
bool? isVariableDeclaration;
bool? isVariableExpression;
bool? isFuncParam;
bool? isTypeName;

@override
Map? toAst() => _ast;
Expand Down Expand Up @@ -1137,6 +1141,7 @@ class Expression extends AstNode {
this.isVariableDeclaration = false,
this.isVariableExpression = false,
this.isFuncParam =false,
this.isTypeName = false,
Map? ast,
}) : super(ast: ast);

Expand Down Expand Up @@ -1237,6 +1242,8 @@ class Expression extends AstNode {
isInterpolationExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.VariableExpression)) {
return Expression(VariableExpression.fromAst(ast), isVariableExpression: true, ast: ast);
} else if (astType == astNodeNameValue(AstNodeName.TypeName)) {
return Expression(TypeName.fromAst(ast), isTypeName: true, ast: ast);
}
return null;
}
Expand Down Expand Up @@ -1311,6 +1318,8 @@ class Expression extends AstNode {
_expression as InterpolationExpression;

VariableExpression get asVariableExpression => _expression as VariableExpression;

TypeName get asTypeNameExpression => _expression as TypeName;
}

class SelectAstClass {
Expand Down Expand Up @@ -1350,6 +1359,19 @@ List<Expression?> _parseArgumentList(Map? ast) {
return arguments;
}

///解析TypeArgumentList 字段
List<Expression?> _parseTypeArgumentList(Map? ast) {
var arguments = <Expression?>[];
if (ast != null) {
var astTypeArgumentList = ast['typeArgumentList'] as List?;
return astTypeArgumentList
?.map((arg) => Expression.fromAst(arg))
.toList() ??
arguments;
}
return arguments;
}

//num _parseNumericValue(Map ast) {
// num n = 0;
// if (ast['type'] == astNodeNameValue(AstNodeName.NumericLiteral)) {
Expand Down
4 changes: 2 additions & 2 deletions dart2dsl/lib/fairdsl/fair_check_node_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ final checkNode = {
'ImplementsClauseImpl': 'visitImplementsClause',
'WithClauseImpl': 'visitWithClause',
'PropertyAccessImpl': 'visitPropertyAccess',
'TypeArgumentListImpl': 'visitTypeArgumentList',
'PrefixExpressionImpl': 'visitPrefixExpression'
'PrefixExpressionImpl': 'visitPrefixExpression',
'TypeArgumentListImpl': 'visitTypeArgumentList'
};
17 changes: 15 additions & 2 deletions dart2dsl/lib/fairdsl/fair_dsl_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ dynamic _buildWidgetDsl(
var dslMap = {};
var paMap = [];
var naMap = {};
var taMap = [];

var methodInvocationExpression = widgetExpression?.asMethodInvocation;
//普通类
Expand Down Expand Up @@ -323,6 +324,13 @@ dynamic _buildWidgetDsl(
}
}

//3.ta
if (methodInvocationExpression.typeArgumentList?.isNotEmpty ?? false) {
taMap.addAll(methodInvocationExpression.typeArgumentList
?.map((ta) => ta?.asTypeNameExpression.name) ??
[]);
}

if (paMap.isNotEmpty) {
dslMap.putIfAbsent('pa', () => paMap);
}
Expand All @@ -332,8 +340,13 @@ dynamic _buildWidgetDsl(
}

var typeArguments = methodInvocationExpression.toAst()?['typeArguments'];
if (typeArguments is Map) {
dslMap.putIfAbsent('ta', () => typeArguments.keys.join(','));
if (typeArguments is Map &&
typeArguments['typeArgumentListDisplayString'] is List) {
dslMap.putIfAbsent(
'ta', () => typeArguments['typeArgumentListDisplayString'].join(','));
}
if (taMap.isNotEmpty) {
dslMap.putIfAbsent('typeArgumentList', () => taMap);
}

return dslMap;
Expand Down
2 changes: 1 addition & 1 deletion dart2dsl/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: fair_dart2dsl
description: Companion compiler for fair_compiler for converting Dart to DSL.
version: 1.4.0
version: 1.5.0
homepage: https://fair.58.com/

environment:
Expand Down
3 changes: 3 additions & 0 deletions dart2js/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.5.0
- fix js isNotEmpty bug.

## 1.4.0

- 升级 analyzer 版本为 5.5.0;
Expand Down
2 changes: 1 addition & 1 deletion dart2js/core-types/string.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Object.defineProperties(String.prototype, {
},
isNotEmpty: {
get: function () {
return this.length;
return !this.isEmpty;
},
},
// runes: {
Expand Down
2 changes: 1 addition & 1 deletion dart2js/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: fair_dart2js
description: Convert individual dart file to js.
version: 1.4.0
version: 1.5.0
homepage: https://fair.58.com/

environment:
Expand Down
6 changes: 3 additions & 3 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ android {
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.example"
minSdkVersion 19
targetSdkVersion 30
minSdkVersion 20
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
Expand All @@ -55,5 +55,5 @@ flutter {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
3 changes: 2 additions & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
android:windowSoftInputMode="adjustResize"
android:exported="true">
<!-- Specifies an Android theme to apply to this Activity as soon as
the Android process has started. This theme is visible to the user
while the Flutter UI initializes. After that, this theme continues
Expand Down
Loading

0 comments on commit 46eeac6

Please sign in to comment.