From 54d70187e1915244d857a0f0f78aae44d0045e68 Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Tue, 6 Sep 2022 14:09:02 +0200 Subject: [PATCH] refactor: Remove unused implementations --- packages/moxplatform_generic/.gitignore | 30 ----- packages/moxplatform_generic/.metadata | 10 -- packages/moxplatform_generic/CHANGELOG.md | 3 - packages/moxplatform_generic/LICENSE | 1 - packages/moxplatform_generic/README.md | 39 ------- .../moxplatform_generic/analysis_options.yaml | 1 - .../lib/isolate_generic.dart | 105 ------------------ .../lib/moxplatform_generic.dart | 2 - .../lib/service_generic.dart | 58 ---------- packages/moxplatform_generic/pubspec.yaml | 33 ------ packages/moxplatform_linux/.gitignore | 30 ----- packages/moxplatform_linux/.metadata | 10 -- packages/moxplatform_linux/CHANGELOG.md | 3 - packages/moxplatform_linux/LICENSE | 1 - .../moxplatform_linux/analysis_options.yaml | 1 - .../lib/moxplatform_linux.dart | 13 --- packages/moxplatform_linux/pubspec.yaml | 32 ------ 17 files changed, 372 deletions(-) delete mode 100644 packages/moxplatform_generic/.gitignore delete mode 100644 packages/moxplatform_generic/.metadata delete mode 100644 packages/moxplatform_generic/CHANGELOG.md delete mode 100644 packages/moxplatform_generic/LICENSE delete mode 100644 packages/moxplatform_generic/README.md delete mode 100644 packages/moxplatform_generic/analysis_options.yaml delete mode 100644 packages/moxplatform_generic/lib/isolate_generic.dart delete mode 100644 packages/moxplatform_generic/lib/moxplatform_generic.dart delete mode 100644 packages/moxplatform_generic/lib/service_generic.dart delete mode 100644 packages/moxplatform_generic/pubspec.yaml delete mode 100644 packages/moxplatform_linux/.gitignore delete mode 100644 packages/moxplatform_linux/.metadata delete mode 100644 packages/moxplatform_linux/CHANGELOG.md delete mode 100644 packages/moxplatform_linux/LICENSE delete mode 100644 packages/moxplatform_linux/analysis_options.yaml delete mode 100644 packages/moxplatform_linux/lib/moxplatform_linux.dart delete mode 100644 packages/moxplatform_linux/pubspec.yaml diff --git a/packages/moxplatform_generic/.gitignore b/packages/moxplatform_generic/.gitignore deleted file mode 100644 index 96486fd..0000000 --- a/packages/moxplatform_generic/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# 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 -# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. -/pubspec.lock -**/doc/api/ -.dart_tool/ -.packages -build/ diff --git a/packages/moxplatform_generic/.metadata b/packages/moxplatform_generic/.metadata deleted file mode 100644 index 71c027b..0000000 --- a/packages/moxplatform_generic/.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: 13a2fb10b838971ce211230f8ffdd094c14af02c - channel: beta - -project_type: package diff --git a/packages/moxplatform_generic/CHANGELOG.md b/packages/moxplatform_generic/CHANGELOG.md deleted file mode 100644 index 41cc7d8..0000000 --- a/packages/moxplatform_generic/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.0.1 - -* TODO: Describe initial release. diff --git a/packages/moxplatform_generic/LICENSE b/packages/moxplatform_generic/LICENSE deleted file mode 100644 index ba75c69..0000000 --- a/packages/moxplatform_generic/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/packages/moxplatform_generic/README.md b/packages/moxplatform_generic/README.md deleted file mode 100644 index 8b55e73..0000000 --- a/packages/moxplatform_generic/README.md +++ /dev/null @@ -1,39 +0,0 @@ - - -TODO: Put a short description of the package here that helps potential users -know whether this package might be useful for them. - -## Features - -TODO: List what your package can do. Maybe include images, gifs, or videos. - -## Getting started - -TODO: List prerequisites and provide or point to information on how to -start using the package. - -## Usage - -TODO: Include short and useful examples for package users. Add longer examples -to `/example` folder. - -```dart -const like = 'sample'; -``` - -## Additional information - -TODO: Tell users more about the package: where to find more information, how to -contribute to the package, how to file issues, what response they can expect -from the package authors, and more. diff --git a/packages/moxplatform_generic/analysis_options.yaml b/packages/moxplatform_generic/analysis_options.yaml deleted file mode 100644 index f04c6cf..0000000 --- a/packages/moxplatform_generic/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: ../../analysis_options.yaml diff --git a/packages/moxplatform_generic/lib/isolate_generic.dart b/packages/moxplatform_generic/lib/isolate_generic.dart deleted file mode 100644 index 8243984..0000000 --- a/packages/moxplatform_generic/lib/isolate_generic.dart +++ /dev/null @@ -1,105 +0,0 @@ -import "dart:convert"; -import "dart:ui"; -import "dart:isolate"; - -import "package:moxplatform_generic/service_generic.dart"; - -import "package:flutter/widgets.dart"; -import "package:logging/logging.dart"; -import "package:get_it/get_it.dart"; -import "package:moxplatform/types.dart"; -import "package:moxlib/awaitabledatasender.dart"; -import "package:moxplatform_platform_interface/src/isolate.dart"; -import "package:moxplatform_platform_interface/src/service.dart"; - -class BackgroundServiceDataSender extends AwaitableDataSender { - final SendPort _port; - BackgroundServiceDataSender(this._port) : super(); - - @override - Future sendDataImpl(DataWrapper data) async { - _port.send(jsonEncode(data.toJson())); - } -} - -Future genericEntrypoint(List parameters) async { - print("genericEntrypoint: Called on new Isolate"); - //WidgetsFlutterBinding.ensureInitialized(); - - SendPort port = parameters[0]; - final int entrypointHandle = parameters[1]; - final entrypointCallbackHandle = CallbackHandle.fromRawHandle(entrypointHandle); - final entrypoint = PluginUtilities.getCallbackFromHandle(entrypointCallbackHandle); - final int handleUIEventHandle = parameters[2]; - final handleUIEventCallbackHandle = CallbackHandle.fromRawHandle(handleUIEventHandle); - final handleUIEvent = PluginUtilities.getCallbackFromHandle(handleUIEventCallbackHandle); - - final srv = GenericBackgroundService(port); - GetIt.I.registerSingleton(srv); - srv.init( - entrypoint! as Future Function(), - handleUIEvent! as Future Function(Map? data) - ); -} - -class GenericIsolateHandler extends IsolateHandler { - final Logger _log; - ReceivePort? _isolateReceivePort; - SendPort? _isolateSendPort; - Isolate? _isolate; - BackgroundServiceDataSender? _dataSender; - - GenericIsolateHandler() - : _log = Logger("GenericIsolateHandler"), - super(); - - @override - Future attach(Future Function(Map? data) handleIsolateEvent) async { - if (_isolateReceivePort != null) { - _isolateReceivePort!.listen((data) async { - if (data is SendPort) { - _isolateSendPort = data; - _dataSender = BackgroundServiceDataSender(data); - return; - } - - await handleIsolateEvent(jsonDecode(data as String)); - }); - } else { - _log.severe("attach: _isolate is null"); - } - } - - @override - Future start( - Future Function() entrypoint, - Future Function(Map? data) handleUIEvent, - Future Function(Map? data) handleIsolateEvent - ) async { - _log.finest("Called start"); - WidgetsFlutterBinding.ensureInitialized(); - - _isolateReceivePort = ReceivePort(); - _dataSender = BackgroundServiceDataSender(_isolateReceivePort!.sendPort); - _isolate = await Isolate.spawn>( - genericEntrypoint, - [ - _isolateReceivePort!.sendPort, - PluginUtilities.getCallbackHandle(entrypoint)!.toRawHandle(), - PluginUtilities.getCallbackHandle(handleUIEvent)!.toRawHandle() - ] - ); - - attach(handleIsolateEvent); - - _log.finest("Service successfully started"); - } - - @override - Future isRunning() async { - return _isolate != null; - } - - @override - BackgroundServiceDataSender getDataSender() => _dataSender!; -} diff --git a/packages/moxplatform_generic/lib/moxplatform_generic.dart b/packages/moxplatform_generic/lib/moxplatform_generic.dart deleted file mode 100644 index daed53e..0000000 --- a/packages/moxplatform_generic/lib/moxplatform_generic.dart +++ /dev/null @@ -1,2 +0,0 @@ -export "package:moxplatform_generic/isolate_generic.dart"; -export "package:moxplatform_generic/service_generic.dart"; diff --git a/packages/moxplatform_generic/lib/service_generic.dart b/packages/moxplatform_generic/lib/service_generic.dart deleted file mode 100644 index 319225b..0000000 --- a/packages/moxplatform_generic/lib/service_generic.dart +++ /dev/null @@ -1,58 +0,0 @@ -import "dart:convert"; -import "dart:ui"; -import "dart:isolate"; - -import "package:moxplatform_platform_interface/src/service.dart"; -import "package:moxplatform/types.dart"; -import "package:moxlib/awaitabledatasender.dart"; -import "package:flutter/material.dart"; -import "package:logging/logging.dart"; -import "package:uuid/uuid.dart"; - -class GenericBackgroundService extends BackgroundService { - final Logger _log; - final SendPort _sender; - late final ReceivePort _receiver; - - GenericBackgroundService(this._sender) - : _log = Logger("GenericBackgroundService"), - super(); - - @override - void setNotification(String title, String body) {} - - @override - void sendEvent(BackgroundEvent event, { String? id }) { - final data = DataWrapper( - id ?? const Uuid().v4(), - event - ); - // NOTE: *S*erver to *F*oreground - _log.fine("S2F: ${data.toJson().toString()}"); - _sender.send(jsonEncode(data.toJson())); - } - - @override - void init( - Future Function() entrypoint, - Future Function(Map? data) handleEvent - ) { - //WidgetsFlutterBinding.ensureInitialized(); - - // Ensure that all native plugins are registered against this Isolate, so that - // we can use path_provider, notifications, ... - DartPluginRegistrant.ensureInitialized(); - - _receiver = ReceivePort(); - _sender.send(_receiver.sendPort); - - // Register the event handler - _receiver.listen((data) { - final arg = jsonDecode(data as String); - handleEvent(arg); - }); - - _log.finest("Running..."); - entrypoint(); - } -} diff --git a/packages/moxplatform_generic/pubspec.yaml b/packages/moxplatform_generic/pubspec.yaml deleted file mode 100644 index 135e2eb..0000000 --- a/packages/moxplatform_generic/pubspec.yaml +++ /dev/null @@ -1,33 +0,0 @@ -name: moxplatform_generic -description: Generic implementations of moxplatform -version: 0.1.11 -homepage: https://git.polynom.me/api/packages/Moxxy/pub - -environment: - sdk: ">=2.17.0-266.1.beta <3.0.0" - flutter: ">=1.17.0" - -dependencies: - flutter: - sdk: flutter - - moxplatform: - hosted: https://git.polynom.me/api/packages/Moxxy/pub - version: 0.1.11 - moxplatform_platform_interface: - hosted: https://git.polynom.me/api/packages/Moxxy/pub - version: 0.1.11 - - moxlib: - hosted: https://git.polynom.me/api/packages/Moxxy/pub - version: 0.1.4 - - logging: 1.0.2 - get_it: 7.2.0 - uuid: 3.0.5 - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - very_good_analysis: 2.4.0 diff --git a/packages/moxplatform_linux/.gitignore b/packages/moxplatform_linux/.gitignore deleted file mode 100644 index 96486fd..0000000 --- a/packages/moxplatform_linux/.gitignore +++ /dev/null @@ -1,30 +0,0 @@ -# Miscellaneous -*.class -*.log -*.pyc -*.swp -.DS_Store -.atom/ -.buildlog/ -.history -.svn/ -migrate_working_dir/ - -# 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 -# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. -/pubspec.lock -**/doc/api/ -.dart_tool/ -.packages -build/ diff --git a/packages/moxplatform_linux/.metadata b/packages/moxplatform_linux/.metadata deleted file mode 100644 index 71c027b..0000000 --- a/packages/moxplatform_linux/.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: 13a2fb10b838971ce211230f8ffdd094c14af02c - channel: beta - -project_type: package diff --git a/packages/moxplatform_linux/CHANGELOG.md b/packages/moxplatform_linux/CHANGELOG.md deleted file mode 100644 index 41cc7d8..0000000 --- a/packages/moxplatform_linux/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 0.0.1 - -* TODO: Describe initial release. diff --git a/packages/moxplatform_linux/LICENSE b/packages/moxplatform_linux/LICENSE deleted file mode 100644 index ba75c69..0000000 --- a/packages/moxplatform_linux/LICENSE +++ /dev/null @@ -1 +0,0 @@ -TODO: Add your license here. diff --git a/packages/moxplatform_linux/analysis_options.yaml b/packages/moxplatform_linux/analysis_options.yaml deleted file mode 100644 index f04c6cf..0000000 --- a/packages/moxplatform_linux/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: ../../analysis_options.yaml diff --git a/packages/moxplatform_linux/lib/moxplatform_linux.dart b/packages/moxplatform_linux/lib/moxplatform_linux.dart deleted file mode 100644 index 279a05d..0000000 --- a/packages/moxplatform_linux/lib/moxplatform_linux.dart +++ /dev/null @@ -1,13 +0,0 @@ -import "package:moxplatform_generic/isolate_generic.dart"; - -import "package:moxplatform_platform_interface/moxplatform_platform_interface.dart"; - -class MoxplatformLinuxPlugin extends MoxplatformInterface { - static void registerWith() { - print("MoxplatformLinuxPlugin: Registering implementation"); - MoxplatformInterface.handler = GenericIsolateHandler(); - } - - @override - Future getPlatformName() async => "Linux"; -} diff --git a/packages/moxplatform_linux/pubspec.yaml b/packages/moxplatform_linux/pubspec.yaml deleted file mode 100644 index 2067376..0000000 --- a/packages/moxplatform_linux/pubspec.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: moxplatform_linux -description: Linux-specific implementation of moxplatform -version: 0.1.11 -homepage: https://codeberg.org/moxxy/moxplatform - -environment: - sdk: ">=2.17.0-266.1.beta <3.0.0" - flutter: ">=1.17.0" - -dependencies: - flutter: - sdk: flutter - - moxplatform: - hosted: https://git.polynom.me/api/packages/Moxxy/pub - version: 0.1.11 - moxplatform_generic: - path: ../moxplatform_generic - -dev_dependencies: - flutter_test: - sdk: flutter - flutter_lints: ^2.0.0 - very_good_analysis: 2.4.0 - -flutter: - plugin: - implements: moxplatform - platforms: - linux: - dartPluginClass: MoxplatformLinuxPlugin -