diff --git a/.vscode/settings.json b/.vscode/settings.json index 4cb6ca1..c9f5533 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,15 +5,15 @@ "editor.suggest.snippetsPreventQuickSuggestions": false, "editor.suggestSelection": "first", "editor.tabCompletion": "onlySnippets", - "editor.wordBasedSuggestions": false, + "editor.wordBasedSuggestions": "off", "editor.selectionHighlight": false, "editor.defaultFormatter": "Dart-Code.dart-code", "editor.formatOnSave": true, "editor.formatOnType": true, "editor.formatOnPaste": true, "editor.codeActionsOnSave": { - "source.fixAll": true, - "source.organizeImports": true + "source.fixAll": "explicit", + "source.organizeImports": "explicit" }, "editor.quickSuggestions": { "comments": "on", @@ -21,7 +21,9 @@ "other": "on" }, "editor.links": true, - "editor.rulers": [80] + "editor.rulers": [ + 80 + ] }, "dart.lineLength": 80, "dart.doNotFormat": [ @@ -36,10 +38,8 @@ "**.pbjson.dart", "**/generated/**" ], - // Flutter Version Manager //"dart.flutterSdkPath": ".fvm/flutter_sdk", - // Remove .fvm files from search "search.exclude": { //"**/.fvm": true, @@ -47,7 +47,6 @@ "coverage": true, "build": true }, - // Remove from file watching "files.watcherExclude": { //"**/.fvm": true, @@ -55,7 +54,6 @@ "coverage": true, "build": true }, - // Causes the debug view to automatically appear when a breakpoint is hit. This // setting is global and not configurable per-language. "debug.openDebug": "openOnDebugBreak", @@ -83,4 +81,4 @@ ] } } */ -} +} \ No newline at end of file diff --git a/Makefile b/Makefile index 21c6fca..9c25ddd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: format get test publish deploy centrifugo-up centrifugo-down coverage analyze check pana generate +.PHONY: format get outdated test publish deploy centrifugo-up centrifugo-down coverage analyze check pana generate format: @echo "Formatting the code" @@ -8,6 +8,9 @@ format: get: @dart pub get +outdated: + @dart pub outdated --show-all --dev-dependencies --dependency-overrides --transitive --no-prereleases + test: get @dart test --debug --coverage=.coverage --platform chrome,vm diff --git a/analysis_options.yaml b/analysis_options.yaml index 907ca29..218404e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -76,7 +76,6 @@ linter: avoid_js_rounded_ints: true avoid_print: true avoid_renaming_method_parameters: true - avoid_returning_null_for_future: true avoid_returning_null_for_void: true avoid_single_cascade_in_expression_statements: true avoid_slow_async_io: true @@ -140,7 +139,6 @@ linter: # Pedantic 1.9.0 always_declare_return_types: true - always_require_non_null_named_parameters: true annotate_overrides: true avoid_empty_else: true avoid_init_to_null: true @@ -204,7 +202,6 @@ linter: prefer_mixin: true use_setters_to_change_properties: true avoid_setters_without_getters: true - avoid_returning_null: true avoid_returning_this: true type_annotate_public_apis: true avoid_types_on_closure_parameters: true diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig index 592ceee..ec97fc6 100644 --- a/example/ios/Flutter/Debug.xcconfig +++ b/example/ios/Flutter/Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig index 592ceee..c4855bf 100644 --- a/example/ios/Flutter/Release.xcconfig +++ b/example/ios/Flutter/Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/example/ios/Podfile b/example/ios/Podfile new file mode 100644 index 0000000..d97f17e --- /dev/null +++ b/example/ios/Podfile @@ -0,0 +1,44 @@ +# Uncomment this line to define a global platform for your project +# platform :ios, '12.0' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_ios_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_ios_build_settings(target) + end +end diff --git a/example/lib/src/common/constant/config.dart b/example/lib/src/common/constant/config.dart index 772fef8..972977d 100644 --- a/example/lib/src/common/constant/config.dart +++ b/example/lib/src/common/constant/config.dart @@ -52,10 +52,8 @@ enum EnvironmentFlavor { /// Production production('production'); - /// {@nodoc} const EnvironmentFlavor(this.value); - /// {@nodoc} factory EnvironmentFlavor.from(String? value) => switch (value?.trim().toLowerCase()) { 'local' || 'loc' || 'lcl' || 'l' => development, diff --git a/example/lib/src/common/controller/controller.dart b/example/lib/src/common/controller/controller.dart index 731fc37..1864cbc 100644 --- a/example/lib/src/common/controller/controller.dart +++ b/example/lib/src/common/controller/controller.dart @@ -26,14 +26,16 @@ abstract interface class IControllerObserver { void onDispose(IController controller); /// Called on any state change in the controller. - void onStateChanged(IController controller, Object prevState, Object nextState); + void onStateChanged( + IController controller, Object prevState, Object nextState); /// Called on any error in the controller. void onError(IController controller, Object error, StackTrace stackTrace); } -/// {@template controller} +/// {@macro controller} abstract base class Controller with ChangeNotifier implements IController { + /// {@macro controller} Controller() { runZonedGuarded( () => Controller.observer?.onCreate(this), @@ -44,6 +46,7 @@ abstract base class Controller with ChangeNotifier implements IController { /// Controller observer static IControllerObserver? observer; + /// Whether the controller is disposed. bool get isDisposed => _$isDisposed; bool _$isDisposed = false; diff --git a/example/lib/src/common/controller/sequential_controller_concurrency.dart b/example/lib/src/common/controller/sequential_controller_concurrency.dart index e03b9a3..25abf47 100644 --- a/example/lib/src/common/controller/sequential_controller_concurrency.dart +++ b/example/lib/src/common/controller/sequential_controller_concurrency.dart @@ -46,9 +46,7 @@ base mixin SequentialControllerConcurrency on Controller { ); } -/// {@nodoc} final class _ControllerEventQueue { - /// {@nodoc} _ControllerEventQueue(); final DoubleLinkedQueue<_SequentialTask> _queue = @@ -57,11 +55,9 @@ final class _ControllerEventQueue { bool _isClosed = false; /// Event queue length. - /// {@nodoc} int get length => _queue.length; /// Push it at the end of the queue. - /// {@nodoc} Future push(FutureOr Function() fn) { final task = _SequentialTask(fn); _queue.add(task); @@ -72,14 +68,12 @@ final class _ControllerEventQueue { /// Mark the queue as closed. /// The queue will be processed until it's empty. /// But all new and current events will be rejected with [WSClientClosed]. - /// {@nodoc} FutureOr close() async { _isClosed = true; await _processing; } /// Execute the queue. - /// {@nodoc} void _exec() => _processing ??= Future.doWhile(() async { final event = _queue.first; try { @@ -104,23 +98,17 @@ final class _ControllerEventQueue { }); } -/// {@nodoc} class _SequentialTask { - /// {@nodoc} _SequentialTask(FutureOr Function() fn) : _fn = fn, _completer = Completer(); - /// {@nodoc} final Completer _completer; - /// {@nodoc} final FutureOr Function() _fn; - /// {@nodoc} Future get future => _completer.future; - /// {@nodoc} FutureOr call() async { final result = await _fn(); if (!_completer.isCompleted) { @@ -129,7 +117,6 @@ class _SequentialTask { return result; } - /// {@nodoc} void reject(Object error, [StackTrace? stackTrace]) { if (_completer.isCompleted) return; _completer.completeError(error, stackTrace); diff --git a/example/lib/src/common/localization/localization.dart b/example/lib/src/common/localization/localization.dart index 1eada77..80600fc 100644 --- a/example/lib/src/common/localization/localization.dart +++ b/example/lib/src/common/localization/localization.dart @@ -31,7 +31,7 @@ final class Localization extends generated.GeneratedLocalization { /// Get language by code. static ({String name, String nativeName})? getLanguageByCode(String code) => switch (_isoLangs[code]) { - (:String name, :String nativeName) => ( + (String name, String nativeName) => ( name: name, nativeName: nativeName ), diff --git a/example/lib/src/common/widget/app.dart b/example/lib/src/common/widget/app.dart index ff27bb4..59046b9 100644 --- a/example/lib/src/common/widget/app.dart +++ b/example/lib/src/common/widget/app.dart @@ -41,7 +41,7 @@ class App extends StatelessWidget { builder: (context, child) => MediaQuery( data: MediaQuery.of(context).copyWith( /* textScaler: TextScaler.noScaling, */ - textScaleFactor: 1, + textScaler: const TextScaler.linear(1), ), child: WindowScope( /* title: Localization.of(context).title, */ diff --git a/example/lib/src/feature/authentication/controller/authentication_state.dart b/example/lib/src/feature/authentication/controller/authentication_state.dart index 225b314..4ffa238 100644 --- a/example/lib/src/feature/authentication/controller/authentication_state.dart +++ b/example/lib/src/feature/authentication/controller/authentication_state.dart @@ -25,10 +25,8 @@ sealed class AuthenticationState extends _$AuthenticationStateBase { } /// Idling state -/// {@nodoc} final class AuthenticationState$Idle extends AuthenticationState with _$AuthenticationState { - /// {@nodoc} const AuthenticationState$Idle( {required super.user, super.message = 'Idling', this.error}); @@ -37,10 +35,8 @@ final class AuthenticationState$Idle extends AuthenticationState } /// Processing -/// {@nodoc} final class AuthenticationState$Processing extends AuthenticationState with _$AuthenticationState { - /// {@nodoc} const AuthenticationState$Processing( {required super.user, super.message = 'Processing'}); @@ -48,17 +44,14 @@ final class AuthenticationState$Processing extends AuthenticationState String? get error => null; } -/// {@nodoc} base mixin _$AuthenticationState on AuthenticationState {} /// Pattern matching for [AuthenticationState]. typedef AuthenticationStateMatch = R Function( S state); -/// {@nodoc} @immutable abstract base class _$AuthenticationStateBase { - /// {@nodoc} const _$AuthenticationStateBase({required this.user, required this.message}); /// Data entity payload. diff --git a/example/lib/src/feature/chat/controller/chat_connection_state.dart b/example/lib/src/feature/chat/controller/chat_connection_state.dart index cac8687..16f6468 100644 --- a/example/lib/src/feature/chat/controller/chat_connection_state.dart +++ b/example/lib/src/feature/chat/controller/chat_connection_state.dart @@ -27,23 +27,17 @@ sealed class ChatConnectionState extends _$ChatConnectionStateBase { } /// Disconnected -/// {@nodoc} final class ChatConnectionState$Disconnected extends ChatConnectionState { - /// {@nodoc} const ChatConnectionState$Disconnected({super.message = 'Disconnected'}); } /// Connecting -/// {@nodoc} final class ChatConnectionState$Connecting extends ChatConnectionState { - /// {@nodoc} const ChatConnectionState$Connecting({super.message = 'Connecting'}); } /// Connected -/// {@nodoc} final class ChatConnectionState$Connected extends ChatConnectionState { - /// {@nodoc} const ChatConnectionState$Connected({super.message = 'Connected'}); } @@ -51,10 +45,8 @@ final class ChatConnectionState$Connected extends ChatConnectionState { typedef ChatConnectionStateMatch = R Function( S state); -/// {@nodoc} @immutable abstract base class _$ChatConnectionStateBase { - /// {@nodoc} const _$ChatConnectionStateBase({required this.message}); /// Message or state description. diff --git a/example/lib/src/feature/chat/controller/chat_messages_state.dart b/example/lib/src/feature/chat/controller/chat_messages_state.dart index 07649e3..93e9ce3 100644 --- a/example/lib/src/feature/chat/controller/chat_messages_state.dart +++ b/example/lib/src/feature/chat/controller/chat_messages_state.dart @@ -44,9 +44,7 @@ sealed class ChatMessagesState extends _$ChatMessagesStateBase { } /// Idling state -/// {@nodoc} final class ChatMessagesState$Idle extends ChatMessagesState { - /// {@nodoc} const ChatMessagesState$Idle({required super.data, super.message = 'Idling'}); @override @@ -61,9 +59,7 @@ final class ChatMessagesState$Idle extends ChatMessagesState { } /// Processing -/// {@nodoc} final class ChatMessagesState$Processing extends ChatMessagesState { - /// {@nodoc} const ChatMessagesState$Processing( {required super.data, super.message = 'Processing'}); @@ -79,9 +75,7 @@ final class ChatMessagesState$Processing extends ChatMessagesState { } /// Successful -/// {@nodoc} final class ChatMessagesState$Successful extends ChatMessagesState { - /// {@nodoc} const ChatMessagesState$Successful( {required super.data, super.message = 'Successful'}); @@ -97,9 +91,7 @@ final class ChatMessagesState$Successful extends ChatMessagesState { } /// Error -/// {@nodoc} final class ChatMessagesState$Error extends ChatMessagesState { - /// {@nodoc} const ChatMessagesState$Error( {required super.data, super.message = 'An error has occurred.'}); @@ -118,10 +110,8 @@ final class ChatMessagesState$Error extends ChatMessagesState { typedef ChatMessagesStateMatch = R Function( S state); -/// {@nodoc} @immutable abstract base class _$ChatMessagesStateBase { - /// {@nodoc} const _$ChatMessagesStateBase({required this.data, required this.message}); /// Data entity payload. diff --git a/example/macos/Flutter/Flutter-Debug.xcconfig b/example/macos/Flutter/Flutter-Debug.xcconfig index c2efd0b..4b81f9b 100644 --- a/example/macos/Flutter/Flutter-Debug.xcconfig +++ b/example/macos/Flutter/Flutter-Debug.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/example/macos/Flutter/Flutter-Release.xcconfig b/example/macos/Flutter/Flutter-Release.xcconfig index c2efd0b..5caa9d1 100644 --- a/example/macos/Flutter/Flutter-Release.xcconfig +++ b/example/macos/Flutter/Flutter-Release.xcconfig @@ -1 +1,2 @@ +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/example/macos/Podfile b/example/macos/Podfile new file mode 100644 index 0000000..c795730 --- /dev/null +++ b/example/macos/Podfile @@ -0,0 +1,43 @@ +platform :osx, '10.14' + +# CocoaPods analytics sends network stats synchronously affecting flutter build latency. +ENV['COCOAPODS_DISABLE_STATS'] = 'true' + +project 'Runner', { + 'Debug' => :debug, + 'Profile' => :release, + 'Release' => :release, +} + +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" + end + + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches + end + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" +end + +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + +target 'Runner' do + use_frameworks! + use_modular_headers! + + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) + target 'RunnerTests' do + inherit! :search_paths + end +end + +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) + end +end diff --git a/lib/src/client/disconnect_code.dart b/lib/src/client/disconnect_code.dart index f6e4ed3..ca6b097 100644 --- a/lib/src/client/disconnect_code.dart +++ b/lib/src/client/disconnect_code.dart @@ -11,7 +11,6 @@ import 'package:meta/meta.dart'; /// /// Client implementation can use codes <3000 for client-side /// specific disconnect reasons. -/// {@nodoc} @internal enum DisconnectCode { /// Disconnect called @@ -32,7 +31,6 @@ enum DisconnectCode { /// Unsubscribe error unsubscribeError(5, 'unsubscribe error'); - /// {@nodoc} const DisconnectCode(this.code, this.reason); /// Disconnect code. diff --git a/lib/src/client/spinify.dart b/lib/src/client/spinify.dart index 8db7a26..09b62be 100644 --- a/lib/src/client/spinify.dart +++ b/lib/src/client/spinify.dart @@ -81,10 +81,8 @@ final class Spinify extends SpinifyBase static SpinifyObserver? observer; } -/// {@nodoc} @internal abstract base class SpinifyBase implements ISpinify { - /// {@nodoc} SpinifyBase(SpinifyConfig config) : _config = config { _transport = SpinifyWSPBTransport( config: config, @@ -94,22 +92,18 @@ abstract base class SpinifyBase implements ISpinify { /// Internal transport responsible /// for sending, receiving, encoding and decoding data from the server. - /// {@nodoc} @nonVirtual late final ISpinifyTransport _transport; /// Spinify config. - /// {@nodoc} @nonVirtual final SpinifyConfig _config; /// Manager responsible for client-side subscriptions. - /// {@nodoc} late final ClientSubscriptionManager _clientSubscriptionManager = ClientSubscriptionManager(_transport); /// Manager responsible for client-side subscriptions. - /// {@nodoc} late final ServerSubscriptionManager _serverSubscriptionManager = ServerSubscriptionManager(_transport); @@ -124,7 +118,6 @@ abstract base class SpinifyBase implements ISpinify { /// Init spinify client, override this method to add custom logic. /// This method is called in constructor. - /// {@nodoc} @protected @mustCallSuper void _initSpinify() { @@ -134,7 +127,6 @@ abstract base class SpinifyBase implements ISpinify { /// Called when connection established. /// Right before [SpinifyState$Connected] state. - /// {@nodoc} @protected @mustCallSuper void _onConnected(SpinifyState$Connected state) { @@ -144,7 +136,6 @@ abstract base class SpinifyBase implements ISpinify { /// Called when connection lost. /// Right before [SpinifyState$Disconnected] state. - /// {@nodoc} @protected @mustCallSuper void _onDisconnected(SpinifyState$Disconnected state) { @@ -166,7 +157,6 @@ abstract base class SpinifyBase implements ISpinify { /// Mixin responsible for event receiving and distribution by controllers /// and streams to subscribers. -/// {@nodoc} base mixin SpinifyEventReceiverMixin on SpinifyBase, SpinifyStateMixin { @protected @nonVirtual @@ -216,7 +206,6 @@ base mixin SpinifyEventReceiverMixin on SpinifyBase, SpinifyStateMixin { } /// Router for all events. - /// {@nodoc} @protected @nonVirtual @pragma('vm:prefer-inline') @@ -290,11 +279,9 @@ base mixin SpinifyEventReceiverMixin on SpinifyBase, SpinifyStateMixin { } /// Mixin responsible for spinify states -/// {@nodoc} @internal base mixin SpinifyStateMixin on SpinifyBase, SpinifyErrorsMixin { /// Refresh timer. - /// {@nodoc} Timer? _refreshTimer; @override @@ -347,7 +334,6 @@ base mixin SpinifyStateMixin on SpinifyBase, SpinifyErrorsMixin { StreamController.broadcast(); /// Refresh connection token when ttl is expired. - /// {@nodoc} void _setRefreshTimer(DateTime? ttl) { _refreshTimer?.cancel(); _refreshTimer = null; @@ -359,7 +345,6 @@ base mixin SpinifyStateMixin on SpinifyBase, SpinifyErrorsMixin { } /// Refresh token for subscription. - /// {@nodoc} void _refreshToken() => Future(() async { try { _refreshTimer?.cancel(); @@ -391,7 +376,6 @@ base mixin SpinifyStateMixin on SpinifyBase, SpinifyErrorsMixin { } /// Mixin responsible for errors stream. -/// {@nodoc} @internal base mixin SpinifyErrorsMixin on SpinifyBase { @protected @@ -401,7 +385,6 @@ base mixin SpinifyErrorsMixin on SpinifyBase { } /// Mixin responsible for connection. -/// {@nodoc} @internal base mixin SpinifyConnectionMixin on SpinifyBase, SpinifyErrorsMixin, SpinifyStateMixin { @@ -497,7 +480,6 @@ base mixin SpinifyConnectionMixin } /// Mixin responsible for sending asynchronous messages. -/// {@nodoc} @internal base mixin SpinifySendMixin on SpinifyBase, SpinifyErrorsMixin { @override @@ -517,7 +499,6 @@ base mixin SpinifySendMixin on SpinifyBase, SpinifyErrorsMixin { } /// Mixin responsible for client-side subscriptions. -/// {@nodoc} @internal base mixin SpinifyClientSubscriptionMixin on SpinifyBase, SpinifyErrorsMixin { @override @@ -580,7 +561,6 @@ base mixin SpinifyClientSubscriptionMixin on SpinifyBase, SpinifyErrorsMixin { } /// Mixin responsible for server-side subscriptions. -/// {@nodoc} @internal base mixin SpinifyServerSubscriptionMixin on SpinifyBase { @override @@ -603,7 +583,6 @@ base mixin SpinifyServerSubscriptionMixin on SpinifyBase { } /// Mixin responsible for publications. -/// {@nodoc} @internal base mixin SpinifyPublicationsMixin on SpinifyBase, SpinifyErrorsMixin, SpinifyClientSubscriptionMixin { @@ -627,7 +606,6 @@ base mixin SpinifyPublicationsMixin } /// Mixin responsible for presence. -/// {@nodoc} base mixin SpinifyPresenceMixin on SpinifyBase, SpinifyErrorsMixin { @override Future presence(String channel) async { @@ -667,7 +645,6 @@ base mixin SpinifyPresenceMixin on SpinifyBase, SpinifyErrorsMixin { } /// Mixin responsible for history. -/// {@nodoc} base mixin SpinifyHistoryMixin on SpinifyBase, SpinifyErrorsMixin { @override Future history( @@ -699,7 +676,6 @@ base mixin SpinifyHistoryMixin on SpinifyBase, SpinifyErrorsMixin { } /// Mixin responsible for history. -/// {@nodoc} base mixin SpinifyRPCMixin on SpinifyBase, SpinifyErrorsMixin { @override Future> rpc(String method, List data) async { @@ -721,7 +697,6 @@ base mixin SpinifyRPCMixin on SpinifyBase, SpinifyErrorsMixin { } /// Responsible for metrics. -/// {@nodoc} @internal base mixin SpinifyMetricsMixin on SpinifyBase, SpinifyStateMixin { int _connectsTotal = 0, _connectsSuccessful = 0, _disconnects = 0; @@ -786,10 +761,8 @@ base mixin SpinifyMetricsMixin on SpinifyBase, SpinifyStateMixin { /// Mixin responsible for queue. /// SHOULD BE LAST MIXIN. -/// {@nodoc} @internal base mixin SpinifyQueueMixin on SpinifyBase { - /// {@nodoc} final SpinifyEventQueue _eventQueue = SpinifyEventQueue(); @override diff --git a/lib/src/client/state.dart b/lib/src/client/state.dart index f209fbf..2dea951 100644 --- a/lib/src/client/state.dart +++ b/lib/src/client/state.dart @@ -416,10 +416,8 @@ final class SpinifyState$Closed extends SpinifyState { /// {@category Entity} typedef SpinifyStateMatch = R Function(S state); -/// {@nodoc} @immutable abstract base class _$SpinifyStateBase { - /// {@nodoc} const _$SpinifyStateBase(this.timestamp); /// Represents the current state type. diff --git a/lib/src/model/channel_push.dart b/lib/src/model/channel_push.dart index 29e8208..5fb7f44 100644 --- a/lib/src/model/channel_push.dart +++ b/lib/src/model/channel_push.dart @@ -8,7 +8,7 @@ import 'package:spinify/src/model/event.dart'; /// {@subCategory Push} @immutable abstract base class SpinifyChannelPush extends SpinifyEvent { - /// {@template spinify_channel_push} + /// {@macro spinify_channel_push} const SpinifyChannelPush({ required super.timestamp, required this.channel, diff --git a/lib/src/model/event.dart b/lib/src/model/event.dart index 08fca41..837e025 100644 --- a/lib/src/model/event.dart +++ b/lib/src/model/event.dart @@ -6,7 +6,7 @@ import 'package:meta/meta.dart'; /// {@category Event} @immutable abstract base class SpinifyEvent implements Comparable { - /// {@template spinify_event} + /// {@macro spinify_event} const SpinifyEvent({ required this.timestamp, }); diff --git a/lib/src/model/jwt.dart b/lib/src/model/jwt.dart index f772efd..0787190 100644 --- a/lib/src/model/jwt.dart +++ b/lib/src/model/jwt.dart @@ -47,7 +47,6 @@ sealed class SpinifyJWT { factory SpinifyJWT.decode(String jwt, [String? secret]) = _SpinifyJWTImpl.decode; - /// {@nodoc} const SpinifyJWT._(); /// This is a standard JWT claim which must contain @@ -398,9 +397,7 @@ final class _SpinifyJWTImpl extends SpinifyJWT { /// A converter that converts Base64-encoded strings /// to unpadded Base64-encoded strings. -/// {@nodoc} class _UnpaddedBase64Converter extends Converter { - /// {@nodoc} const _UnpaddedBase64Converter(); @override diff --git a/lib/src/model/refresh_result.dart b/lib/src/model/refresh_result.dart index bff42dd..f66b0eb 100644 --- a/lib/src/model/refresh_result.dart +++ b/lib/src/model/refresh_result.dart @@ -1,10 +1,8 @@ import 'package:meta/meta.dart'; -/// {@nodoc} @internal @immutable final class SpinifyRefreshResult { - /// {@nodoc} const SpinifyRefreshResult({ required this.expires, this.client, @@ -25,11 +23,9 @@ final class SpinifyRefreshResult { final DateTime? ttl; } -/// {@nodoc} @internal @immutable final class SpinifySubRefreshResult { - /// {@nodoc} const SpinifySubRefreshResult({ required this.expires, this.ttl, diff --git a/lib/src/subscription/client_subscription_impl.dart b/lib/src/subscription/client_subscription_impl.dart index 640c720..3ad363b 100644 --- a/lib/src/subscription/client_subscription_impl.dart +++ b/lib/src/subscription/client_subscription_impl.dart @@ -29,7 +29,6 @@ import 'package:spinify/src/util/event_queue.dart'; import 'package:spinify/src/util/logger.dart' as logger; /// Client-side subscription implementation. -/// {@nodoc} @internal final class SpinifyClientSubscriptionImpl extends SpinifyClientSubscriptionBase with @@ -40,7 +39,6 @@ final class SpinifyClientSubscriptionImpl extends SpinifyClientSubscriptionBase SpinifyClientSubscriptionHistoryMixin, SpinifyClientSubscriptionPresenceMixin, SpinifyClientSubscriptionQueueMixin { - /// {@nodoc} SpinifyClientSubscriptionImpl({ required super.channel, required super.transportWeakRef, @@ -48,11 +46,9 @@ final class SpinifyClientSubscriptionImpl extends SpinifyClientSubscriptionBase }) : super(config: config ?? const SpinifySubscriptionConfig.byDefault()); } -/// {@nodoc} @internal abstract base class SpinifyClientSubscriptionBase extends SpinifyClientSubscription { - /// {@nodoc} SpinifyClientSubscriptionBase({ required this.channel, required WeakReference transportWeakRef, @@ -75,21 +71,17 @@ abstract base class SpinifyClientSubscriptionBase }; /// Weak reference to transport. - /// {@nodoc} @nonVirtual late final WeakReference _transportWeakRef; /// Internal transport responsible /// for sending, receiving, encoding and decoding data from the server. - /// {@nodoc} ISpinifyTransport get _transport => _transportWeakRef.target!; /// Subscription config. - /// {@nodoc} final SpinifySubscriptionConfig _config; /// Init subscription. - /// {@nodoc} @protected @mustCallSuper void _initSubscription() { @@ -102,24 +94,20 @@ abstract base class SpinifyClientSubscriptionBase /// - `unsubscribed` /// - `subscribing` /// - `subscribed` - /// {@nodoc} @override SpinifySubscriptionState get state => _state; late SpinifySubscriptionState _state; /// Stream of subscription states. - /// {@nodoc} @override late final SpinifySubscriptionStateStream states = SpinifySubscriptionStateStream(_stateController.stream); /// States controller. - /// {@nodoc} final StreamController _stateController = StreamController.broadcast(); /// Set new state. - /// {@nodoc} void _setState(SpinifySubscriptionState state) { if (_state == state) return; final previousState = _state; @@ -128,14 +116,12 @@ abstract base class SpinifyClientSubscriptionBase } /// Notify about new publication. - /// {@nodoc} @nonVirtual void _handlePublication(SpinifyPublication publication) { final offset = publication.offset; if (offset != null && offset > _offset) _offset = offset; } - /// {@nodoc} @internal @mustCallSuper Future close([int code = 0, String reason = 'closed']) async { @@ -156,7 +142,6 @@ abstract base class SpinifyClientSubscriptionBase /// Mixin responsible for event receiving and distribution by controllers /// and streams to subscribers. -/// {@nodoc} base mixin SpinifyClientSubscriptionEventReceiverMixin on SpinifyClientSubscriptionBase { @protected @@ -207,7 +192,6 @@ base mixin SpinifyClientSubscriptionEventReceiverMixin /// Handle push event from server for the specific channel. /// Called from `SpinifyClientSubscriptionsManager.onPush` - /// {@nodoc} @internal @nonVirtual void onPush(SpinifyChannelPush push) { @@ -255,7 +239,6 @@ base mixin SpinifyClientSubscriptionEventReceiverMixin } /// Mixin responsible for errors stream. -/// {@nodoc} @internal base mixin SpinifyClientSubscriptionErrorsMixin on SpinifyClientSubscriptionBase { @@ -266,16 +249,13 @@ base mixin SpinifyClientSubscriptionErrorsMixin } /// Mixin responsible for subscribing. -/// {@nodoc} @internal base mixin SpinifyClientSubscriptionSubscribeMixin on SpinifyClientSubscriptionBase, SpinifyClientSubscriptionErrorsMixin { /// Refresh timer. - /// {@nodoc} Timer? _refreshTimer; /// Start subscribing to a channel - /// {@nodoc} @override Future subscribe() async { logger.fine('Subscribing to $channel'); @@ -330,7 +310,6 @@ base mixin SpinifyClientSubscriptionSubscribeMixin } /// Await for subscription to be ready. - /// {@nodoc} @override FutureOr ready() async { try { @@ -374,7 +353,6 @@ base mixin SpinifyClientSubscriptionSubscribeMixin } /// Unsubscribe from a channel - /// {@nodoc} @override Future unsubscribe( [int code = 0, String reason = 'unsubscribe called']) async { @@ -408,7 +386,6 @@ base mixin SpinifyClientSubscriptionSubscribeMixin } /// Refresh subscription when ttl is expired. - /// {@nodoc} void _setRefreshTimer(DateTime? ttl) { _refreshTimer?.cancel(); _refreshTimer = null; @@ -420,7 +397,6 @@ base mixin SpinifyClientSubscriptionSubscribeMixin } /// Refresh token for subscription. - /// {@nodoc} void _refreshToken() => Future(() async { logger.fine('Refreshing subscription token for $channel'); try { @@ -466,7 +442,6 @@ base mixin SpinifyClientSubscriptionSubscribeMixin } /// Mixin responsible for publishing. -/// {@nodoc} @internal base mixin SpinifyClientSubscriptionPublishingMixin on SpinifyClientSubscriptionBase, SpinifyClientSubscriptionErrorsMixin { @@ -487,7 +462,6 @@ base mixin SpinifyClientSubscriptionPublishingMixin } /// Mixin responsible for history. -/// {@nodoc} @internal base mixin SpinifyClientSubscriptionHistoryMixin on SpinifyClientSubscriptionBase, SpinifyClientSubscriptionErrorsMixin { @@ -518,7 +492,6 @@ base mixin SpinifyClientSubscriptionHistoryMixin } /// Mixin responsible for presence. -/// {@nodoc} @internal base mixin SpinifyClientSubscriptionPresenceMixin on SpinifyClientSubscriptionBase, SpinifyClientSubscriptionErrorsMixin { @@ -557,11 +530,9 @@ base mixin SpinifyClientSubscriptionPresenceMixin /// Mixin responsible for queue. /// SHOULD BE LAST MIXIN. -/// {@nodoc} @internal base mixin SpinifyClientSubscriptionQueueMixin on SpinifyClientSubscriptionBase { - /// {@nodoc} final SpinifyEventQueue _eventQueue = SpinifyEventQueue(); @override diff --git a/lib/src/subscription/client_subscription_manager.dart b/lib/src/subscription/client_subscription_manager.dart index e809316..702ff1f 100644 --- a/lib/src/subscription/client_subscription_manager.dart +++ b/lib/src/subscription/client_subscription_manager.dart @@ -10,15 +10,12 @@ import 'package:spinify/src/subscription/subscription_state.dart'; import 'package:spinify/src/transport/transport_interface.dart'; /// Responsible for managing client-side subscriptions. -/// {@nodoc} @internal final class ClientSubscriptionManager { - /// {@nodoc} ClientSubscriptionManager(ISpinifyTransport transport) : _transportWeakRef = WeakReference(transport); /// Spinify client weak reference. - /// {@nodoc} final WeakReference _transportWeakRef; /// Subscriptions count. @@ -45,7 +42,6 @@ final class ClientSubscriptionManager { /// Subscriptions registry (channel -> subscription). /// Channel : SpinifyClientSubscription - /// {@nodoc} final Map _channelSubscriptions = {}; @@ -53,7 +49,6 @@ final class ClientSubscriptionManager { /// `newSubscription(channel, config)` allocates a new Subscription /// in the registry or throws an exception if the Subscription /// is already there. We will discuss common Subscription options below. - /// {@nodoc} SpinifyClientSubscription newSubscription( String channel, SpinifySubscriptionConfig? config, @@ -76,7 +71,6 @@ final class ClientSubscriptionManager { /// Returns all registered subscriptions, /// so you can iterate over all and do some action if required /// (for example, you want to unsubscribe/remove all subscriptions). - /// {@nodoc} Map get subscriptions => UnmodifiableMapView({ for (final entry in _channelSubscriptions.entries) @@ -85,7 +79,6 @@ final class ClientSubscriptionManager { /// Remove the [SpinifyClientSubscription] from internal registry /// and unsubscribe from [SpinifyClientSubscription.channel]. - /// {@nodoc} Future removeSubscription( SpinifyClientSubscription subscription, ) async { @@ -113,7 +106,6 @@ final class ClientSubscriptionManager { } /// Establish all subscriptions for the specific client. - /// {@nodoc} void subscribeAll() { for (final entry in _channelSubscriptions.values) { entry.subscribe().ignore(); @@ -122,7 +114,6 @@ final class ClientSubscriptionManager { /// Disconnect all subscriptions for the specific client /// from internal registry. - /// {@nodoc} void unsubscribeAll([ int code = 0, String reason = 'connection closed', @@ -133,7 +124,6 @@ final class ClientSubscriptionManager { } /// Remove all subscriptions for the specific client from internal registry. - /// {@nodoc} void close([ int code = 0, String reason = 'client closed', @@ -145,7 +135,6 @@ final class ClientSubscriptionManager { } /// Handle push event from server for the specific channel. - /// {@nodoc} @internal void onPush(SpinifyChannelPush push) => _channelSubscriptions[push.channel]?.onPush(push); @@ -155,7 +144,6 @@ final class ClientSubscriptionManager { /// /// You need to call [SpinifyClientSubscription.subscribe] /// to start receiving events - /// {@nodoc} SpinifyClientSubscription? operator [](String channel) => _channelSubscriptions[channel]; } diff --git a/lib/src/subscription/server_subscription_impl.dart b/lib/src/subscription/server_subscription_impl.dart index 555098e..0cb6b3c 100644 --- a/lib/src/subscription/server_subscription_impl.dart +++ b/lib/src/subscription/server_subscription_impl.dart @@ -27,7 +27,6 @@ import 'package:spinify/src/util/event_queue.dart'; import 'package:spinify/src/util/logger.dart' as logger; /// Server-side subscription implementation. -/// {@nodoc} @internal final class SpinifyServerSubscriptionImpl extends SpinifyServerSubscriptionBase with @@ -38,18 +37,15 @@ final class SpinifyServerSubscriptionImpl extends SpinifyServerSubscriptionBase SpinifyServerSubscriptionHistoryMixin, SpinifyServerSubscriptionPresenceMixin, SpinifyServerSubscriptionQueueMixin { - /// {@nodoc} SpinifyServerSubscriptionImpl({ required super.channel, required super.transportWeakRef, }); } -/// {@nodoc} @internal abstract base class SpinifyServerSubscriptionBase extends SpinifyServerSubscription { - /// {@nodoc} SpinifyServerSubscriptionBase({ required this.channel, required WeakReference transportWeakRef, @@ -71,17 +67,14 @@ abstract base class SpinifyServerSubscriptionBase fixnum.Int64 _offset = fixnum.Int64.ZERO; /// Weak reference to transport. - /// {@nodoc} @nonVirtual late final WeakReference _transportWeakRef; /// Internal transport responsible /// for sending, receiving, encoding and decoding data from the server. - /// {@nodoc} ISpinifyTransport get _transport => _transportWeakRef.target!; /// Init subscription. - /// {@nodoc} @protected @mustCallSuper void _initSubscription() { @@ -93,24 +86,20 @@ abstract base class SpinifyServerSubscriptionBase /// - `unsubscribed` /// - `subscribing` /// - `subscribed` - /// {@nodoc} @override SpinifySubscriptionState get state => _state; late SpinifySubscriptionState _state; /// Stream of subscription states. - /// {@nodoc} @override late final SpinifySubscriptionStateStream states = SpinifySubscriptionStateStream(_stateController.stream); /// States controller. - /// {@nodoc} final StreamController _stateController = StreamController.broadcast(); /// Set new state. - /// {@nodoc} void _setState(SpinifySubscriptionState state) { if (_state == state) return; final previousState = _state; @@ -119,14 +108,12 @@ abstract base class SpinifyServerSubscriptionBase } /// Notify about new publication. - /// {@nodoc} @nonVirtual void _handlePublication(SpinifyPublication publication) { final offset = publication.offset; if (offset != null && offset > _offset) _offset = offset; } - /// {@nodoc} @internal @mustCallSuper Future close([int code = 0, String reason = 'closed']) async { @@ -146,7 +133,6 @@ abstract base class SpinifyServerSubscriptionBase /// Mixin responsible for event receiving and distribution by controllers /// and streams to subscribers. -/// {@nodoc} base mixin SpinifyServerSubscriptionEventReceiverMixin on SpinifyServerSubscriptionBase { @protected @@ -197,7 +183,6 @@ base mixin SpinifyServerSubscriptionEventReceiverMixin /// Handle push event from server for the specific channel. /// Called from `SpinifyClientSubscriptionsManager.onPush` - /// {@nodoc} @internal @nonVirtual void onPush(SpinifyChannelPush push) { @@ -255,7 +240,6 @@ base mixin SpinifyServerSubscriptionEventReceiverMixin } /// Mixin responsible for errors stream. -/// {@nodoc} @internal base mixin SpinifyServerSubscriptionErrorsMixin on SpinifyServerSubscriptionBase { @@ -266,12 +250,10 @@ base mixin SpinifyServerSubscriptionErrorsMixin } /// Mixin responsible for ready method. -/// {@nodoc} @internal base mixin SpinifyServerSubscriptionReadyMixin on SpinifyServerSubscriptionBase, SpinifyServerSubscriptionErrorsMixin { /// Await for subscription to be ready. - /// {@nodoc} @override FutureOr ready() async { try { @@ -301,7 +283,6 @@ base mixin SpinifyServerSubscriptionReadyMixin } /// Mark subscription as ready. - /// {@nodoc} void setSubscribed() { if (!state.isSubscribed) _setState(SpinifySubscriptionState.subscribed( @@ -311,7 +292,6 @@ base mixin SpinifyServerSubscriptionReadyMixin } /// Mark subscription as subscribing. - /// {@nodoc} void setSubscribing() { if (!state.isSubscribing) _setState(SpinifySubscriptionState.subscribing( @@ -321,7 +301,6 @@ base mixin SpinifyServerSubscriptionReadyMixin } /// Mark subscription as unsubscribed. - /// {@nodoc} void setUnsubscribed(int code, String reason) { if (!state.isUnsubscribed) _setState(SpinifySubscriptionState.unsubscribed( @@ -341,7 +320,6 @@ base mixin SpinifyServerSubscriptionReadyMixin } /// Mixin responsible for publishing. -/// {@nodoc} @internal base mixin SpinifyServerSubscriptionPublishingMixin on SpinifyServerSubscriptionBase, SpinifyServerSubscriptionErrorsMixin { @@ -362,7 +340,6 @@ base mixin SpinifyServerSubscriptionPublishingMixin } /// Mixin responsible for history. -/// {@nodoc} @internal base mixin SpinifyServerSubscriptionHistoryMixin on SpinifyServerSubscriptionBase, SpinifyServerSubscriptionErrorsMixin { @@ -393,7 +370,6 @@ base mixin SpinifyServerSubscriptionHistoryMixin } /// Mixin responsible for presence. -/// {@nodoc} @internal base mixin SpinifyServerSubscriptionPresenceMixin on SpinifyServerSubscriptionBase, SpinifyServerSubscriptionErrorsMixin { @@ -432,11 +408,9 @@ base mixin SpinifyServerSubscriptionPresenceMixin /// Mixin responsible for queue. /// SHOULD BE LAST MIXIN. -/// {@nodoc} @internal base mixin SpinifyServerSubscriptionQueueMixin on SpinifyServerSubscriptionBase { - /// {@nodoc} final SpinifyEventQueue _eventQueue = SpinifyEventQueue(); @override diff --git a/lib/src/subscription/server_subscription_manager.dart b/lib/src/subscription/server_subscription_manager.dart index a679981..3d96bf3 100644 --- a/lib/src/subscription/server_subscription_manager.dart +++ b/lib/src/subscription/server_subscription_manager.dart @@ -10,15 +10,12 @@ import 'package:spinify/src/subscription/subscription_state.dart'; import 'package:spinify/src/transport/transport_interface.dart'; /// Responsible for managing client-side subscriptions. -/// {@nodoc} @internal final class ServerSubscriptionManager { - /// {@nodoc} ServerSubscriptionManager(ISpinifyTransport transport) : _transportWeakRef = WeakReference(transport); /// Spinify client weak reference. - /// {@nodoc} final WeakReference _transportWeakRef; /// Subscriptions count. @@ -45,7 +42,6 @@ final class ServerSubscriptionManager { /// Subscriptions registry (channel -> subscription). /// Channel : SpinifyClientSubscription - /// {@nodoc} final Map _channelSubscriptions = {}; @@ -53,7 +49,6 @@ final class ServerSubscriptionManager { /// Returns all registered subscriptions, /// so you can iterate over all and do some action if required /// (for example, you want to unsubscribe/remove all subscriptions). - /// {@nodoc} Map get subscriptions => UnmodifiableMapView({ for (final entry in _channelSubscriptions.entries) @@ -89,7 +84,6 @@ final class ServerSubscriptionManager { /// Called when subscribed to a server-side channel upon Client moving to /// connected state or during connection lifetime if server sends Subscribe /// push message. - /// {@nodoc} void setSubscribedAll() { for (final entry in _channelSubscriptions.values) { if (entry.state.isSubscribed) continue; @@ -99,7 +93,6 @@ final class ServerSubscriptionManager { /// Called when existing connection lost (Client reconnects) or Client /// explicitly disconnected. Client continue keeping server-side subscription /// registry with stream position information where applicable. - /// {@nodoc} void setSubscribingAll() { for (final entry in _channelSubscriptions.values) { if (entry.state.isSubscribing) continue; @@ -109,7 +102,6 @@ final class ServerSubscriptionManager { /// Called when server sent unsubscribe push or server-side subscription /// previously existed in SDK registry disappeared upon Client reconnect. - /// {@nodoc} void setUnsubscribedAll([int code = 0, String reason = 'unsubscribed']) { for (final entry in _channelSubscriptions.values) { if (entry.state.isUnsubscribed) continue; @@ -118,7 +110,6 @@ final class ServerSubscriptionManager { } /// Close all subscriptions. - /// {@nodoc} void close([ int code = 0, String reason = 'client closed', @@ -130,7 +121,6 @@ final class ServerSubscriptionManager { } /// Handle push event from server for the specific channel. - /// {@nodoc} @internal void onPush(SpinifyChannelPush push) => _channelSubscriptions[push.channel]?.onPush(push); @@ -140,7 +130,6 @@ final class ServerSubscriptionManager { /// /// You need to call [SpinifyClientSubscription.subscribe] /// to start receiving events - /// {@nodoc} SpinifyServerSubscription? operator [](String channel) => _channelSubscriptions[channel]; } diff --git a/lib/src/subscription/subscription_state.dart b/lib/src/subscription/subscription_state.dart index f059652..31a1f66 100644 --- a/lib/src/subscription/subscription_state.dart +++ b/lib/src/subscription/subscription_state.dart @@ -55,7 +55,7 @@ sealed class SpinifySubscriptionState extends _$SpinifySubscriptionStateBase { /// {@category Entity} final class SpinifySubscriptionState$Unsubscribed extends SpinifySubscriptionState { - /// {@nodoc} + /// {@macro subscription_state} SpinifySubscriptionState$Unsubscribed({ required this.code, required this.reason, @@ -120,7 +120,7 @@ final class SpinifySubscriptionState$Unsubscribed /// {@category Entity} final class SpinifySubscriptionState$Subscribing extends SpinifySubscriptionState { - /// {@nodoc} + /// {@macro subscription_state} SpinifySubscriptionState$Subscribing({ DateTime? timestamp, super.since, @@ -170,7 +170,7 @@ final class SpinifySubscriptionState$Subscribing /// {@category Entity} final class SpinifySubscriptionState$Subscribed extends SpinifySubscriptionState { - /// {@nodoc} + /// {@macro subscription_state} SpinifySubscriptionState$Subscribed({ DateTime? timestamp, super.since, @@ -228,10 +228,8 @@ final class SpinifySubscriptionState$Subscribed typedef SpinifySubscriptionStateMatch = R Function(S state); -/// {@nodoc} @immutable abstract base class _$SpinifySubscriptionStateBase { - /// {@nodoc} const _$SpinifySubscriptionStateBase({ required this.timestamp, required this.since, diff --git a/lib/src/subscription/unsubscribe_code.dart b/lib/src/subscription/unsubscribe_code.dart index 2e54fb0..3901aaa 100644 --- a/lib/src/subscription/unsubscribe_code.dart +++ b/lib/src/subscription/unsubscribe_code.dart @@ -1,7 +1,6 @@ import 'package:meta/meta.dart'; /// Unsubscribe codes. -/// {@nodoc} @internal enum UnsubscribeCode { /// Disconnect called diff --git a/lib/src/transport/transport_interface.dart b/lib/src/transport/transport_interface.dart index 6cd4191..19efe67 100644 --- a/lib/src/transport/transport_interface.dart +++ b/lib/src/transport/transport_interface.dart @@ -14,37 +14,29 @@ import 'package:spinify/src/subscription/subscription_config.dart'; import 'package:spinify/src/util/notifier.dart'; /// Class responsible for sending and receiving data from the server. -/// {@nodoc} @internal abstract interface class ISpinifyTransport { /// Current state - /// {@nodoc} SpinifyState get state; /// State observable. - /// {@nodoc} abstract final SpinifyListenable states; /// Spinify events. - /// {@nodoc} abstract final SpinifyListenable events; /// Received bytes count & size. - /// {@nodoc} ({BigInt count, BigInt size}) get received; /// Transferred bytes count & size. - /// {@nodoc} ({BigInt count, BigInt size}) get transferred; /// Message response timeout in milliseconds. - /// {@nodoc} ({int min, int avg, int max}) get speed; /// Connect to the server. /// [url] is a URL of endpoint. /// [subs] is a list of server-side subscriptions to subscribe on connect. - /// {@nodoc} Future connect( String url, ServerSubscriptionManager serverSubscriptionManager, @@ -53,11 +45,9 @@ abstract interface class ISpinifyTransport { /// Send asynchronous message to a server. This method makes sense /// only when using Centrifuge library for Go on a server side. In Centrifuge /// asynchronous message handler does not exist. - /// {@nodoc} Future sendAsyncMessage(List data); /// Subscribe on channel with optional [since] position. - /// {@nodoc} Future subscribe( String channel, SpinifySubscriptionConfig config, @@ -65,19 +55,16 @@ abstract interface class ISpinifyTransport { ); /// Unsubscribe from channel. - /// {@nodoc} Future unsubscribe( String channel, SpinifySubscriptionConfig config, ); /// Publish data to channel. - /// {@nodoc} Future publish(String channel, List data); /// Fetch publication history inside a channel. /// Only for channels where history is enabled. - /// {@nodoc} Future history( String channel, { int? limit, @@ -86,24 +73,19 @@ abstract interface class ISpinifyTransport { }); /// Fetch presence information inside a channel. - /// {@nodoc} Future presence(String channel); /// Fetch presence stats information inside a channel. - /// {@nodoc} Future presenceStats(String channel); /// Disconnect from the server. /// e.g. code: 0, reason: 'disconnect called' - /// {@nodoc} Future disconnect(int code, String reason); /// Send refresh token command to server. - /// {@nodoc} Future sendRefresh(String token); /// Send subscription channel refresh token command to server. - /// {@nodoc} Future sendSubRefresh( String channel, String token, @@ -114,6 +96,5 @@ abstract interface class ISpinifyTransport { /// Permanent close connection to the server and /// free all allocated resources. - /// {@nodoc} Future close(); } diff --git a/lib/src/transport/transport_protobuf_codec.dart b/lib/src/transport/transport_protobuf_codec.dart index ec51f7c..5d27b99 100644 --- a/lib/src/transport/transport_protobuf_codec.dart +++ b/lib/src/transport/transport_protobuf_codec.dart @@ -5,10 +5,8 @@ import 'package:protobuf/protobuf.dart' as pb; import 'package:spinify/src/transport/protobuf/client.pb.dart' as pb; import 'package:spinify/src/util/logger.dart' as logger; -/// {@nodoc} @internal final class TransportProtobufCodec extends Codec> { - /// {@nodoc} const TransportProtobufCodec(); @override @@ -20,10 +18,8 @@ final class TransportProtobufCodec extends Codec> { const TransportProtobufEncoder(); } -/// {@nodoc} @internal final class TransportProtobufEncoder extends Converter> { - /// {@nodoc} const TransportProtobufEncoder(); @override @@ -39,11 +35,9 @@ final class TransportProtobufEncoder extends Converter> { } } -/// {@nodoc} @internal final class TransportProtobufDecoder extends Converter, Iterable> { - /// {@nodoc} const TransportProtobufDecoder(); @override diff --git a/lib/src/transport/ws_protobuf_transport.dart b/lib/src/transport/ws_protobuf_transport.dart index b329d8c..9d1c28b 100644 --- a/lib/src/transport/ws_protobuf_transport.dart +++ b/lib/src/transport/ws_protobuf_transport.dart @@ -36,10 +36,8 @@ import 'package:spinify/src/util/notifier.dart'; import 'package:spinify/src/util/speed_meter.dart'; import 'package:ws/ws.dart'; -/// {@nodoc} @internal abstract base class SpinifyWSPBTransportBase implements ISpinifyTransport { - /// {@nodoc} SpinifyWSPBTransportBase({ required SpinifyConfig config, }) : _config = config, @@ -63,13 +61,11 @@ abstract base class SpinifyWSPBTransportBase implements ISpinifyTransport { } /// Protocols for websocket. - /// {@nodoc} static const List _$protocolsSpinifyProtobuf = [ 'centrifuge-protobuf' ]; /// Spinify config. - /// {@nodoc} final SpinifyConfig _config; @override @@ -77,13 +73,11 @@ abstract base class SpinifyWSPBTransportBase implements ISpinifyTransport { SpinifyChangeNotifier(); /// Init transport, override this method to add custom logic. - /// {@nodoc} @protected @mustCallSuper void _initTransport() {} /// Websocket client. - /// {@nodoc} @nonVirtual final WebSocketClient _webSocket; @@ -116,7 +110,6 @@ abstract base class SpinifyWSPBTransportBase implements ISpinifyTransport { /// Class responsible for sending and receiving data from the server /// through the Protobuf & WebSocket protocol. -/// {@nodoc} @internal // ignore: lines_longer_than_80_chars final class SpinifyWSPBTransport = SpinifyWSPBTransportBase @@ -130,23 +123,19 @@ final class SpinifyWSPBTransport = SpinifyWSPBTransportBase SpinifyWSPBHandlerMixin; /// Stored completer for responses. -/// {@nodoc} typedef _ReplyCompleter = ({ void Function(pb.Reply reply) complete, void Function(Object error, StackTrace stackTrace) fail, }); /// Mixin responsible for holding reply completers. -/// {@nodoc} @internal base mixin SpinifyWSPBReplyMixin on SpinifyWSPBTransportBase { /// Completers for messages by id. /// Contains timer for timeout and completer for response. - /// {@nodoc} final Map _replyCompleters = {}; /// Observe reply future by command id. - /// {@nodoc} Future _awaitReply(int commandId, [Duration? timeout]) { final completer = Completer.sync(); final timeoutTimer = timeout != null && timeout > Duration.zero @@ -183,12 +172,10 @@ base mixin SpinifyWSPBReplyMixin on SpinifyWSPBTransportBase { } /// Complete reply by id. - /// {@nodoc} void _completeReply(pb.Reply reply) => _replyCompleters.remove(reply.id)?.complete(reply); /// Fail all replies. - /// {@nodoc} void _failAllReplies(Object error, StackTrace stackTrace) { for (final completer in _replyCompleters.values) { completer.fail(error, stackTrace); @@ -198,12 +185,10 @@ base mixin SpinifyWSPBReplyMixin on SpinifyWSPBTransportBase { } /// Mixin responsible for sending data through websocket with protobuf. -/// {@nodoc} @internal base mixin SpinifyWSPBSenderMixin on SpinifyWSPBTransportBase, SpinifyWSPBReplyMixin { /// Encoder protobuf commands to bytes. - /// {@nodoc} static const Converter> _commandEncoder = TransportProtobufEncoder(); @@ -214,10 +199,8 @@ base mixin SpinifyWSPBSenderMixin ({int min, int avg, int max}) get speed => _speedMeter.speed; /// Counter for messages. - /// {@nodoc} int _messageId = 1; - /// {@nodoc} @nonVirtual @protected Future _sendMessage sendAsyncMessage(List data) => _sendAsyncMessage(pb.Message()..data = data); - /// {@nodoc} @nonVirtual @protected Future _sendAsyncMessage( @@ -342,7 +324,6 @@ base mixin SpinifyWSPBSenderMixin } /// Mixin responsible for connection. -/// {@nodoc} @internal base mixin SpinifyWSPBConnectionMixin on @@ -479,13 +460,11 @@ base mixin SpinifyWSPBConnectionMixin } /// Handler for websocket states. -/// {@nodoc} @internal base mixin SpinifyWSPBStateHandlerMixin on SpinifyWSPBTransportBase, SpinifyWSPBReplyMixin { // Subscribe to websocket state after first connection. /// Subscription to websocket state. - /// {@nodoc} StreamSubscription? _webSocketClosedStateSubscription; @override @@ -500,7 +479,6 @@ base mixin SpinifyWSPBStateHandlerMixin closeReason: 'Not connected yet', ); - /// {@nodoc} @override @nonVirtual final SpinifyChangeNotifier states = SpinifyChangeNotifier(); @@ -511,7 +489,6 @@ base mixin SpinifyWSPBStateHandlerMixin } /// Change state of spinify client. - /// {@nodoc} @protected @nonVirtual void _setState(SpinifyState state) { @@ -566,7 +543,6 @@ base mixin SpinifyWSPBStateHandlerMixin } /// Handler for websocket messages and decode protobuf. -/// {@nodoc} @internal base mixin SpinifyWSPBHandlerMixin on @@ -574,12 +550,10 @@ base mixin SpinifyWSPBHandlerMixin SpinifyWSPBSenderMixin, SpinifyWSPBPingPongMixin { /// Encoder protobuf commands to bytes. - /// {@nodoc} static const Converter, Iterable> _replyDecoder = TransportProtobufDecoder(); /// Subscription to websocket messages/data. - /// {@nodoc} StreamSubscription>? _webSocketMessageSubscription; BigInt _receivedCount = BigInt.zero; @@ -601,7 +575,6 @@ base mixin SpinifyWSPBHandlerMixin return super.connect(url, serverSubscriptionManager); } - /// {@nodoc} @protected @nonVirtual @pragma('vm:prefer-inline') @@ -755,7 +728,6 @@ base mixin SpinifyWSPBHandlerMixin } /// Mixin responsible for spinify subscriptions. -/// {@nodoc} @internal base mixin SpinifyWSPBSubscription on SpinifyWSPBTransportBase, SpinifyWSPBSenderMixin { @@ -958,7 +930,6 @@ base mixin SpinifyWSPBSubscription /// When client does not receive ping from a server for some /// time it can consider connection broken and try to reconnect. /// Usually a server sends pings every 25 seconds. -/// {@nodoc} @internal base mixin SpinifyWSPBPingPongMixin on SpinifyWSPBTransportBase { @protected @@ -978,7 +949,6 @@ base mixin SpinifyWSPBPingPongMixin on SpinifyWSPBTransportBase { /// Start or restart keepalive timer, /// you should restart it after each received ping message. /// Or connection will be closed by timeout. - /// {@nodoc} @protected @nonVirtual void _restartPingTimer() { @@ -1006,11 +976,10 @@ base mixin SpinifyWSPBPingPongMixin on SpinifyWSPBTransportBase { } } -/// {@nodoc} final List _emptyPublicationsList = List.empty(growable: false); -/// {@nodoc} +/// Decode protobuf messages to Spinify models. @internal SpinifyPublication Function(pb.Publication publication) $publicationDecode( String channel, @@ -1027,7 +996,7 @@ SpinifyPublication Function(pb.Publication publication) $publicationDecode( ); } -/// {@nodoc} +/// Decode protobuf client info to Spinify client info. @internal SpinifyClientInfo $decodeClientInfo(pb.ClientInfo info) => SpinifyClientInfo( client: info.client, diff --git a/lib/src/util/event_queue.dart b/lib/src/util/event_queue.dart index 266b177..3ae6f61 100644 --- a/lib/src/util/event_queue.dart +++ b/lib/src/util/event_queue.dart @@ -4,10 +4,8 @@ import 'dart:collection'; import 'package:meta/meta.dart'; import 'package:spinify/src/util/logger.dart'; -/// {@nodoc} @internal final class SpinifyEventQueue { - /// {@nodoc} SpinifyEventQueue(); final DoubleLinkedQueue> _queue = @@ -16,7 +14,6 @@ final class SpinifyEventQueue { bool _isClosed = false; /// Push it at the end of the queue. - /// {@nodoc} Future push(String id, FutureOr Function() fn) { final task = SpinifyTask(id, fn); _queue.add(task); @@ -27,14 +24,12 @@ final class SpinifyEventQueue { /// Mark the queue as closed. /// The queue will be processed until it's empty. /// But all new and current events will be rejected with [WSClientClosed]. - /// {@nodoc} FutureOr close() async { _isClosed = true; await _processing; } /// Execute the queue. - /// {@nodoc} void _exec() => _processing ??= Future.doWhile(() async { final event = _queue.first; try { @@ -66,27 +61,20 @@ final class SpinifyEventQueue { }); } -/// {@nodoc} @internal class SpinifyTask { - /// {@nodoc} SpinifyTask(this.id, FutureOr Function() fn) : _fn = fn, _completer = Completer(); - /// {@nodoc} final Completer _completer; - /// {@nodoc} final String id; - /// {@nodoc} final FutureOr Function() _fn; - /// {@nodoc} Future get future => _completer.future; - /// {@nodoc} FutureOr call() async { final result = await _fn(); if (!_completer.isCompleted) { @@ -95,7 +83,6 @@ class SpinifyTask { return result; } - /// {@nodoc} void reject(Object error, [StackTrace? stackTrace]) { if (_completer.isCompleted) return; // coverage:ignore-line _completer.completeError(error, stackTrace); diff --git a/lib/src/util/logger.dart b/lib/src/util/logger.dart index 1d7e971..b800f2b 100644 --- a/lib/src/util/logger.dart +++ b/lib/src/util/logger.dart @@ -5,7 +5,6 @@ import 'package:meta/meta.dart'; /// Constants used to debug the Spinify client. /// --dart-define=dev.plugfox.spinify.debug=true -/// {@nodoc} @internal bool get $enableLogging => const bool.fromEnvironment( @@ -15,33 +14,27 @@ bool get $enableLogging => Zone.current[#dev.plugfox.spinify.log] == true; /// Tracing information -/// {@nodoc} @internal final void Function(Object? message) fine = _logAll('FINE', 500); /// Static configuration messages -/// {@nodoc} @internal final void Function(Object? message) config = _logAll('CONF', 700); /// Iformational messages -/// {@nodoc} @internal final void Function(Object? message) info = _logAll('INFO', 800); /// Potential problems -/// {@nodoc} @internal final void Function(Object exception, [StackTrace? stackTrace, String? reason]) warning = _logAll('WARN', 900); /// Serious failures -/// {@nodoc} @internal final void Function(Object error, [StackTrace stackTrace, String? reason]) severe = _logAll('ERR!', 1000); -/// {@nodoc} void Function( Object? message, [ StackTrace? stackTrace, diff --git a/lib/src/util/notifier.dart b/lib/src/util/notifier.dart index 7ca4e3d..07aeeaf 100644 --- a/lib/src/util/notifier.dart +++ b/lib/src/util/notifier.dart @@ -1,38 +1,30 @@ import 'package:meta/meta.dart'; /// Notify about value changes. -/// {@nodoc} typedef ValueChanged = void Function(T value); /// Notify about value changes. -/// {@nodoc} @internal abstract interface class SpinifyListenable { /// Add listener. - /// {@nodoc} void addListener(ValueChanged listener); /// Remove listener. - /// {@nodoc} void removeListener(ValueChanged listener); } /// Notify about value changes. -/// {@nodoc} @internal final class SpinifyChangeNotifier implements SpinifyListenable { /// Notify about value changes. - /// {@nodoc} SpinifyChangeNotifier(); /// Notify about value changes. - /// {@nodoc} void notify(T value) { for (var i = 0; i < _listeners.length; i++) _listeners[i](value); } /// Listeners. - /// {@nodoc} final List> _listeners = >[]; @override diff --git a/lib/src/util/speed_meter.dart b/lib/src/util/speed_meter.dart index 928a3ea..da0bcaf 100644 --- a/lib/src/util/speed_meter.dart +++ b/lib/src/util/speed_meter.dart @@ -2,21 +2,17 @@ import 'dart:math' as math; import 'package:meta/meta.dart'; -/// {@nodoc} @internal class SpinifySpeedMeter { - /// {@nodoc} SpinifySpeedMeter(this.size) : _speeds = List.filled(size, 0); /// Size of the speed meter - /// {@nodoc} final int size; final List _speeds; int _pointer = 0; int _count = 0; /// Add new speed in ms - /// {@nodoc} void add(num speed) { _speeds[_pointer] = speed.toInt(); _pointer = (_pointer + 1) % size; @@ -24,7 +20,6 @@ class SpinifySpeedMeter { } /// Get speed in ms - /// {@nodoc} ({int min, int avg, int max}) get speed { if (_count == 0) return (min: 0, avg: 0, max: 0); var sum = _speeds.first, min = sum, max = sum;