Skip to content

Commit 1f45547

Browse files
committed
chore: update version to 1.1.0, enhance API with new features and improved documentation
1 parent df74761 commit 1f45547

Some content is hidden

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

47 files changed

+8488
-2078
lines changed

.github/workflows/precompile-binaries.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Precompile Binaries
22

3+
concurrency:
4+
group: ${{ github.workflow }}
5+
cancel-in-progress: true
6+
37
on:
48
workflow_dispatch:
59
inputs:
@@ -8,8 +12,6 @@ on:
812
required: true
913
default: ''
1014
push:
11-
tags:
12-
- v*
1315

1416
env:
1517
GITHUB_REPOSITORY: fluttercandies/fjs
@@ -71,6 +73,9 @@ jobs:
7173
if: matrix.os == 'macos-latest'
7274
run: |
7375
export IPHONEOS_DEPLOYMENT_TARGET=12.0
76+
export MACOSX_DEPLOYMENT_TARGET=12.0
77+
# Set environment variables that work for both iOS device and simulator builds
78+
export BINDGEN_EXTRA_CLANG_ARGS="-target aarch64-apple-ios12.0"
7479
dart run cargokit/build_tool/bin/build_tool.dart precompile-binaries -v --manifest-dir=${{ env.RUST_CRATE_DIR }} --repository=${{ env.GITHUB_REPOSITORY }}
7580
env:
7681
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# Changelog
22

3+
## 1.1.0
4+
5+
* **FEATURE**: Enhanced API design with improved high-level interface
6+
* **FEATURE**: Advanced example application with interactive playground, responsive layout, haptic feedback, and local storage
7+
* **FEATURE**: New module management methods `declareNewModule`, `declareNewModules`, and `clearNewModules` for better module handling
8+
* **FEATURE**: Built-in modules are now configured during runtime creation via `JsAsyncRuntime.withOptions()`
9+
* **DEPRECATED**: Removed `enableBuiltinModule()` method - use runtime options instead
10+
* **DEPRECATED**: Removed `declareModule()` method - use `declareNewModule()` instead
11+
* **DEPRECATED**: Removed `importModule()` method
12+
* **DOCS**: Comprehensive documentation updates with detailed examples and API reference
13+
* **DOCS**: Enhanced quick start guide and advanced usage examples
14+
* **PERF**: Improved memory management and garbage collection controls
15+
* **PERF**: Better error handling and recovery mechanisms
16+
* **INTERNAL**: Updated dependencies for better compatibility
17+
* **INTERNAL**: Enhanced build system for faster development cycles
18+
19+
## 1.0.9
20+
21+
* Bug fixes and stability improvements
22+
323
## 1.0.3
424

525
* Precompiled binaries support for macOS, iOS, Linux, Windows, and Android

README.md

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,17 @@ Future<void> main() async {
7272
### 🔧 2. Create a JavaScript Engine
7373

7474
```dart
75-
// Create runtime and context
76-
final runtime = JsAsyncRuntime();
77-
final context = await JsAsyncContext.from(rt: runtime);
75+
// Create runtime with built-in options
76+
final runtime = await JsAsyncRuntime.withOptions(
77+
builtin: JsBuiltinOptions(
78+
fetch: true,
79+
console: true,
80+
timers: true,
81+
),
82+
);
83+
84+
// Create context
85+
final context = await JsAsyncContext.from(runtime);
7886
7987
// Create engine with bridge support
8088
final engine = JsEngine(context);
@@ -101,16 +109,10 @@ final asyncResult = await engine.eval(JsCode.code('''
101109
'''));
102110
```
103111

104-
### 🌐 4. Enable Built-in Modules
112+
### 🌐 4. Use Built-in Modules
105113

106114
```dart
107-
// Enable fetch and console APIs
108-
await engine.enableBuiltinModule(const JsBuiltinOptions(
109-
fetch: true,
110-
console: true,
111-
timers: true,
112-
));
113-
115+
// Built-in modules are enabled during runtime creation
114116
// Now you can use fetch, console.log, setTimeout, etc.
115117
await engine.eval(JsCode.code('''
116118
console.log('Hello from JavaScript!');
@@ -121,7 +123,7 @@ await engine.eval(JsCode.code('''
121123
### 📦 5. Work with Modules
122124

123125
```dart
124-
// Declare a module
126+
// Declare a single module
125127
const moduleCode = '''
126128
export function greet(name) {
127129
return `Hello, ${name}!`;
@@ -130,15 +132,26 @@ export function greet(name) {
130132
export const version = '1.0.0';
131133
''';
132134
133-
await engine.declareModule(
135+
await engine.declareNewModule(
134136
JsModule.code(module: 'greeting', code: moduleCode)
135137
);
136138
137-
// Use the module
139+
// Declare multiple modules at once
140+
await engine.declareNewModules([
141+
JsModule.code('math', 'export const add = (a, b) => a + b;'),
142+
JsModule.code('string', 'export const reverse = (s) => s.split("").reverse().join("");'),
143+
]);
144+
145+
// Use the modules
138146
await engine.eval(JsCode.code('''
139147
import { greet, version } from 'greeting';
148+
import { add } from 'math';
149+
import { reverse } from 'string';
150+
140151
console.log(greet('Flutter'));
141152
console.log('Version:', version);
153+
console.log('Add 2 + 3:', add(2, 3));
154+
console.log('Reverse hello:', reverse('hello'));
142155
'''));
143156
```
144157

@@ -242,13 +255,11 @@ class JsEngine {
242255
// Execute JavaScript code
243256
Future<JsValue> eval(JsCode source, {JsEvalOptions? options, Duration? timeout});
244257
245-
// Enable built-in modules
246-
Future<JsValue> enableBuiltinModule(JsBuiltinOptions options, {Duration? timeout});
247-
248258
// Module operations
249-
Future<JsValue> declareModule(JsModule module, {Duration? timeout});
259+
Future<JsValue> declareNewModule(JsModule module, {Duration? timeout});
260+
Future<JsValue> declareNewModules(List<JsModule> modules, {Duration? timeout});
250261
Future<JsValue> evaluateModule(JsModule module, {Duration? timeout});
251-
Future<JsValue> importModule(String specifier, {Duration? timeout});
262+
Future<JsValue> clearNewModules({Duration? timeout});
252263
253264
// Cleanup
254265
Future<void> dispose();

README_zh.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,17 @@ Future<void> main() async {
7272
### 🔧 2. 创建 JavaScript 引擎
7373

7474
```dart
75-
// 创建运行时和上下文
76-
final runtime = JsAsyncRuntime();
77-
final context = await JsAsyncContext.from(rt: runtime);
75+
// 创建带内置选项的运行时
76+
final runtime = await JsAsyncRuntime.withOptions(
77+
builtin: JsBuiltinOptions(
78+
fetch: true,
79+
console: true,
80+
timers: true,
81+
),
82+
);
83+
84+
// 创建上下文
85+
final context = await JsAsyncContext.from(runtime);
7886
7987
// 创建支持桥接的引擎
8088
final engine = JsEngine(context);
@@ -101,16 +109,10 @@ final asyncResult = await engine.eval(JsCode.code('''
101109
'''));
102110
```
103111

104-
### 🌐 4. 启用内置模块
112+
### 🌐 4. 使用内置模块
105113

106114
```dart
107-
// 启用 fetch 和 console API
108-
await engine.enableBuiltinModule(const JsBuiltinOptions(
109-
fetch: true,
110-
console: true,
111-
timers: true,
112-
));
113-
115+
// 内置模块在运行时创建期间启用
114116
// 现在可以使用 fetch、console.log、setTimeout 等
115117
await engine.eval(JsCode.code('''
116118
console.log('你好,来自 JavaScript!');
@@ -121,7 +123,7 @@ await engine.eval(JsCode.code('''
121123
### 📦 5. 使用模块
122124

123125
```dart
124-
// 声明模块
126+
// 声明单个模块
125127
const moduleCode = '''
126128
export function greet(name) {
127129
return `你好,${name}!`;
@@ -130,15 +132,26 @@ export function greet(name) {
130132
export const version = '1.0.0';
131133
''';
132134
133-
await engine.declareModule(
135+
await engine.declareNewModule(
134136
JsModule.code(module: 'greeting', code: moduleCode)
135137
);
136138
139+
// 一次声明多个模块
140+
await engine.declareNewModules([
141+
JsModule.code('math', 'export const add = (a, b) => a + b;'),
142+
JsModule.code('string', 'export const reverse = (s) => s.split("").reverse().join("");'),
143+
]);
144+
137145
// 使用模块
138146
await engine.eval(JsCode.code('''
139147
import { greet, version } from 'greeting';
148+
import { add } from 'math';
149+
import { reverse } from 'string';
150+
140151
console.log(greet('Flutter'));
141152
console.log('版本:', version);
153+
console.log('加法 2 + 3:', add(2, 3));
154+
console.log('反转 hello:', reverse('hello'));
142155
'''));
143156
```
144157

@@ -242,13 +255,11 @@ class JsEngine {
242255
// 执行 JavaScript 代码
243256
Future<JsValue> eval(JsCode source, {JsEvalOptions? options, Duration? timeout});
244257
245-
// 启用内置模块
246-
Future<JsValue> enableBuiltinModule(JsBuiltinOptions options, {Duration? timeout});
247-
248258
// 模块操作
249-
Future<JsValue> declareModule(JsModule module, {Duration? timeout});
259+
Future<JsValue> declareNewModule(JsModule module, {Duration? timeout});
260+
Future<JsValue> declareNewModules(List<JsModule> modules, {Duration? timeout});
250261
Future<JsValue> evaluateModule(JsModule module, {Duration? timeout});
251-
Future<JsValue> importModule(String specifier, {Duration? timeout});
262+
Future<JsValue> clearNewModules({Duration? timeout});
252263
253264
// 清理
254265
Future<void> dispose();

build.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,4 @@ targets:
44
freezed:
55
generate_for:
66
include:
7-
- lib/src/frb/api/js.dart
8-
- lib/src/frb/api/value.dart
7+
- lib/src/frb/api/*.dart

cargokit/build_tool/lib/src/target.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,8 @@ class Target {
5555
flutter: 'linux-arm64',
5656
),
5757
Target(
58-
rust: 'x86_64-apple-darwin',
59-
darwinPlatform: 'macosx',
60-
darwinArch: 'x86_64',
61-
),
62-
Target(
63-
rust: 'aarch64-apple-darwin',
64-
darwinPlatform: 'macosx',
58+
rust: 'aarch64-apple-ios-sim',
59+
darwinPlatform: 'iphonesimulator',
6560
darwinArch: 'arm64',
6661
),
6762
Target(
@@ -70,13 +65,18 @@ class Target {
7065
darwinArch: 'x86_64',
7166
),
7267
Target(
73-
rust: 'aarch64-apple-ios-sim',
74-
darwinPlatform: 'iphonesimulator',
68+
rust: 'aarch64-apple-ios',
69+
darwinPlatform: 'iphoneos',
7570
darwinArch: 'arm64',
7671
),
7772
Target(
78-
rust: 'aarch64-apple-ios',
79-
darwinPlatform: 'iphoneos',
73+
rust: 'x86_64-apple-darwin',
74+
darwinPlatform: 'macosx',
75+
darwinArch: 'x86_64',
76+
),
77+
Target(
78+
rust: 'aarch64-apple-darwin',
79+
darwinPlatform: 'macosx',
8080
darwinArch: 'arm64',
8181
),
8282
];

example/README.md

Lines changed: 0 additions & 16 deletions
This file was deleted.

example/android/app/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ android {
2323
applicationId = "app.fjs_example"
2424
// You can update the following values to match your application needs.
2525
// For more information, see: https://flutter.dev/to/review-gradle-config.
26-
minSdk = 21
26+
minSdkVersion = flutter.minSdkVersion
2727
targetSdk = 36
2828
versionCode = flutter.versionCode
2929
versionName = flutter.versionName

example/ios/Flutter/AppFrameworkInfo.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@
2121
<key>CFBundleVersion</key>
2222
<string>1.0</string>
2323
<key>MinimumOSVersion</key>
24-
<string>12.0</string>
24+
<string>13.0</string>
2525
</dict>
2626
</plist>

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
# platform :ios, '12.0'
2+
# platform :ios, '13.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

0 commit comments

Comments
 (0)