diff --git a/.github/workflows/dart_lint.yml b/.github/workflows/dart_lint.yml index 44e0efdfdc..25c4990cac 100644 --- a/.github/workflows/dart_lint.yml +++ b/.github/workflows/dart_lint.yml @@ -8,9 +8,12 @@ name: Flutter lint on: push: branches: [ main ] + paths: + - 'frontend/app_flowy' pull_request: branches: [ main ] - + paths: + - 'frontend/app_flowy' env: CARGO_TERM_COLOR: always @@ -25,10 +28,10 @@ jobs: - uses: subosito/flutter-action@v1 with: channel: "stable" - - name: Flutter pub get + - name: Deps Flutter run: flutter pub get working-directory: frontend/app_flowy - - name: Generate language files + - name: Code Generate working-directory: frontend/app_flowy run: flutter pub run easy_localization:generate --source-dir ./assets/translations -f keys -O lib/generated -o locale_keys.g.dart diff --git a/.github/workflows/dart_test.yml b/.github/workflows/dart_test.yml new file mode 100644 index 0000000000..6106126cee --- /dev/null +++ b/.github/workflows/dart_test.yml @@ -0,0 +1,47 @@ +name: Unit test(Flutter) + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +env: + CARGO_TERM_COLOR: always + +jobs: + tests: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - uses: subosito/flutter-action@v1 + with: + channel: "stable" + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + - name: Deps Rust + working-directory: frontend + run: | + cargo install --force cargo-make + cargo install --force duckscript_cli + cargo make flowy_dev + echo PATH="$PATH":"$HOME/.pub-cache/bin" >> $GITHUB_PATH + - name: Deps Flutter + run: flutter pub get + working-directory: frontend/app_flowy + - name: Code Generate + working-directory: frontend/app_flowy + run: + flutter pub run easy_localization:generate --source-dir ./assets/translations -f keys -O lib/generated -o locale_keys.g.dart + - name: Build FlowySDK + working-directory: frontend + run: | + flutter config --enable-linux-desktop + cargo make --profile development-linux-x86 flowy-sdk-dev + - name: Run bloc tests + working-directory: frontend/app_flowy + run: | + flutter test + diff --git a/.github/workflows/rust_test.yml b/.github/workflows/rust_test.yml index ec7dd72f49..0321d5f9bc 100644 --- a/.github/workflows/rust_test.yml +++ b/.github/workflows/rust_test.yml @@ -3,14 +3,14 @@ name: Unit test(Rust) on: push: branches: [ main ] -# paths: -# - 'frontend/rust-lib' -# - 'shared-lib' + paths: + - 'frontend/rust-lib' + - 'shared-lib' pull_request: branches: [ main ] -# paths: -# - 'frontend/rust-lib' -# - 'shared-lib' + paths: + - 'frontend/rust-lib' + - 'shared-lib' env: CARGO_TERM_COLOR: always @@ -31,9 +31,9 @@ jobs: - name: Install cargo-make run: cargo install --force cargo-make working-directory: frontend - - name: RustLib tests + - name: Run rust-lib tests run: cargo test --no-default-features working-directory: frontend/rust-lib - - name: Sharedlib tests + - name: Run shared-lib tests run: cargo test --no-default-features working-directory: shared-lib diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml index f7c47820cd..e661a425b6 100644 --- a/frontend/Makefile.toml +++ b/frontend/Makefile.toml @@ -14,12 +14,13 @@ RUST_LOG = "info" CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = true CARGO_MAKE_CRATE_FS_NAME = "dart_ffi" CARGO_MAKE_CRATE_NAME = "dart-ffi" +LIB_NAME = "dart_ffi" VERSION = "0.0.3" FEATURES = "flutter" PRODUCT_NAME = "AppFlowy" #CRATE_TYPE: https://doc.rust-lang.org/reference/linkage.html -CRATE_TYPE = "staticlib" -SDK_EXT = "a" +CRATE_TYPE = "cdylib" +SDK_EXT = "dylib" APP_ENVIRONMENT = "local" FLUTTER_FLOWY_SDK_PATH="app_flowy/packages/flowy_sdk" PROTOBUF_DERIVE_CACHE="../shared-lib/flowy-derive/src/derive_cache/derive_cache.rs" @@ -124,7 +125,6 @@ script_runner = "@shell" [env.production-ios] BUILD_FLAG = "release" TARGET_OS = "ios" -CRATE_TYPE = "staticlib" FLUTTER_OUTPUT_DIR = "Release" PRODUCT_EXT = "ipa" @@ -153,7 +153,6 @@ script = [ ] script_runner = "@duckscript" - [tasks.test-build] condition = { env_set = [ "FLUTTER_FLOWY_SDK_PATH"] } script = [ diff --git a/frontend/app_flowy/.gitignore b/frontend/app_flowy/.gitignore index 8ec45dd95a..3421d1450b 100644 --- a/frontend/app_flowy/.gitignore +++ b/frontend/app_flowy/.gitignore @@ -59,4 +59,5 @@ windows/flutter/dart_ffi/ **/**/*.lib **/**/*.dll **/**/*.so -**/**/Brewfile.lock.json \ No newline at end of file +**/**/Brewfile.lock.json +**/.sandbox \ No newline at end of file diff --git a/frontend/app_flowy/.vscode/launch.json b/frontend/app_flowy/.vscode/launch.json index c7236062fd..7dae433cf9 100644 --- a/frontend/app_flowy/.vscode/launch.json +++ b/frontend/app_flowy/.vscode/launch.json @@ -11,7 +11,7 @@ "type": "dart", "preLaunchTask": "build_flowy_sdk", "env":{ - "RUST_LOG":"info", + "RUST_LOG":"debug" }, "cwd": "${workspaceRoot}" }, @@ -22,7 +22,7 @@ "type": "dart", "preLaunchTask": "build_flowy_sdk", "env":{ - "RUST_LOG":"trace", + "RUST_LOG":"trace" }, "cwd": "${workspaceRoot}" }, diff --git a/frontend/app_flowy/fonts/FlowyIconData.ttf b/frontend/app_flowy/assets/fonts/FlowyIconData.ttf similarity index 100% rename from frontend/app_flowy/fonts/FlowyIconData.ttf rename to frontend/app_flowy/assets/fonts/FlowyIconData.ttf diff --git a/frontend/app_flowy/lib/main.dart b/frontend/app_flowy/lib/main.dart index 3c17924567..8b1da85f75 100644 --- a/frontend/app_flowy/lib/main.dart +++ b/frontend/app_flowy/lib/main.dart @@ -14,5 +14,5 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); await EasyLocalization.ensureInitialized(); - System.run(FlowyApp()); + await FlowyRunner.run(FlowyApp()); } diff --git a/frontend/app_flowy/lib/startup/launcher.dart b/frontend/app_flowy/lib/startup/launcher.dart deleted file mode 100644 index 78c251c7cb..0000000000 --- a/frontend/app_flowy/lib/startup/launcher.dart +++ /dev/null @@ -1,40 +0,0 @@ -import 'package:app_flowy/startup/startup.dart'; -import 'package:get_it/get_it.dart'; - -class LaunchContext { - GetIt getIt; - IntegrationEnv env; - LaunchContext(this.getIt, this.env); -} - -enum LaunchTaskType { - dataProcessing, - appLauncher, -} - -/// The interface of an app launch task, which will trigger -/// some nonresident indispensable task in app launching task. -abstract class LaunchTask { - LaunchTaskType get type => LaunchTaskType.dataProcessing; - Future initialize(LaunchContext context); -} - -class AppLauncher { - List tasks; - IntegrationEnv env; - GetIt getIt; - - AppLauncher(this.env, this.getIt) : tasks = List.from([]); - - void addTask(LaunchTask task) { - tasks.add(task); - } - - void launch() async { - final context = LaunchContext(getIt, env); - for (var task in tasks) { - await task.initialize(context); - } - } -} -//test git hooks diff --git a/frontend/app_flowy/lib/startup/startup.dart b/frontend/app_flowy/lib/startup/startup.dart index 79717dbf52..283a751c75 100644 --- a/frontend/app_flowy/lib/startup/startup.dart +++ b/frontend/app_flowy/lib/startup/startup.dart @@ -1,13 +1,13 @@ -import 'package:app_flowy/startup/launcher.dart'; +import 'dart:io'; + import 'package:app_flowy/startup/tasks/prelude.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; import 'package:app_flowy/workspace/infrastructure/deps_resolver.dart'; import 'package:app_flowy/user/infrastructure/deps_resolver.dart'; import 'package:flowy_sdk/flowy_sdk.dart'; -import 'tasks/init_platform_service.dart'; - // [[diagram: flowy startup flow]] // ┌──────────┐ // │ FlowyApp │ @@ -26,44 +26,100 @@ import 'tasks/init_platform_service.dart'; // // 3.build MeterialApp final getIt = GetIt.instance; -enum IntegrationEnv { - dev, - pro, -} abstract class EntryPoint { Widget create(); } -class System { - static void run(EntryPoint f) { +class FlowyRunner { + static Future run(EntryPoint f) async { // Specify the env - const env = IntegrationEnv.dev; - - // Config the deps graph - getIt.registerFactory(() => f); - - resolveDependencies(env); + final env = integrationEnv(); + initGetIt(getIt, env, f); // add task getIt().addTask(InitRustSDKTask()); - getIt().addTask(AppWidgetTask()); - getIt().addTask(InitPlatformService()); + + if (!env.isTest()) { + getIt().addTask(InitAppWidgetTask()); + getIt().addTask(InitPlatformServiceTask()); + } // execute the tasks getIt().launch(); } } -void resolveDependencies(IntegrationEnv env) => initGetIt(getIt, env); - Future initGetIt( GetIt getIt, - IntegrationEnv env, + IntegrationMode env, + EntryPoint f, ) async { + getIt.registerFactory(() => f); getIt.registerLazySingleton(() => const FlowySDK()); getIt.registerLazySingleton(() => AppLauncher(env, getIt)); await UserDepsResolver.resolve(getIt); await HomeDepsResolver.resolve(getIt); } + +class LaunchContext { + GetIt getIt; + IntegrationMode env; + LaunchContext(this.getIt, this.env); +} + +enum LaunchTaskType { + dataProcessing, + appLauncher, +} + +/// The interface of an app launch task, which will trigger +/// some nonresident indispensable task in app launching task. +abstract class LaunchTask { + LaunchTaskType get type => LaunchTaskType.dataProcessing; + Future initialize(LaunchContext context); +} + +class AppLauncher { + List tasks; + IntegrationMode env; + GetIt getIt; + + AppLauncher(this.env, this.getIt) : tasks = List.from([]); + + void addTask(LaunchTask task) { + tasks.add(task); + } + + Future launch() async { + final context = LaunchContext(getIt, env); + for (var task in tasks) { + await task.initialize(context); + } + } +} + +enum IntegrationMode { + develop, + release, + test, +} + +extension IntegrationEnvExt on IntegrationMode { + bool isTest() { + return this == IntegrationMode.test; + } +} + +IntegrationMode integrationEnv() { + if (Platform.environment.containsKey('FLUTTER_TEST')) { + return IntegrationMode.test; + } + + if (kReleaseMode) { + return IntegrationMode.release; + } + + return IntegrationMode.develop; +} diff --git a/frontend/app_flowy/lib/startup/tasks/application_widget.dart b/frontend/app_flowy/lib/startup/tasks/app_widget.dart similarity index 96% rename from frontend/app_flowy/lib/startup/tasks/application_widget.dart rename to frontend/app_flowy/lib/startup/tasks/app_widget.dart index 92759ba079..a50e871795 100644 --- a/frontend/app_flowy/lib/startup/tasks/application_widget.dart +++ b/frontend/app_flowy/lib/startup/tasks/app_widget.dart @@ -7,11 +7,10 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:window_size/window_size.dart'; -import 'package:app_flowy/startup/launcher.dart'; import 'package:bloc/bloc.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; -class AppWidgetTask extends LaunchTask { +class InitAppWidgetTask extends LaunchTask { @override LaunchTaskType get type => LaunchTaskType.appLauncher; diff --git a/frontend/app_flowy/lib/startup/tasks/init_sdk.dart b/frontend/app_flowy/lib/startup/tasks/init_sdk.dart index 7a2a1e4ba9..6621ec9c69 100644 --- a/frontend/app_flowy/lib/startup/tasks/init_sdk.dart +++ b/frontend/app_flowy/lib/startup/tasks/init_sdk.dart @@ -1,9 +1,7 @@ import 'dart:io'; -import 'package:app_flowy/startup/launcher.dart'; import 'package:app_flowy/startup/startup.dart'; import 'package:path_provider/path_provider.dart'; import 'package:flowy_sdk/flowy_sdk.dart'; -import 'package:flutter/material.dart'; class InitRustSDKTask extends LaunchTask { @override @@ -11,23 +9,27 @@ class InitRustSDKTask extends LaunchTask { @override Future initialize(LaunchContext context) async { - WidgetsFlutterBinding.ensureInitialized(); - - Directory directory = await getApplicationDocumentsDirectory(); - final documentPath = directory.path; - - return Directory('$documentPath/flowy').create().then((Directory directory) async { - switch (context.env) { - case IntegrationEnv.dev: - // await context.getIt().init(Directory('./temp/flowy_dev')); - await context.getIt().init(directory); - break; - case IntegrationEnv.pro: - await context.getIt().init(directory); - break; - default: - assert(false, 'Unsupported env'); - } - }); + switch (context.env) { + case IntegrationMode.release: + Directory documentsDir = await getApplicationDocumentsDirectory(); + return Directory('${documentsDir.path}/flowy').create().then( + (Directory directory) async { + await context.getIt().init(directory); + }, + ); + case IntegrationMode.develop: + Directory documentsDir = await getApplicationDocumentsDirectory(); + return Directory('${documentsDir.path}/flowy_dev').create().then( + (Directory directory) async { + await context.getIt().init(directory); + }, + ); + case IntegrationMode.test: + final directory = Directory("${Directory.current.path}/.sandbox"); + await context.getIt().init(directory); + break; + default: + assert(false, 'Unsupported env'); + } } } diff --git a/frontend/app_flowy/lib/startup/tasks/init_platform_service.dart b/frontend/app_flowy/lib/startup/tasks/platform_service.dart similarity index 64% rename from frontend/app_flowy/lib/startup/tasks/init_platform_service.dart rename to frontend/app_flowy/lib/startup/tasks/platform_service.dart index 70653a365f..950ea3aaf7 100644 --- a/frontend/app_flowy/lib/startup/tasks/init_platform_service.dart +++ b/frontend/app_flowy/lib/startup/tasks/platform_service.dart @@ -1,14 +1,12 @@ -import 'package:app_flowy/startup/launcher.dart'; import 'package:app_flowy/user/infrastructure/network_monitor.dart'; - import '../startup.dart'; -class InitPlatformService extends LaunchTask { +class InitPlatformServiceTask extends LaunchTask { @override LaunchTaskType get type => LaunchTaskType.dataProcessing; @override Future initialize(LaunchContext context) async { - getIt().start(); + getIt().start(); } } diff --git a/frontend/app_flowy/lib/startup/tasks/prelude.dart b/frontend/app_flowy/lib/startup/tasks/prelude.dart index 288dc6c9dc..f1551595ad 100644 --- a/frontend/app_flowy/lib/startup/tasks/prelude.dart +++ b/frontend/app_flowy/lib/startup/tasks/prelude.dart @@ -1,2 +1,3 @@ -export 'application_widget.dart'; +export 'app_widget.dart'; export 'init_sdk.dart'; +export 'platform_service.dart'; diff --git a/frontend/app_flowy/lib/user/infrastructure/deps_resolver.dart b/frontend/app_flowy/lib/user/infrastructure/deps_resolver.dart index 1d3bedb833..9f6e6aadc6 100644 --- a/frontend/app_flowy/lib/user/infrastructure/deps_resolver.dart +++ b/frontend/app_flowy/lib/user/infrastructure/deps_resolver.dart @@ -24,6 +24,6 @@ class UserDepsResolver { getIt.registerFactory(() => HomeBloc()); getIt.registerFactory(() => EditPannelBloc()); getIt.registerFactory(() => SplashBloc()); - getIt.registerLazySingleton(() => NetworkMonitor()); + getIt.registerLazySingleton(() => NetworkListener()); } } diff --git a/frontend/app_flowy/lib/user/infrastructure/network_monitor.dart b/frontend/app_flowy/lib/user/infrastructure/network_monitor.dart index 779755a009..ba7806873d 100644 --- a/frontend/app_flowy/lib/user/infrastructure/network_monitor.dart +++ b/frontend/app_flowy/lib/user/infrastructure/network_monitor.dart @@ -1,16 +1,16 @@ import 'dart:async'; import 'package:connectivity_plus/connectivity_plus.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/flowy-net/network_state.pb.dart'; import 'package:flutter/services.dart'; -class NetworkMonitor { +class NetworkListener { final Connectivity _connectivity = Connectivity(); late StreamSubscription _connectivitySubscription; - NetworkMonitor() { + NetworkListener() { _connectivitySubscription = _connectivity.onConnectivityChanged.listen(_updateConnectionStatus); } diff --git a/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart b/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart index ffc88bc101..f86feb8226 100644 --- a/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart +++ b/frontend/app_flowy/lib/user/presentation/skip_log_in_screen.dart @@ -8,7 +8,7 @@ import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra/uuid.dart'; import 'package:flowy_infra_ui/widget/rounded_button.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; diff --git a/frontend/app_flowy/lib/user/presentation/splash_screen.dart b/frontend/app_flowy/lib/user/presentation/splash_screen.dart index aa66a58ffe..bbe04e4b18 100644 --- a/frontend/app_flowy/lib/user/presentation/splash_screen.dart +++ b/frontend/app_flowy/lib/user/presentation/splash_screen.dart @@ -2,7 +2,7 @@ import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/user/application/splash_bloc.dart'; import 'package:app_flowy/user/domain/auth_state.dart'; import 'package:app_flowy/user/infrastructure/router.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/errors.pb.dart'; import 'package:flutter/material.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart b/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart index 932308efdb..ce5415d407 100644 --- a/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/app/app_bloc.dart @@ -1,5 +1,5 @@ import 'package:app_flowy/workspace/infrastructure/repos/app_repo.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/appearance.dart b/frontend/app_flowy/lib/workspace/application/appearance.dart index 266ab1a5c5..80a6cab581 100644 --- a/frontend/app_flowy/lib/workspace/application/appearance.dart +++ b/frontend/app_flowy/lib/workspace/application/appearance.dart @@ -1,7 +1,7 @@ import 'package:app_flowy/user/infrastructure/repos/user_setting_repo.dart'; import 'package:equatable/equatable.dart'; import 'package:flowy_infra/theme.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_setting.pb.dart'; import 'package:flutter/material.dart'; import 'package:easy_localization/easy_localization.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart b/frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart index af8d366342..2801fc049f 100644 --- a/frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/doc/doc_bloc.dart @@ -6,7 +6,7 @@ import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flutter_quill/flutter_quill.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:dartz/dartz.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart index fb1e9dc7c9..a601e99721 100644 --- a/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/menu/menu_bloc.dart @@ -3,7 +3,7 @@ import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart'; import 'package:app_flowy/workspace/infrastructure/repos/workspace_repo.dart'; import 'package:app_flowy/workspace/presentation/stack_page/blank/blank_page.dart'; import 'package:dartz/dartz.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart b/frontend/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart index c2f73c62d8..e8c5dfb0b7 100644 --- a/frontend/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/menu/menu_user_bloc.dart @@ -1,5 +1,5 @@ import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-user-data-model/user_profile.pb.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart b/frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart index 49d86f71a9..0829484de0 100644 --- a/frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/trash/trash_bloc.dart @@ -1,6 +1,6 @@ import 'package:app_flowy/workspace/infrastructure/repos/trash_repo.dart'; import 'package:dartz/dartz.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/trash.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; diff --git a/frontend/app_flowy/lib/workspace/application/workspace/welcome_bloc.dart b/frontend/app_flowy/lib/workspace/application/workspace/welcome_bloc.dart index 3f6a770724..b613109f11 100644 --- a/frontend/app_flowy/lib/workspace/application/workspace/welcome_bloc.dart +++ b/frontend/app_flowy/lib/workspace/application/workspace/welcome_bloc.dart @@ -1,5 +1,5 @@ import 'package:app_flowy/workspace/infrastructure/repos/user_repo.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/workspace.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; import 'package:freezed_annotation/freezed_annotation.dart'; diff --git a/frontend/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart b/frontend/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart index fd36057678..81d1980215 100644 --- a/frontend/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart +++ b/frontend/app_flowy/lib/workspace/infrastructure/repos/app_repo.dart @@ -1,7 +1,7 @@ import 'dart:async'; import 'dart:typed_data'; import 'package:dartz/dartz.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/app.pb.dart'; diff --git a/frontend/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart b/frontend/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart index 8bba568fc3..7987e07c37 100644 --- a/frontend/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart +++ b/frontend/app_flowy/lib/workspace/infrastructure/repos/workspace_repo.dart @@ -3,7 +3,7 @@ import 'dart:typed_data'; import 'package:dartz/dartz.dart'; import 'package:easy_localization/easy_localization.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/dispatch/dispatch.dart'; import 'package:flowy_sdk/protobuf/dart-notify/subject.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile; diff --git a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart index bc81ac53f3..f46f6b8d80 100644 --- a/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart +++ b/frontend/app_flowy/lib/workspace/presentation/home/home_screen.dart @@ -5,7 +5,7 @@ import 'package:app_flowy/workspace/presentation/stack_page/home_stack.dart'; import 'package:app_flowy/workspace/presentation/widgets/float_bubble/question_bubble.dart'; import 'package:app_flowy/workspace/presentation/widgets/prelude.dart'; import 'package:app_flowy/startup/startup.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_infra_ui/style_widget/container.dart'; import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart' show UserProfile; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/protobuf.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/stack_page/doc/doc_stack_page.dart b/frontend/app_flowy/lib/workspace/presentation/stack_page/doc/doc_stack_page.dart index 3e0475c307..32ff4e6501 100644 --- a/frontend/app_flowy/lib/workspace/presentation/stack_page/doc/doc_stack_page.dart +++ b/frontend/app_flowy/lib/workspace/presentation/stack_page/doc/doc_stack_page.dart @@ -11,7 +11,7 @@ import 'package:flowy_infra/size.dart'; import 'package:flowy_infra/theme.dart'; import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/widget/rounded_button.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/share.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-folder-data-model/view.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-error/errors.pb.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/stack_page/home_stack.dart b/frontend/app_flowy/lib/workspace/presentation/stack_page/home_stack.dart index af20dcb88c..77f8a8c2b7 100644 --- a/frontend/app_flowy/lib/workspace/presentation/stack_page/home_stack.dart +++ b/frontend/app_flowy/lib/workspace/presentation/stack_page/home_stack.dart @@ -2,7 +2,7 @@ import 'package:app_flowy/startup/startup.dart'; import 'package:app_flowy/workspace/domain/page_stack/page_stack.dart'; import 'package:app_flowy/workspace/presentation/home/home_screen.dart'; import 'package:flowy_infra/theme.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:time/time.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/dialogs.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/dialogs.dart index 3141568272..3a5c1c79e5 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/dialogs.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/dialogs.dart @@ -7,7 +7,7 @@ import 'package:flowy_infra_ui/widget/buttons/secondary_button.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; -import 'package:app_flowy/startup/tasks/application_widget.dart'; +import 'package:app_flowy/startup/tasks/app_widget.dart'; import 'package:flowy_infra/size.dart'; import 'package:flowy_infra_ui/style_widget/text_input.dart'; import 'package:flowy_infra_ui/widget/dialog/styled_dialogs.dart'; diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart index 62e10be3b6..acedb7c1d6 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/float_bubble/question_bubble.dart @@ -5,7 +5,7 @@ import 'package:flowy_infra_ui/flowy_infra_ui.dart'; import 'package:flowy_infra_ui/style_widget/button.dart'; import 'package:flowy_infra_ui/style_widget/text.dart'; import 'package:flowy_infra_ui/widget/spacing.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:provider/provider.dart'; @@ -48,14 +48,14 @@ class QuestionBubble extends StatelessWidget { case BubbleAction.debug: final deviceInfoPlugin = DeviceInfoPlugin(); final deviceInfo = deviceInfoPlugin.deviceInfo; - + deviceInfo.then((info) { var debugText = ""; info.toMap().forEach((key, value) { debugText = debugText + "$key: $value\n"; }); - Clipboard.setData(ClipboardData( text: debugText )); + Clipboard.setData(ClipboardData(text: debugText)); Widget toast = Container( padding: const EdgeInsets.symmetric(horizontal: 24.0, vertical: 12.0), @@ -64,8 +64,8 @@ class QuestionBubble extends StatelessWidget { color: theme.main1, ), child: Row( - mainAxisSize: MainAxisSize.min, - children: [ + mainAxisSize: MainAxisSize.min, + children: [ const Icon(Icons.check), const SizedBox( width: 12.0, @@ -76,9 +76,9 @@ class QuestionBubble extends StatelessWidget { ); fToast.showToast( - child: toast, - gravity: ToastGravity.BOTTOM, - toastDuration: const Duration(seconds: 3), + child: toast, + gravity: ToastGravity.BOTTOM, + toastDuration: const Duration(seconds: 3), ); }).catchError((error) { Log.info("Debug info has not yet been implemented on this platform"); @@ -90,8 +90,8 @@ class QuestionBubble extends StatelessWidget { color: Colors.red, ), child: Row( - mainAxisSize: MainAxisSize.min, - children: [ + mainAxisSize: MainAxisSize.min, + children: [ const Icon(Icons.close), const SizedBox( width: 12.0, @@ -102,9 +102,9 @@ class QuestionBubble extends StatelessWidget { ); fToast.showToast( - child: toast, - gravity: ToastGravity.BOTTOM, - toastDuration: const Duration(seconds: 3), + child: toast, + gravity: ToastGravity.BOTTOM, + toastDuration: const Duration(seconds: 3), ); }, test: (e) => e is UnimplementedError); break; @@ -213,11 +213,7 @@ class FlowyVersionDescription extends StatelessWidget { } } -enum BubbleAction { - whatsNews, - help, - debug -} +enum BubbleAction { whatsNews, help, debug } class BubbleActionWrapper extends ActionItem { final BubbleAction inner; diff --git a/frontend/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/section.dart b/frontend/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/section.dart index 3b621fefec..455602e3f9 100644 --- a/frontend/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/section.dart +++ b/frontend/app_flowy/lib/workspace/presentation/widgets/menu/widget/app/section/section.dart @@ -34,7 +34,6 @@ class ViewSection extends StatelessWidget { Widget _renderSectionItems(BuildContext context, List views) { List viewWidgets = []; - if (views.isNotEmpty) { viewWidgets = views .map( diff --git a/frontend/app_flowy/packages/flowy_log/.gitignore b/frontend/app_flowy/packages/flowy_log/.gitignore deleted file mode 100644 index a247422ef7..0000000000 --- a/frontend/app_flowy/packages/flowy_log/.gitignore +++ /dev/null @@ -1,75 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ - -# IntelliJ related -*.iml -*.ipr -*.iws -.idea/ - -# The .vscode folder contains launch configuration and tasks you configure in -# VS Code which you may wish to be included in version control, so this line -# is commented out by default. -#.vscode/ - -# Flutter/Dart/Pub related -**/doc/api/ -.dart_tool/ -.flutter-plugins -.flutter-plugins-dependencies -.packages -.pub-cache/ -.pub/ -build/ - -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java - -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Flutter.podspec -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/ephemeral -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* - -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 diff --git a/frontend/app_flowy/packages/flowy_log/.metadata b/frontend/app_flowy/packages/flowy_log/.metadata deleted file mode 100644 index 84b25f93ab..0000000000 --- a/frontend/app_flowy/packages/flowy_log/.metadata +++ /dev/null @@ -1,10 +0,0 @@ -# This file tracks properties of this Flutter project. -# Used by Flutter tool to assess capabilities and perform upgrades etc. -# -# This file should be version controlled and should not be manually edited. - -version: - revision: cc00e7e6bc281f6af9a257e7e33868ef782b1cf7 - channel: dev - -project_type: package diff --git a/frontend/app_flowy/packages/flowy_log/LICENSE b/frontend/app_flowy/packages/flowy_log/LICENSE deleted file mode 100644 index ba75c69f7f..0000000000 --- a/frontend/app_flowy/packages/flowy_log/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/frontend/app_flowy/packages/flowy_log/analysis_options.yaml b/frontend/app_flowy/packages/flowy_log/analysis_options.yaml deleted file mode 100644 index a5744c1cfb..0000000000 --- a/frontend/app_flowy/packages/flowy_log/analysis_options.yaml +++ /dev/null @@ -1,4 +0,0 @@ -include: package:flutter_lints/flutter.yaml - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options diff --git a/frontend/app_flowy/packages/flowy_log/pubspec.lock b/frontend/app_flowy/packages/flowy_log/pubspec.lock deleted file mode 100644 index 7f75ad81b7..0000000000 --- a/frontend/app_flowy/packages/flowy_log/pubspec.lock +++ /dev/null @@ -1,168 +0,0 @@ -# Generated by pub -# See https://dart.dev/tools/pub/glossary#lockfile -packages: - async: - dependency: transitive - description: - name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.8.2" - boolean_selector: - dependency: transitive - description: - name: boolean_selector - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - characters: - dependency: transitive - description: - name: characters - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.1" - clock: - dependency: transitive - description: - name: clock - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - collection: - dependency: transitive - description: - name: collection - url: "https://pub.dartlang.org" - source: hosted - version: "1.15.0" - fake_async: - dependency: transitive - description: - name: fake_async - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - flutter: - dependency: "direct main" - description: flutter - source: sdk - version: "0.0.0" - flutter_lints: - dependency: "direct dev" - description: - name: flutter_lints - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.4" - flutter_test: - dependency: "direct dev" - description: flutter - source: sdk - version: "0.0.0" - lints: - dependency: transitive - description: - name: lints - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.1" - logger: - dependency: "direct main" - description: - name: logger - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - matcher: - dependency: transitive - description: - name: matcher - url: "https://pub.dartlang.org" - source: hosted - version: "0.12.11" - meta: - dependency: transitive - description: - name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.7.0" - path: - dependency: transitive - description: - name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.0" - sky_engine: - dependency: transitive - description: flutter - source: sdk - version: "0.0.99" - source_span: - dependency: transitive - description: - name: source_span - url: "https://pub.dartlang.org" - source: hosted - version: "1.8.1" - stack_trace: - dependency: transitive - description: - name: stack_trace - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" - stream_channel: - dependency: transitive - description: - name: stream_channel - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" - string_scanner: - dependency: transitive - description: - name: string_scanner - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.0" - term_glyph: - dependency: transitive - description: - name: term_glyph - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - test_api: - dependency: transitive - description: - name: test_api - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.3" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" - vector_math: - dependency: transitive - description: - name: vector_math - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.0" -sdks: - dart: ">=2.12.0 <3.0.0" - flutter: ">=1.17.0" diff --git a/frontend/app_flowy/packages/flowy_log/pubspec.yaml b/frontend/app_flowy/packages/flowy_log/pubspec.yaml deleted file mode 100644 index b8b9d51bb3..0000000000 --- a/frontend/app_flowy/packages/flowy_log/pubspec.yaml +++ /dev/null @@ -1,55 +0,0 @@ -name: flowy_log -description: A new Flutter package project. -version: 0.0.1 -homepage: - -environment: - sdk: ">=2.12.0 <3.0.0" - flutter: ">=1.17.0" - -dependencies: - flutter: - sdk: flutter - logger: ^1.0.0 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^1.0.0 - -# For information on the generic Dart part of this file, see the -# following page: https://dart.dev/tools/pub/pubspec - -# The following section is specific to Flutter. -flutter: - - # To add assets to your package, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg - # - # For details regarding assets in packages, see - # https://flutter.dev/assets-and-images/#from-packages - # - # An image asset can refer to one or more resolution-specific "variants", see - # https://flutter.dev/assets-and-images/#resolution-aware. - - # To add custom fonts to your package, add a fonts section here, - # in this "flutter" section. Each entry in this list should have a - # "family" key with the font family name, and a "fonts" key with a - # list giving the asset and other descriptors for the font. For - # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic - # - family: Trajan Pro - # fonts: - # - asset: fonts/TrajanPro.ttf - # - asset: fonts/TrajanPro_Bold.ttf - # weight: 700 - # - # For details regarding fonts in packages, see - # https://flutter.dev/custom-fonts/#from-packages diff --git a/frontend/app_flowy/packages/flowy_log/test/flowy_log_test.dart b/frontend/app_flowy/packages/flowy_log/test/flowy_log_test.dart deleted file mode 100644 index 8b13789179..0000000000 --- a/frontend/app_flowy/packages/flowy_log/test/flowy_log_test.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/frontend/app_flowy/packages/flowy_sdk/example/pubspec.lock b/frontend/app_flowy/packages/flowy_sdk/example/pubspec.lock index e3acc4bb72..921bd4fb2b 100644 --- a/frontend/app_flowy/packages/flowy_sdk/example/pubspec.lock +++ b/frontend/app_flowy/packages/flowy_sdk/example/pubspec.lock @@ -99,13 +99,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - flowy_log: - dependency: transitive - description: - path: "../../flowy_log" - relative: true - source: path - version: "0.0.1" flowy_sdk: dependency: "direct main" description: @@ -187,6 +180,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: @@ -207,7 +207,7 @@ packages: name: platform url: "https://pub.dartlang.org" source: hosted - version: "3.0.2" + version: "3.1.0" process: dependency: transitive description: @@ -275,7 +275,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.8" typed_data: dependency: transitive description: @@ -296,7 +296,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "7.3.0" + version: "7.5.0" webdriver: dependency: transitive description: diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart index a376f7d3b0..8c65b29b9b 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/dispatch/dispatch.dart @@ -1,6 +1,6 @@ import 'dart:ffi'; import 'package:dartz/dartz.dart'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; // ignore: unnecessary_import import 'package:flowy_sdk/protobuf/dart-ffi/ffi_response.pb.dart'; import 'package:flowy_sdk/protobuf/flowy-collaboration/document_info.pb.dart'; diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart b/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart index 71ea1b7286..798c33b318 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/ffi.dart @@ -12,11 +12,21 @@ final DynamicLibrary _dl = _open(); /// Reference to the Dynamic Library, it should be only used for low-level access final DynamicLibrary dl = _dl; DynamicLibrary _open() { - if (Platform.isAndroid) return DynamicLibrary.open('libdart_ffi.so'); - if (Platform.isMacOS) return DynamicLibrary.executable(); - if (Platform.isIOS) return DynamicLibrary.executable(); - if (Platform.isWindows) return DynamicLibrary.open('dart_ffi.dll'); - if (Platform.isLinux) return DynamicLibrary.open('libdart_ffi.so'); + if (Platform.environment.containsKey('FLUTTER_TEST')) { + final prefix = "${Directory.current.path}/.sandbox"; + if (Platform.isLinux) return DynamicLibrary.open('${prefix}/libdart_ffi.so'); + if (Platform.isAndroid) return DynamicLibrary.open('${prefix}/libdart_ffi.so'); + if (Platform.isMacOS) return DynamicLibrary.open('${prefix}/libdart_ffi.dylib'); + if (Platform.isIOS) return DynamicLibrary.open('${prefix}/libdart_ffi.dylib'); + if (Platform.isWindows) return DynamicLibrary.open('${prefix}/dart_ffi.dll'); + } else { + if (Platform.isLinux) return DynamicLibrary.open('libdart_ffi.so'); + if (Platform.isAndroid) return DynamicLibrary.open('libdart_ffi.so'); + if (Platform.isMacOS) return DynamicLibrary.executable(); + if (Platform.isIOS) return DynamicLibrary.executable(); + if (Platform.isWindows) return DynamicLibrary.open('dart_ffi.dll'); + } + throw UnsupportedError('This platform is not supported.'); } diff --git a/frontend/app_flowy/packages/flowy_log/lib/flowy_log.dart b/frontend/app_flowy/packages/flowy_sdk/lib/log.dart similarity index 84% rename from frontend/app_flowy/packages/flowy_log/lib/flowy_log.dart rename to frontend/app_flowy/packages/flowy_sdk/lib/log.dart index b842e8827a..a34faaff0e 100644 --- a/frontend/app_flowy/packages/flowy_log/lib/flowy_log.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/log.dart @@ -9,8 +9,7 @@ class Log { _logger = Logger( printer: PrettyPrinter( methodCount: 2, // number of method calls to be displayed - errorMethodCount: - 8, // number of method calls if stacktrace is provided + errorMethodCount: 8, // number of method calls if stacktrace is provided lineLength: 120, // width of the output colors: true, // Colorful log messages printEmojis: true, // Print an emoji for each log message @@ -27,6 +26,10 @@ class Log { Log.shared._logger.d(msg); } + static void warn(dynamic msg) { + Log.shared._logger.w(msg); + } + static void trace(dynamic msg) { Log.shared._logger.d(msg); } diff --git a/frontend/app_flowy/packages/flowy_sdk/lib/rust_stream.dart b/frontend/app_flowy/packages/flowy_sdk/lib/rust_stream.dart index 783a25ee8a..0aaa565e43 100644 --- a/frontend/app_flowy/packages/flowy_sdk/lib/rust_stream.dart +++ b/frontend/app_flowy/packages/flowy_sdk/lib/rust_stream.dart @@ -2,7 +2,7 @@ import 'dart:isolate'; import 'dart:async'; import 'dart:typed_data'; import 'dart:ffi'; -import 'package:flowy_log/flowy_log.dart'; +import 'package:flowy_sdk/log.dart'; import 'protobuf/dart-notify/subject.pb.dart'; typedef ObserverCallback = void Function(SubscribeObject observable); diff --git a/frontend/app_flowy/packages/flowy_sdk/macos/flowy_sdk.podspec b/frontend/app_flowy/packages/flowy_sdk/macos/flowy_sdk.podspec index 497388b99f..4dd9a055f9 100644 --- a/frontend/app_flowy/packages/flowy_sdk/macos/flowy_sdk.podspec +++ b/frontend/app_flowy/packages/flowy_sdk/macos/flowy_sdk.podspec @@ -20,6 +20,6 @@ A new flutter plugin project. s.platform = :osx, '10.11' s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } s.swift_version = '5.0' - s.static_framework = true - s.vendored_libraries = "libdart_ffi.a" + # s.static_framework = true + s.vendored_libraries = "libdart_ffi.dylib" end diff --git a/frontend/app_flowy/packages/flowy_sdk/pubspec.lock b/frontend/app_flowy/packages/flowy_sdk/pubspec.lock index 895c00a297..5ece223a66 100644 --- a/frontend/app_flowy/packages/flowy_sdk/pubspec.lock +++ b/frontend/app_flowy/packages/flowy_sdk/pubspec.lock @@ -197,13 +197,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - flowy_log: - dependency: "direct main" - description: - path: "../flowy_log" - relative: true - source: path - version: "0.0.1" flutter: dependency: "direct main" description: flutter @@ -292,7 +285,7 @@ packages: source: hosted version: "1.0.1" logger: - dependency: transitive + dependency: "direct main" description: name: logger url: "https://pub.dartlang.org" @@ -312,6 +305,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.12.11" + material_color_utilities: + dependency: transitive + description: + name: material_color_utilities + url: "https://pub.dartlang.org" + source: hosted + version: "0.1.3" meta: dependency: transitive description: @@ -442,7 +442,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.3" + version: "0.4.8" timing: dependency: transitive description: diff --git a/frontend/app_flowy/packages/flowy_sdk/pubspec.yaml b/frontend/app_flowy/packages/flowy_sdk/pubspec.yaml index ac93eb7331..f123a48729 100644 --- a/frontend/app_flowy/packages/flowy_sdk/pubspec.yaml +++ b/frontend/app_flowy/packages/flowy_sdk/pubspec.yaml @@ -2,7 +2,7 @@ name: flowy_sdk description: A new flutter plugin project. version: 0.0.1 homepage: -publish_to: 'none' +publish_to: "none" environment: sdk: ">=2.12.0-0 <3.0.0" @@ -14,16 +14,14 @@ dependencies: ffi: ^1.0.0 isolates: ^3.0.3+8 protobuf: "2.0.0" - dartz: '0.10.0-nullsafety.2' + dartz: "0.10.0-nullsafety.2" freezed_annotation: ^0.14.1 - flowy_log: - path: ../flowy_log - - + logger: ^1.0.0 + dev_dependencies: flutter_test: sdk: flutter - build_runner: '1.12.2' + build_runner: "1.12.2" flutter_lints: ^1.0.0 # For information on the generic Dart part of this file, see the diff --git a/frontend/app_flowy/pubspec.lock b/frontend/app_flowy/pubspec.lock index efa82e7604..f8d24d0552 100644 --- a/frontend/app_flowy/pubspec.lock +++ b/frontend/app_flowy/pubspec.lock @@ -43,6 +43,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "8.0.2" + bloc_test: + dependency: "direct dev" + description: + name: bloc_test + url: "https://pub.dartlang.org" + source: hosted + version: "9.0.2" boolean_selector: dependency: transitive description: @@ -211,6 +218,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.0.1" + coverage: + dependency: transitive + description: + name: coverage + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" cross_file: dependency: transitive description: @@ -393,13 +407,6 @@ packages: relative: true source: path version: "0.0.1" - flowy_log: - dependency: "direct main" - description: - path: "packages/flowy_log" - relative: true - source: path - version: "0.0.1" flowy_sdk: dependency: "direct main" description: @@ -709,6 +716,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.1" + mocktail: + dependency: transitive + description: + name: mocktail + url: "https://pub.dartlang.org" + source: hosted + version: "0.2.0" nested: dependency: transitive description: @@ -723,6 +737,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.2" + node_preamble: + dependency: transitive + description: + name: node_preamble + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" package_config: dependency: transitive description: @@ -989,6 +1010,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.0" + shelf_static: + dependency: transitive + description: + name: shelf_static + url: "https://pub.dartlang.org" + source: hosted + version: "1.1.0" shelf_web_socket: dependency: transitive description: @@ -1015,6 +1050,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.1" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" + source_maps: + dependency: transitive + description: + name: source_maps + url: "https://pub.dartlang.org" + source: hosted + version: "0.10.10" source_span: dependency: transitive description: @@ -1078,6 +1127,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.2.0" + test: + dependency: transitive + description: + name: test + url: "https://pub.dartlang.org" + source: hosted + version: "1.19.5" test_api: dependency: transitive description: @@ -1085,6 +1141,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.8" + test_core: + dependency: transitive + description: + name: test_core + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.9" textstyle_extensions: dependency: transitive description: @@ -1218,6 +1281,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.6" + vm_service: + dependency: transitive + description: + name: vm_service + url: "https://pub.dartlang.org" + source: hosted + version: "7.5.0" watcher: dependency: transitive description: @@ -1232,6 +1302,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.1.0" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0" win32: dependency: transitive description: diff --git a/frontend/app_flowy/pubspec.yaml b/frontend/app_flowy/pubspec.yaml index 206c60c5ba..31721eb5d1 100644 --- a/frontend/app_flowy/pubspec.yaml +++ b/frontend/app_flowy/pubspec.yaml @@ -37,8 +37,6 @@ dependencies: path: packages/flowy_infra_ui flowy_infra: path: packages/flowy_infra - flowy_log: - path: packages/flowy_log flutter_quill: git: url: https://github.com/appflowy/flutter-quill.git @@ -82,6 +80,7 @@ dev_dependencies: sdk: flutter build_runner: freezed: "^0.14.2" + bloc_test: ^9.0.2 # The "flutter_lints" package below contains a set of recommended lints to # encourage good coding practices. The lint set provided by the package is @@ -105,7 +104,7 @@ flutter: fonts: - family: FlowyIconData fonts: - - asset: fonts/FlowyIconData.ttf + - asset: assets/fonts/FlowyIconData.ttf # To add assets to your application, add an assets section, like this: assets: diff --git a/frontend/app_flowy/test/util/test_env.dart b/frontend/app_flowy/test/util/test_env.dart new file mode 100644 index 0000000000..e2dd3c8f7d --- /dev/null +++ b/frontend/app_flowy/test/util/test_env.dart @@ -0,0 +1,41 @@ +import 'package:app_flowy/startup/startup.dart'; +import 'package:app_flowy/user/infrastructure/repos/auth_repo.dart'; +import 'package:flowy_infra/uuid.dart'; +import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +class FlowyTest { + static Future setup() async { + TestWidgetsFlutterBinding.ensureInitialized(); + // await EasyLocalization.ensureInitialized(); + + await FlowyRunner.run(FlowyTestApp()); + return FlowyTest(); + } + + Future signIn() async { + final authRepo = getIt(); + const password = "AppFlowy123@"; + final uid = uuid(); + final userEmail = "$uid@appflowy.io"; + final result = await authRepo.signUp( + name: "FlowyTestUser", + password: password, + email: userEmail, + ); + return result.fold( + (user) => user, + (error) { + throw StateError("$error"); + }, + ); + } +} + +class FlowyTestApp implements EntryPoint { + @override + Widget create() { + return Container(); + } +} diff --git a/frontend/app_flowy/test/widget_test.dart b/frontend/app_flowy/test/widget_test.dart deleted file mode 100644 index 8b13789179..0000000000 --- a/frontend/app_flowy/test/widget_test.dart +++ /dev/null @@ -1 +0,0 @@ - diff --git a/frontend/app_flowy/test/workspace_bloc_test.dart b/frontend/app_flowy/test/workspace_bloc_test.dart new file mode 100644 index 0000000000..f4dba63a11 --- /dev/null +++ b/frontend/app_flowy/test/workspace_bloc_test.dart @@ -0,0 +1,29 @@ +import 'package:app_flowy/startup/startup.dart'; +import 'package:app_flowy/workspace/application/workspace/welcome_bloc.dart'; +import 'package:flowy_sdk/protobuf/flowy-user-data-model/protobuf.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:bloc_test/bloc_test.dart'; + +import 'util/test_env.dart'; + +void main() { + UserProfile? userInfo; + setUpAll(() async { + final flowyTest = await FlowyTest.setup(); + userInfo = await flowyTest.signIn(); + }); + + group('WelcomeBloc', () { + blocTest( + "welcome screen init", + build: () => getIt(param1: userInfo), + act: (bloc) { + bloc.add(const WelcomeEvent.initial()); + }, + wait: const Duration(seconds: 3), + verify: (bloc) { + assert(bloc.state.isLoading == false); + }, + ); + }); +} diff --git a/frontend/rust-lib/flowy-sdk/src/lib.rs b/frontend/rust-lib/flowy-sdk/src/lib.rs index f3582ad92b..779af9a53d 100644 --- a/frontend/rust-lib/flowy-sdk/src/lib.rs +++ b/frontend/rust-lib/flowy-sdk/src/lib.rs @@ -38,7 +38,6 @@ pub struct FlowySDKConfig { impl fmt::Debug for FlowySDKConfig { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("FlowySDKConfig") - .field("name", &self.name) .field("root", &self.root) .field("server_config", &self.server_config) .finish() diff --git a/frontend/scripts/makefile/desktop.toml b/frontend/scripts/makefile/desktop.toml index 3b4f8aed4e..458801ee26 100644 --- a/frontend/scripts/makefile/desktop.toml +++ b/frontend/scripts/makefile/desktop.toml @@ -16,17 +16,17 @@ linux_alias = "flowy-sdk-dev-linux" [tasks.flowy-sdk-dev-macos] category = "Build" dependencies = ["env_check"] -run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type"] } +run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type", "copy-to-sys-tmpdir"] } [tasks.flowy-sdk-dev-windows] category = "Build" dependencies = ["env_check"] -run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type"] } +run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type", "copy-to-sys-tmpdir"] } [tasks.flowy-sdk-dev-linux] category = "Build" dependencies = ["env_check"] -run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type"] } +run_task = { name = ["setup-crate-type","sdk-build", "post-desktop", "restore-crate-type", "copy-to-sys-tmpdir"] } # [tasks.sdk-build] @@ -82,27 +82,29 @@ private = true script = [ """ echo "🚀 🚀 🚀 Flowy-SDK(macOS) build success" + dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/${TARGET_OS} + lib = set lib${LIB_NAME}.${SDK_EXT} - cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/lib${CARGO_MAKE_CRATE_FS_NAME}.${SDK_EXT} \ - ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/${TARGET_OS}/lib${CARGO_MAKE_CRATE_FS_NAME}.${SDK_EXT} + cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \ + ${dart_ffi_dir}/${lib} cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \ - ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/packages/flowy_sdk/${TARGET_OS}/Classes/binding.h + ${dart_ffi_dir}/Classes/binding.h """, ] script_runner = "@duckscript" - [tasks.post-desktop-windows] private = true script = [ """ echo "🚀 🚀 🚀 Flowy-SDK(windows) build success" dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/windows/flutter/dart_ffi + lib = set ${LIB_NAME}.${SDK_EXT} # copy dll - cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${CARGO_MAKE_CRATE_FS_NAME}.${SDK_EXT} \ - ${dart_ffi_dir}/${CARGO_MAKE_CRATE_FS_NAME}.${SDK_EXT} + cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \ + ${dart_ffi_dir}/${lib} # copy binding.h cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \ @@ -117,10 +119,11 @@ script = [ """ echo "🚀 🚀 🚀 Flowy-SDK(linux) build success" dart_ffi_dir= set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/linux/flutter/dart_ffi + lib = set lib${LIB_NAME}.${SDK_EXT} # copy dll - cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/lib${CARGO_MAKE_CRATE_FS_NAME}.${SDK_EXT} \ - ${dart_ffi_dir}/lib${CARGO_MAKE_CRATE_FS_NAME}.${SDK_EXT} + cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \ + ${dart_ffi_dir}/${lib} # copy binding.h cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/${CARGO_MAKE_CRATE_NAME}/binding.h \ @@ -129,29 +132,25 @@ script = [ ] script_runner = "@duckscript" -# [tasks.copy-to-sys-tmpdir] private = true -condition = { profiles = [ "development-mac" ], platforms = ["mac"] } script = [ """ - # post the dylib target_path that use for flutter unit test - target_path = set ${TMPDIR}/appflowy/lib${CARGO_MAKE_CRATE_FS_NAME}.${SDK_EXT} - rm ${target_path} - cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/lib${CARGO_MAKE_CRATE_FS_NAME}.${SDK_EXT} ${target_path} + # Copy the flowy_sdk lib to system temp directory for flutter unit test. + lib = set lib${LIB_NAME}.${SDK_EXT} + dest = set ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/app_flowy/.sandbox/${lib} + rm ${dest} + cp ${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/rust-lib/target/${RUST_COMPILE_TARGET}/${BUILD_FLAG}/${lib} \ + ${dest} """, ] script_runner = "@duckscript" -[tasks.check_protoc_cmd] +[tasks.copy-to-sys-tmpdir.windows] +private = true script = [ """ - ret = which protoc - if is_empty ${ret} - echo Please make sure /bin/ is in PATH env var - echo See BUILD_ON_{LINUX|WINDOWS}.md for how to get protoc - exit -1 - end + # Doesn't work on windows """, ] -script_runner = "@duckscript" +script_runner = "@duckscript" \ No newline at end of file diff --git a/frontend/scripts/makefile/protobuf.toml b/frontend/scripts/makefile/protobuf.toml index 82084bd3e9..f507b7aba6 100644 --- a/frontend/scripts/makefile/protobuf.toml +++ b/frontend/scripts/makefile/protobuf.toml @@ -52,19 +52,6 @@ dart pub global activate protoc_plugin script_runner = "@shell" -[tasks.check_protoc_cmd] -script = [ - """ - ret = which protoc - if is_empty ${ret} - echo Please make sure /bin/ is in PATH env var - echo See BUILD_ON_{LINUX|WINDOWS}.md for how to get protoc - exit -1 - end - """, -] -script_runner = "@duckscript" - [tasks.gen_pb_file] script = [ """