Skip to content

Commit e79c8b7

Browse files
committed
Merge remote-tracking branch 'upstream/main' into dev_wanbing
2 parents 9902bef + e6be29c commit e79c8b7

File tree

187 files changed

+6815
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+6815
-302
lines changed

README-zh.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![social preview](social-dark.png)
22

33
<p align="center">
4-
<a href="https://pub.dev/packages/fair"><img src="https://img.shields.io/badge/pub-2.8.0-orange" alt="pub"></a>
4+
<a href="https://pub.dev/packages/fair"><img src="https://img.shields.io/badge/pub-2.8.1-orange" alt="pub"></a>
55
<a href="https://github.com/wuba/fair"><img src="https://img.shields.io/badge/platform-flutter-blue.svg" alt="github"></a>
66
<a href="https://fair.58.com/"><img src="https://img.shields.io/badge/doc-fair.58.com-green.svg" alt="doc"></a>
77
<a href="https://github.com/wuba/fair/LICENSE"><img src="https://img.shields.io/badge/license-BSD-green.svg" alt="license"></a>
@@ -22,7 +22,7 @@ Fair是为Flutter设计的动态化框架,通过Fair Compiler工具对原生Da
2222
**如果您需要热更新平台,可关注Fair Pushy**
2323
> 热更新平台:[FAIR PUSHY](https://github.com/wuba/FairPushy)
2424
25-
![](fair/what-is-fair.png)
25+
![](what-is-fair.png)
2626

2727
Fair的UI渲染是无损的,可以做到像素级别的还原,看一张转义Best Flutter UI Templates部分页面后的效果:
2828

@@ -58,7 +58,7 @@ git clone https://github.com/wuba/fair.git
5858
```yaml
5959
# add Fair dependency
6060
dependencies:
61-
fair: 2.8.0
61+
fair: 2.8.1
6262

6363
# add build_runner and compiler dependency
6464
dev_dependencies:
@@ -157,6 +157,11 @@ faircli create -k carrier -n carrier_project_name
157157

158158
## 🔨最近版本
159159

160+
### 2.8.1
161+
更新时间:2022.11.01
162+
163+
- 修复 bug:CustomScrollView 引用外部函数构建 builder 报错。
164+
160165
### 2.8.0
161166
更新时间:2022.10.21
162167

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![social preview](social-dark.png)
22
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
33
<p align="center">
4-
<a href="https://pub.dev/packages/fair"><img src="https://img.shields.io/badge/pub-2.8.0-orange" alt="pub"></a>
4+
<a href="https://pub.dev/packages/fair"><img src="https://img.shields.io/badge/pub-2.8.1-orange" alt="pub"></a>
55
<a href="https://github.com/wuba/fair"><img src="https://img.shields.io/badge/platform-flutter-blue.svg" alt="github"></a>
66
<a href="https://fair.58.com/"><img src="https://img.shields.io/badge/doc-fair.58.com-green.svg" alt="doc"></a>
77
<a href="https://github.com/wuba/fair/LICENSE"><img src="https://img.shields.io/badge/license-BSD-green.svg" alt="license"></a>
@@ -17,7 +17,7 @@ Fair is a lightweight package for Flutter, which can be used to update widget tr
1717

1818
We create Fair so we can dispatch any pages changes to users as bundle(s), the way similar to React Native. With Flutter Fair integrated, you can publish your pages without waiting for the next release date of your App. Fair provides standard widget and some logic plugins, it can be used as a new dynamic page or as part of existing Flutter page.
1919

20-
![](fair/what-is-fair-en.png)
20+
![](what-is-fair-en.png)
2121

2222
Fair's UI rendering is lossless and can be restored at the pixel level. Take a look at the effect of escaping some pages of Best Flutter UI Templates:
2323

@@ -50,7 +50,7 @@ Assuming that the fair project and your own project are in the same folder:
5050
```yaml
5151
# add Fair dependency
5252
dependencies:
53-
fair: 2.8.0
53+
fair: 2.8.1
5454

5555
# add build_runner and compiler dependency
5656
dev_dependencies:
@@ -153,6 +153,11 @@ For more details, please refer to [fair_tools](fair_tools.md)
153153

154154
## versions
155155

156+
### 2.8.1
157+
updateDate:2022.11.01
158+
159+
- Fixed:CustomScrollView reference external function builder bug.
160+
156161
### 2.8.0
157162
updateDate:2022.10.21
158163

compiler/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## [1.4.1-dev.1]
2+
* bugfix.
3+
14
## [1.4.0]
25
* bugfix.
36

compiler/lib/src/generator.dart

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class BindingGenerator extends GeneratorForAnnotation<FairBinding> {
8181
buffer = StringBuffer();
8282
buffer!.writeln('# Generated by Fair on ${DateTime.now()}.');
8383
}
84-
84+
StringBuffer? importsBuffer;
8585
var resource =
8686
annotation.peek('packages')?.listValue.map((e) => e.toStringValue());
8787
var list = [];
@@ -103,6 +103,9 @@ class BindingGenerator extends GeneratorForAnnotation<FairBinding> {
103103
element.indexOf('\'') + 1, element.lastIndexOf('\''));
104104
elements
105105
.add(element.contains('package:') ? package : str + package);
106+
} else if (element.startsWith('import')) {
107+
importsBuffer ??= StringBuffer();
108+
importsBuffer!.writeln(element);
106109
}
107110
});
108111
if (elements.isNotEmpty) {
@@ -130,6 +133,11 @@ class BindingGenerator extends GeneratorForAnnotation<FairBinding> {
130133
buffer!.writeln('${buildStep.inputId.uri}');
131134
await _transitSource(buildStep, buildStep.inputId, dir);
132135
}
136+
if (importsBuffer != null) {
137+
File(path.join(dir, 'fair.binding.imports'))
138+
..createSync(recursive: true)
139+
..writeAsStringSync(importsBuffer!.toString());
140+
}
133141
if (!generated) {
134142
generated = true;
135143
return '${package.absolute.path}';
@@ -214,7 +222,11 @@ class PackageBuilder extends Builder with FairCompiler {
214222
.where((l) => !l.startsWith('#'))
215223
.map((e) => 'import \'$e\';')
216224
.toSet();
217-
225+
var bindingImportsFile = File(path.join(
226+
'.dart_tool', 'build', 'fairc', 'source', 'fair.binding.imports'));
227+
if (bindingImportsFile.existsSync()) {
228+
annotated.addAll(bindingImportsFile.readAsLinesSync().toSet());
229+
}
218230
var dir = path.join('.dart_tool', 'build', 'fairc', 'source');
219231
var r = await compile(buildStep, ['-k', 'dart', '-d', dir]);
220232
String generated;
@@ -224,6 +236,8 @@ class PackageBuilder extends Builder with FairCompiler {
224236
}
225237
Directory(dir).deleteSync(recursive: true);
226238
var builder = StringBuffer('// Generated by Fair on ${DateTime.now()}.\n');
239+
builder.writeln(
240+
'// ignore_for_file: implementation_imports, unused_import, depend_on_referenced_packages, unused_shown_name, duplicate_import, always_specify_types');
227241
annotated.forEach((element) => builder.writeln(element));
228242
builder.writeln(r.data);
229243
generated = builder.toString();

compiler/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: fair_compiler
22
description: A complier which can generate Fair bundle for widget with annotation.
3-
version: 1.4.0
3+
version: 1.4.1-dev.1
44
homepage: https://fair.58.com/
55

66
environment:
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import '../../convertorV2.dart';
2+
3+
String a = convertFunction('''
4+
void main(){
5+
var paint = Paint()..color = Colors.black
6+
..strokeCap = StrokeCap.round
7+
..strokeWidth = 5.0;
8+
9+
10+
}
11+
''');
12+
13+
// 语法不支持报错
14+
String b = convertFunction('''
15+
void main(){
16+
querySelector('#confirm')?..text = 'Confirm'
17+
..classes.add('important')
18+
..onClick.listen((e) => window.alert('Confirmed!'))
19+
..scrollIntoView();
20+
}
21+
''');
22+
23+
void main() {
24+
print(a);
25+
print("-----------------------");
26+
print(b);
27+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import '../../convertorV2.dart';
2+
3+
// as 关键字 被舍弃
4+
String a = convertFunction('''
5+
void main(){
6+
var visibility = isPublic ? 'public' : 'private';
7+
var x= name ?? 'Guest';
8+
String playerName(String? name) => name ?? 'Guest';
9+
}
10+
''');
11+
12+
void main() {
13+
print(a);
14+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import '../../convertorV2.dart';
2+
3+
String a = convertFunction('''
4+
void main(){
5+
do {
6+
printLine();
7+
} while (!atEndOfPage());
8+
9+
while (true) {
10+
if (shutDownRequested()) break;
11+
processIncomingRequests();
12+
}
13+
14+
for (int i = 0; i < candidates.length; i++) {
15+
var candidate = candidates[i];
16+
if (candidate.yearsExperience < 5) {
17+
continue;
18+
}
19+
candidate.interview();
20+
}
21+
22+
}
23+
''');
24+
25+
void main() {
26+
print(a);
27+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import '../../convertorV2.dart';
2+
3+
String a = convertFunction('''
4+
void main(){
5+
var callbacks = [];
6+
for (var i = 0; i < 2; i++) {
7+
callbacks.add(() => print(i));
8+
}
9+
10+
for (final c in callbacks) {
11+
c();
12+
}
13+
var collection = [1, 2, 3];
14+
collection.forEach(print); // 1 2 3
15+
}
16+
''');
17+
18+
void main() {
19+
print(a);
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import '../../convertorV2.dart';
2+
3+
String a = convertFunction('''
4+
void main(){
5+
if (isRaining()) {
6+
you.bringRainCoat();
7+
} else if (isSnowing()) {
8+
you.wearJacket();
9+
} else {
10+
car.putTopDown();
11+
}
12+
}
13+
''');
14+
15+
void main() {
16+
print(a);
17+
}

0 commit comments

Comments
 (0)