refactor: Remove unused implementations
This commit is contained in:
parent
3aad6b617d
commit
54d70187e1
30
packages/moxplatform_generic/.gitignore
vendored
30
packages/moxplatform_generic/.gitignore
vendored
@ -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/
|
|
@ -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
|
|
@ -1,3 +0,0 @@
|
|||||||
## 0.0.1
|
|
||||||
|
|
||||||
* TODO: Describe initial release.
|
|
@ -1 +0,0 @@
|
|||||||
TODO: Add your license here.
|
|
@ -1,39 +0,0 @@
|
|||||||
<!--
|
|
||||||
This README describes the package. If you publish this package to pub.dev,
|
|
||||||
this README's contents appear on the landing page for your package.
|
|
||||||
|
|
||||||
For information about how to write a good package README, see the guide for
|
|
||||||
[writing package pages](https://dart.dev/guides/libraries/writing-package-pages).
|
|
||||||
|
|
||||||
For general information about developing packages, see the Dart guide for
|
|
||||||
[creating packages](https://dart.dev/guides/libraries/create-library-packages)
|
|
||||||
and the Flutter guide for
|
|
||||||
[developing packages and plugins](https://flutter.dev/developing-packages).
|
|
||||||
-->
|
|
||||||
|
|
||||||
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.
|
|
@ -1 +0,0 @@
|
|||||||
include: ../../analysis_options.yaml
|
|
@ -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<BackgroundCommand, BackgroundEvent> {
|
|
||||||
final SendPort _port;
|
|
||||||
BackgroundServiceDataSender(this._port) : super();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> sendDataImpl(DataWrapper data) async {
|
|
||||||
_port.send(jsonEncode(data.toJson()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> genericEntrypoint(List<dynamic> 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<BackgroundService>(srv);
|
|
||||||
srv.init(
|
|
||||||
entrypoint! as Future<void> Function(),
|
|
||||||
handleUIEvent! as Future<void> Function(Map<String, dynamic>? data)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class GenericIsolateHandler extends IsolateHandler {
|
|
||||||
final Logger _log;
|
|
||||||
ReceivePort? _isolateReceivePort;
|
|
||||||
SendPort? _isolateSendPort;
|
|
||||||
Isolate? _isolate;
|
|
||||||
BackgroundServiceDataSender? _dataSender;
|
|
||||||
|
|
||||||
GenericIsolateHandler()
|
|
||||||
: _log = Logger("GenericIsolateHandler"),
|
|
||||||
super();
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> attach(Future<void> Function(Map<String, dynamic>? 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<void> start(
|
|
||||||
Future<void> Function() entrypoint,
|
|
||||||
Future<void> Function(Map<String, dynamic>? data) handleUIEvent,
|
|
||||||
Future<void> Function(Map<String, dynamic>? data) handleIsolateEvent
|
|
||||||
) async {
|
|
||||||
_log.finest("Called start");
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
|
|
||||||
_isolateReceivePort = ReceivePort();
|
|
||||||
_dataSender = BackgroundServiceDataSender(_isolateReceivePort!.sendPort);
|
|
||||||
_isolate = await Isolate.spawn<List<dynamic>>(
|
|
||||||
genericEntrypoint,
|
|
||||||
[
|
|
||||||
_isolateReceivePort!.sendPort,
|
|
||||||
PluginUtilities.getCallbackHandle(entrypoint)!.toRawHandle(),
|
|
||||||
PluginUtilities.getCallbackHandle(handleUIEvent)!.toRawHandle()
|
|
||||||
]
|
|
||||||
);
|
|
||||||
|
|
||||||
attach(handleIsolateEvent);
|
|
||||||
|
|
||||||
_log.finest("Service successfully started");
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<bool> isRunning() async {
|
|
||||||
return _isolate != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
BackgroundServiceDataSender getDataSender() => _dataSender!;
|
|
||||||
}
|
|
@ -1,2 +0,0 @@
|
|||||||
export "package:moxplatform_generic/isolate_generic.dart";
|
|
||||||
export "package:moxplatform_generic/service_generic.dart";
|
|
@ -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<void> Function() entrypoint,
|
|
||||||
Future<void> Function(Map<String, dynamic>? 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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
30
packages/moxplatform_linux/.gitignore
vendored
30
packages/moxplatform_linux/.gitignore
vendored
@ -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/
|
|
@ -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
|
|
@ -1,3 +0,0 @@
|
|||||||
## 0.0.1
|
|
||||||
|
|
||||||
* TODO: Describe initial release.
|
|
@ -1 +0,0 @@
|
|||||||
TODO: Add your license here.
|
|
@ -1 +0,0 @@
|
|||||||
include: ../../analysis_options.yaml
|
|
@ -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<String> getPlatformName() async => "Linux";
|
|
||||||
}
|
|
@ -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
|
|
||||||
|
|
Reference in New Issue
Block a user