Skip to content

Commit

Permalink
Merge branch 'wuba:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
yyzl0418 committed Feb 13, 2023
2 parents 3e8d80d + c0bf612 commit 08f954b
Show file tree
Hide file tree
Showing 640 changed files with 115,256 additions and 83 deletions.
28 changes: 20 additions & 8 deletions README-zh.md
Expand Up @@ -63,7 +63,7 @@ dependencies:
# add build_runner and compiler dependency
dev_dependencies:
build_runner: ^2.0.0
fair_compiler: ^1.4.1
fair_compiler: ^1.5.1

# switch "fair_version" according to the local Flutter SDK version
# Flutter SDK 3.3.x(3.3.0、3.3.1、3.3.2、3.3.3、3.3.4、3.3.5、3.3.6) -> flutter_3_3_0
Expand Down Expand Up @@ -150,16 +150,28 @@ faircli create -k carrier -n carrier_project_name

<html>
<div align="center">
<img src="fair_tools.gif" width="50%">
<img src="fair_tools.gif" width="30%">
</div>
</html>

更多介绍请查看 [文档](fair_tools.md)

*工具集:*
Fair脚手架: [Fair CLI](https://pub.dev/packages/faircli)
IDEA插件: [jetbrains plugin fairtemplate](https://plugins.jetbrains.com/plugin/20323-fairtemplate)

## ⚙️fair-online云开发平台
Fair-Online 是面向Flutter 开发者,提供从Flutter 在线开发,到实时编译预览,打包发布、动态下发端侧更新,实现Flutter 线上动态化的一体化云开发平台。

开发者无需配置Flutter 开发环境,在线开发调试代码,即时编译预览,所见即所得,结合58开源团队打造的Flutter 动态化框架 Fair 及热更新平台 FairPushy ,实现Flutter 线上动态化。

<html>
<div align="center">
<img src="./fair_online/fair_online.gif" width="90%">
</div>
</html>


在线体验地址:
[Fair-Online Platform](https://fair-online.58.com/)

更多介绍请查看 [文档](./fair_online/README.md)

## 🔨最近版本

Expand Down Expand Up @@ -352,8 +364,8 @@ Star&Fork 是对我们最大的支持~

对Fair感兴趣的小伙伴,可以加入交流群。技术咨询、讨论,请移步至[![Gitter](https://badges.gitter.im/flutter_fair/community.svg)](https://gitter.im/flutter_fair/community?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)

| 微信 | 美事(内部) |
| ---------------------------- | ---------------------------- |
| 微信 | 美事(内部) |
|--------------------------|--------------------------|
| ![wechat](./weixin.jpeg) | ![meishi](./meishi.jpeg) |

> 微信入群:请先添加58技术小秘书为好友,备注fair,小秘书邀请进群。
Expand Down
20 changes: 18 additions & 2 deletions README.md
Expand Up @@ -55,7 +55,7 @@ dependencies:
# add build_runner and compiler dependency
dev_dependencies:
build_runner: ^2.0.0
fair_compiler: ^1.4.1
fair_compiler: ^1.5.1

# switch "fair_version" according to the local Flutter SDK version
# Flutter SDK 3.3.x(3.3.0、3.3.1、3.3.2、3.3.3、3.3.4、3.3.5、3.3.6) -> flutter_3_3_0
Expand Down Expand Up @@ -142,12 +142,28 @@ After using faircli to configure the local hot update service, open the develope

<html>
<div align="center">
<img src="fair_tools.gif" width="50%">
<img src="fair_tools.gif" width="30%">
</div>
</html>

For more details, please refer to [fair_tools](fair_tools.md)

## Fair-Online Platform
Fair-Online is an integrated cloud development platform for Flutter developers, from online development of Flutter, to real-time compilation and preview, packaging and publishing, and dynamic release of end-side updates, to realize the dynamic online Flutter.

Developers do not need to configure the Flutter development environment, develop and debug code online, compile and preview in real time, and what you see is what you get. Combined with the Flutter dynamic framework Fair and the hot update platform FairPushy created by the 58 open source team, Flutter online dynamics are realized.

<html>
<div align="center">
<img src="./fair_online/fair_online.gif" width="90%">
</div>
</html>

Online experience URL:
[Fair-Online Platform](https://fair-online.58.com/)

For more details, please refer to [fair_online](./fair_online/README.md)

## Documentation
For more details, please refer to [https://fair.58.com](https://fair.58.com)
### Tools
Expand Down
6 changes: 6 additions & 0 deletions compiler/CHANGELOG.md
@@ -1,3 +1,9 @@
## [1.5.1]
* bugfix.

## [1.5.0]
* The function supports parameter passing.

## [1.4.1]
* bugfix.

Expand Down
4 changes: 2 additions & 2 deletions compiler/README.md
Expand Up @@ -5,7 +5,7 @@ A complier which can generate Fair bundle for widget with annotation.
![](http://pic1.58cdn.com.cn/nowater/jltx/n_v26dd88a1afa1c4cc9b186524f96ff3f65.png)
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
<p align="center">
<a href="https://pub.dev/packages/fair"><img src="https://img.shields.io/badge/pub-1.4.1-orange" alt="pub"></a>
<a href="https://pub.dev/packages/fair"><img src="https://img.shields.io/badge/pub-1.5.1-orange" alt="pub"></a>
<a href="https://github.com/wuba/fair"><img src="https://img.shields.io/badge/platform-flutter-blue.svg" alt="github"></a>
<a href="https://fair.58.com/"><img src="https://img.shields.io/badge/doc-fair.58.com-green.svg" alt="doc"></a>
<a href="https://github.com/wuba/fair/LICENSE"><img src="https://img.shields.io/badge/license-BSD-green.svg" alt="license"></a>
Expand Down Expand Up @@ -53,7 +53,7 @@ dependencies:
# add build_runner and compiler dependency
dev_dependencies:
build_runner: ^2.0.0
fair_compiler: ^1.4.1
fair_compiler: ^1.5.1

# switch "fair_version" according to the local Flutter SDK version
# Flutter SDK 3.0.x(3.0.0、3.0.1、3.0.2、3.0.3、3.0.4、3.0.5) -> flutter_3_0_0
Expand Down
6 changes: 3 additions & 3 deletions compiler/pubspec.yaml
@@ -1,6 +1,6 @@
name: fair_compiler
description: A complier which can generate Fair bundle for widget with annotation.
version: 1.4.1
version: 1.5.1
homepage: https://fair.58.com/

environment:
Expand All @@ -25,8 +25,8 @@ dependencies:
# fair_annotation:
# path: ../annotation
http: ^0.13.3
fair_dart2dsl: ^1.0.2
fair_dart2js: ^1.3.1
fair_dart2dsl: ^1.1.0
fair_dart2js: ^1.3.2

dev_dependencies:
test: ^1.17.12
4 changes: 4 additions & 0 deletions dart2dsl/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.1.0

- The function supports parameter passing.

## 1.0.2

- bugfix.
Expand Down
16 changes: 14 additions & 2 deletions dart2dsl/lib/fairdsl/fair_dsl_gen.dart
Expand Up @@ -229,12 +229,24 @@ dynamic _buildWidgetDsl(
return '\$(${methodInvocationExpression?.callee?.asIdentifier.name})';
} else if (fairDslContex?.variableAnnotation
.containsKey(methodInvocationExpression?.callee?.asIdentifier.name)==true) {
return '%(${methodInvocationExpression?.callee?.asIdentifier.name})';
if (methodInvocationExpression?.argumentList?.isNotEmpty ?? false) {
var args = methodInvocationExpression?.argumentList?.fold('', (previousValue, element) =>
'$previousValue,${_buildValueExpression(element, fairDslContex)}').substring(1);
return '%(${methodInvocationExpression?.callee?.asIdentifier.name}($args))';
} else {
return '%(${methodInvocationExpression?.callee?.asIdentifier.name})';
}
}

if (RegExp(r'^[a-z_]')
.hasMatch(methodInvocationExpression?.callee?.asIdentifier.name??'')) {
return '%(${methodInvocationExpression?.callee?.asIdentifier.name})';
if (methodInvocationExpression?.argumentList?.isNotEmpty ?? false) {
var args = methodInvocationExpression?.argumentList?.fold('', (previousValue, element) =>
'$previousValue,${_buildValueExpression(element, fairDslContex)}').substring(1);
return '%(${methodInvocationExpression?.callee?.asIdentifier.name}($args))';
} else {
return '%(${methodInvocationExpression?.callee?.asIdentifier.name})';
}
} else {
dslMap.putIfAbsent('className',
() => methodInvocationExpression?.callee?.asIdentifier.name);
Expand Down
2 changes: 1 addition & 1 deletion dart2dsl/pubspec.yaml
@@ -1,6 +1,6 @@
name: fair_dart2dsl
description: Companion compiler for fair_compiler for converting Dart to DSL.
version: 1.0.2
version: 1.1.0
homepage: https://fair.58.com/

environment:
Expand Down
4 changes: 4 additions & 0 deletions dart2js/CHANGELOG.md
@@ -1,3 +1,7 @@
## 1.3.2

- bugfix.

## 1.3.1

- 修复字段覆盖 bug
Expand Down
2 changes: 0 additions & 2 deletions dart2js/lib/src/declaration/ClassDeclarationData.dart
Expand Up @@ -108,9 +108,7 @@ class ClassDeclarationData {
if(element.isGetter){
fieldsLiterval += 'this.${element.name} = (function(_this) { with (_this) {${element.initVal ?? 'null'} } })(this);';
}else{
if(element.initVal!=null){
fieldsLiterval += 'this.${element.name} = ${element.initVal};';
}
}
});
return fieldsLiterval;
Expand Down
4 changes: 3 additions & 1 deletion dart2js/lib/src/visitor/ClassDeclarationVisitor.dart
Expand Up @@ -180,7 +180,9 @@ class ClassDeclarationVisitor
void parseByFile(String filePath) {
var file = File(filePath);
var result = parseFile(
path: file.absolute.uri.normalizePath().path,
path: Platform.isWindows
? filePath
: file.absolute.uri.normalizePath().path,
featureSet: FeatureSet.fromEnableFlags([]));
result.unit.visitChildren(this);
}
Expand Down
2 changes: 1 addition & 1 deletion dart2js/pubspec.yaml
@@ -1,6 +1,6 @@
name: fair_dart2js
description: Convert individual dart file to js.
version: 1.3.1
version: 1.3.2
homepage: https://fair.58.com/

environment:
Expand Down
4 changes: 0 additions & 4 deletions fair/android/build.gradle
Expand Up @@ -9,15 +9,13 @@ group 'com.wuba.fair'
version '1.0'

buildscript {
ext.kotlin_version = '1.5.31'
repositories {
google()
jcenter()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}

Expand All @@ -29,7 +27,6 @@ rootProject.allprojects {
}

apply plugin: 'com.android.library'
apply plugin: "kotlin-android"

android {
compileSdkVersion 28
Expand Down Expand Up @@ -104,6 +101,5 @@ android {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
}

Binary file added fair/assets/images/error.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 9 additions & 2 deletions fair/lib/src/bloc/common.dart
Expand Up @@ -80,7 +80,14 @@ FairWidgetBinding provider = () {
'BorderSide': (props) => BorderSide(
color: props['color'],
width: props['width'],
style: props['style'] ?? BorderStyle.solid
),
style: props['style'] ?? BorderStyle.solid),
'IconData': (props) {
// const Map pro = Map.from(props);
return IconData(
int.parse(props['pa'][0]),
fontFamily: props['fontFamily'],
fontPackage: props['fontPackage'],
);
},
};
};
42 changes: 35 additions & 7 deletions fair/lib/src/internal/bind_data.dart
Expand Up @@ -6,8 +6,12 @@

import 'dart:convert';

import 'package:flutter/material.dart';

import '../module/module_registry.dart';
import '../render/domain.dart';
import '../render/expression.dart';
import '../render/proxy.dart';
import '../type.dart';

class BindingData {
Expand Down Expand Up @@ -35,9 +39,33 @@ class BindingData {
return functionOf(key);
}

dynamic runFunctionOf(String funcName, {String? exp}) {
dynamic runFunctionOf(String funcName, ProxyMirror? proxyMirror,
BindingData? bound, Domain? domain,
{String? exp}) {
if (_functions?[funcName] == null) {
var result = _functions?['runtimeInvokeMethodSync']?.call(funcName);
var result;
if (RegExp(r'.+\(.+\)', multiLine: false).hasMatch(funcName)) {
var rFuncName = funcName.substring(0, funcName.indexOf('('));
var params =
funcName.substring(funcName.indexOf('(') + 1 , funcName.lastIndexOf(')'));
var args = params.split(',').map((e) {
if (RegExp(r'\^\(index\)', multiLine: false).hasMatch(e)) {
return domain?.index;
} else if (domain != null && domain.match(e)) {
return domain.bindValue(e);
} else {
var r = proxyMirror?.evaluate(null, bound, e, domain: domain);
if (r?.data == null) {
return e;
} else {
return r?.data is ValueNotifier ? r?.data.value : r?.data;
}
}
}).toList();
result = _functions?['runtimeInvokeMethodSync']?.call(rFuncName, args);
} else {
result = _functions?['runtimeInvokeMethodSync']?.call(funcName);
}
var value = jsonDecode(result);
return value['result']['result'];
} else {
Expand All @@ -56,11 +84,11 @@ class BindingData {
dynamic bindRuntimeValueOf(String name) {
// _delegateValues优先级高于JS,如果要使用JS的变量,需要重命名变量
if (_values?[name] == null) {
var result = _functions?['runtimeParseVar']?.call({name: ''});
var value = jsonDecode(result);
if (value['result'][name] != null) {
return value['result'][name];
}
var result = _functions?['runtimeParseVar']?.call({name: ''});
var value = jsonDecode(result);
if (value['result'][name] != null) {
return value['result'][name];
}
} else {
if (_values != null && _values?[name] != null) {
return Function.apply(_values![name]!, null);
Expand Down
2 changes: 1 addition & 1 deletion fair/lib/src/internal/error_tips.dart
Expand Up @@ -37,7 +37,7 @@ class WarningWidget extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
Image(
image: NetworkImage('http://pic1.58cdn.com.cn/nowater/jltx/n_v2e7bc132cc46043d89dd927d9c184d599.png'),
image: AssetImage('packages/fair/assets/images/error.jpg'),
width: 80,
height: 80,
),
Expand Down

0 comments on commit 08f954b

Please sign in to comment.