From b559cf7ecb76ed39af0cc0eb8f7e3c32d6d223d0 Mon Sep 17 00:00:00 2001 From: Jimmy Tai Date: Fri, 27 May 2022 16:54:37 +0800 Subject: [PATCH 01/10] Ignore fvm/vscode settings folder in git. --- .gitignore | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 02c4c38..061dba8 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,7 @@ .pub/ build/ -.idea/ \ No newline at end of file +.idea/ + +.fvm/ +.vscode/ \ No newline at end of file From b199b447b0cb0fce10961fe981d6da3b7212c8d0 Mon Sep 17 00:00:00 2001 From: Jimmy Tai Date: Fri, 27 May 2022 17:01:38 +0800 Subject: [PATCH 02/10] Re-define class related to authorize. Solve some data parsing issue. There are some data could not be passed via MethodChannel such as AuthorizeOptions etc. Should create a "toMap" function to serialize those data. Because we use StatndartMethodCodec in MethodChannel. --- lib/pusher-js/core/auth/auth_transports.dart | 13 +- lib/pusher-js/core/auth/options.dart | 72 +++++--- .../core/auth/pusher_authorizer.dart | 20 ++- lib/pusher-js/core/pusher.dart | 2 +- lib/pusher-js/runtimes/interface.dart | 4 +- lib/pusher_channels_flutter.dart | 38 +++-- lib/pusher_channels_flutter_web.dart | 154 +++++++++--------- 7 files changed, 167 insertions(+), 136 deletions(-) diff --git a/lib/pusher-js/core/auth/auth_transports.dart b/lib/pusher-js/core/auth/auth_transports.dart index 5930502..11e0f3a 100644 --- a/lib/pusher-js/core/auth/auth_transports.dart +++ b/lib/pusher-js/core/auth/auth_transports.dart @@ -4,10 +4,11 @@ library core.auth.auth_transports; import "package:js/js.dart"; import "../../runtimes/interface.dart" show Runtime; -typedef AuthTransport = void Function(Runtime context, String socketId, Function callback); +typedef AuthTransport = void Function( + Runtime context, String socketId, Function callback); -@anonymous -@JS() -abstract class AuthTransports { - /* Index signature is not yet supported by JavaScript interop. */ -} +// @anonymous +// @JS() +// abstract class AuthTransports { + +// } diff --git a/lib/pusher-js/core/auth/options.dart b/lib/pusher-js/core/auth/options.dart index 6aebe65..fd10f19 100644 --- a/lib/pusher-js/core/auth/options.dart +++ b/lib/pusher-js/core/auth/options.dart @@ -9,11 +9,22 @@ import "../channels/channel.dart" show Channel; @anonymous @JS() abstract class AuthOptions { - external dynamic get params; - external set params(dynamic v); - external dynamic get headers; - external set headers(dynamic v); - external factory AuthOptions({dynamic params, dynamic headers}); + external Map get params; + external set params(Map v); + external Map get headers; + external set headers(Map v); + + external factory AuthOptions({ + Map params, + Map headers, + }); +} + +extension AuthOptionsExt on AuthOptions { + Map toMap() => { + 'params': params, + 'headers': headers, + }; } @anonymous @@ -21,20 +32,30 @@ abstract class AuthOptions { abstract class AuthData { external String get auth; external set auth(String v); - external String get channel_data; - external set channel_data(String v); - external String get shared_secret; - external set shared_secret(String v); - external factory AuthData( - {String auth, String? channel_data, String? shared_secret}); + external String? get channel_data; + external set channel_data(String? v); + external String? get shared_secret; + external set shared_secret(String? v); + + external factory AuthData({ + String auth, + String? channel_data, + String? shared_secret, + }); } typedef AuthorizerCallback = void Function(Error? error, AuthData authData); +typedef AuthorizeFunc = void Function( + String socketId, AuthorizerCallback callback); + @anonymous @JS() abstract class Authorizer { - external void authorize(String socketId, AuthorizerCallback callback); + external set authorize(AuthorizeFunc v); + external AuthorizeFunc get authorize; + + external factory Authorizer({AuthorizeFunc authorize}); } typedef AuthorizerGenerator = Authorizer Function( @@ -47,13 +68,22 @@ abstract class AuthorizerOptions { external set authTransport(String /*'ajax'|'jsonp'*/ v); external String get authEndpoint; external set authEndpoint(String v); - external AuthOptions get auth; - external set auth(AuthOptions v); - external AuthorizerGenerator get authorizer; - external set authorizer(AuthorizerGenerator v); - external factory AuthorizerOptions( - {String /*'ajax'|'jsonp'*/ authTransport, - String authEndpoint, - AuthOptions auth, - AuthorizerGenerator authorizer}); + external AuthOptions? get auth; + external set auth(AuthOptions? v); + external AuthorizerGenerator? get authorizer; + external set authorizer(AuthorizerGenerator? v); + external factory AuthorizerOptions({ + String /*'ajax'|'jsonp'*/ authTransport, + String authEndpoint, + AuthOptions? auth, + AuthorizerGenerator? authorizer, + }); +} + +extension AuthorizerOptionsExt on AuthorizerOptions { + Map toMap() => { + 'authTransport': authTransport, + 'authEndpoint': authEndpoint, + 'auth': auth, + }; } diff --git a/lib/pusher-js/core/auth/pusher_authorizer.dart b/lib/pusher-js/core/auth/pusher_authorizer.dart index cdeb01b..5efe02e 100644 --- a/lib/pusher-js/core/auth/pusher_authorizer.dart +++ b/lib/pusher-js/core/auth/pusher_authorizer.dart @@ -2,15 +2,14 @@ library core.auth.pusher_authorizer; import "package:js/js.dart"; -import "options.dart" - show Authorizer, AuthorizerOptions, AuthOptions, AuthorizerCallback; -import "auth_transports.dart" show AuthTransports; +import "options.dart" show Authorizer, AuthorizerOptions, AuthOptions; +import "auth_transports.dart" show AuthTransport; import "../channels/channel.dart" show Channel; @JS() -class PusherAuthorizer implements Authorizer { - external static AuthTransports get authorizers; - external static set authorizers(AuthTransports v); +abstract class PusherAuthorizer implements Authorizer { + external static Map get authorizers; + external Channel get channel; external set channel(Channel v); external String get type; @@ -19,8 +18,11 @@ class PusherAuthorizer implements Authorizer { external set options(AuthorizerOptions v); external AuthOptions get authOptions; external set authOptions(AuthOptions v); - external factory PusherAuthorizer(Channel channel, AuthorizerOptions options); + external String composeQuery(String socketId); - @override - external void authorize(String socketId, AuthorizerCallback callback); + + external factory PusherAuthorizer({ + Channel channel, + AuthorizerOptions options, + }); } diff --git a/lib/pusher-js/core/pusher.dart b/lib/pusher-js/core/pusher.dart index d1992ed..508d8bd 100644 --- a/lib/pusher-js/core/pusher.dart +++ b/lib/pusher-js/core/pusher.dart @@ -58,7 +58,7 @@ class Pusher { // external PeriodicTimer get timelineSenderTimer; // external set timelineSenderTimer(PeriodicTimer v); external factory Pusher(String app_key, [Options options]); - external Channel channel(String name); + external Channel? channel(String name); external List allChannels(); external connect(); external disconnect(); diff --git a/lib/pusher-js/runtimes/interface.dart b/lib/pusher-js/runtimes/interface.dart index 8a15a36..fae52fb 100644 --- a/lib/pusher-js/runtimes/interface.dart +++ b/lib/pusher-js/runtimes/interface.dart @@ -7,7 +7,7 @@ import 'dart:html'; import "package:js/js.dart"; import 'package:pusher_channels_flutter/pusher-js/runtimes/web/dom/script_receiver_factory.dart'; -import "../core/auth/auth_transports.dart" show AuthTransports; +import "../core/auth/auth_transports.dart" show AuthTransport; import "../core/timeline/timeline_transport.dart" show TimelineTransport; import "../core/http/ajax.dart" show Ajax; import "../core/socket.dart" show Socket; @@ -36,7 +36,7 @@ abstract class Runtime { }*/ PusherClass); external String getProtocol(); - external AuthTransports getAuthorizers(); + external Map getAuthorizers(); external dynamic getLocalStorage(); external TimelineTransport timelineTransport; //external set TimelineTransport(TimelineTransport v); diff --git a/lib/pusher_channels_flutter.dart b/lib/pusher_channels_flutter.dart index 85d2521..1617223 100644 --- a/lib/pusher_channels_flutter.dart +++ b/lib/pusher_channels_flutter.dart @@ -8,25 +8,26 @@ class PusherEvent { String eventName; dynamic data; String? userId; - PusherEvent( - {required this.channelName, - required this.eventName, - this.data, - this.userId}); + PusherEvent({ + required this.channelName, + required this.eventName, + this.data, + this.userId, + }); + @override - String toString() { - return "{ channelName: $channelName, eventName: $eventName, data: $data, userId: $userId }"; - } + String toString() => + '{ channelName: $channelName, eventName: $eventName, data: $data, userId: $userId }'; } class PusherMember { String userId; dynamic userInfo; + PusherMember(this.userId, this.userInfo); + @override - String toString() { - return "{ userId: $userId, userInfo: $userInfo }"; - } + String toString() => '{ userId: $userId, userInfo: $userInfo }'; } class PusherChannel { @@ -38,13 +39,14 @@ class PusherChannel { Function(dynamic event)? onEvent; Function(PusherMember member)? onMemberAdded; Function(PusherMember member)? onMemberRemoved; - PusherChannel( - {required this.channelName, - this.onSubscriptionSucceeded, - this.onEvent, - this.onMemberAdded, - this.onMemberRemoved, - this.me}); + PusherChannel({ + required this.channelName, + this.onSubscriptionSucceeded, + this.onEvent, + this.onMemberAdded, + this.onMemberRemoved, + this.me, + }); Future unsubscribe() async { return PusherChannelsFlutter.getInstance() diff --git a/lib/pusher_channels_flutter_web.dart b/lib/pusher_channels_flutter_web.dart index c330800..0cf77cc 100644 --- a/lib/pusher_channels_flutter_web.dart +++ b/lib/pusher_channels_flutter_web.dart @@ -2,10 +2,10 @@ library pusher_channels_flutter; import 'dart:async'; -import 'package:flutter/material.dart'; +import 'dart:convert'; import 'package:js/js.dart'; import 'package:js/js_util.dart' as js_util; -// In order to *not* need this ignore, consider extracting the "web" version +// In order to *not* need this ignore, consider extracting the 'web' version // of your plugin as a separate package, instead of inlining it in the same // package as the core of your plugin. // ignore: avoid_web_libraries_in_flutter @@ -51,18 +51,6 @@ T dartify(dynamic jsObject) { return result as T; } -class PusherChannelsFlutterWebAuthorizer implements Authorizer { - final void Function(String socketId, AuthorizerCallback callback) _authorize; - PusherChannelsFlutterWebAuthorizer( - void Function(String socketId, AuthorizerCallback callback) authorize) - : _authorize = authorize; - - @override - void authorize(String socketId, AuthorizerCallback callback) { - _authorize(socketId, callback); - } -} - /// A web implementation of the PusherChannelsFlutter plugin. class PusherChannelsFlutterWeb { Pusher? pusher; @@ -114,96 +102,104 @@ class PusherChannelsFlutterWeb { void assertPusher() { if (pusher == null) { - throw ArgumentError.notNull("Pusher not initialized"); + throw ArgumentError.notNull('Pusher not initialized'); } } - void assertChannel(channelName) { + void assertChannel(String channelName) { if (pusher!.channel(channelName) == null) { - throw ArgumentError.notNull("Not subscribed to channel: $channelName"); + throw ArgumentError.notNull('Not subscribed to channel: $channelName'); } } - void onError(err) { - methodChannel!.invokeMethod("onError", { - "message": err.data?.message, - "code": err.data?.code, - "error": dartify(err), + void onError(dynamic jsError) { + final Map error = dartify>(jsError); + methodChannel!.invokeMethod('onError', { + 'message': error['data']?['message'], + 'code': error['data']?['code'], + 'error': error, }); } - void onMessage(msg) { - if (msg.event == 'pusher_internal:subscription_error') { - methodChannel!.invokeMethod("onSubscriptionError", - {"message": msg.error, "error": dartify(msg.data)}); - } else if (msg.event == 'pusher_internal:member_added') { - methodChannel!.invokeMethod("onMemberAdded", { - "channelName": msg.channel, - "user": { - "userId": msg.data.user_id, - "userInfo": dartify(msg.data.user_info) + void onMessage(dynamic jsMessage) { + final Map msg = dartify>(jsMessage); + final String event = msg['event'] ?? ''; + final String channel = msg['channel'] ?? ''; + final Map data = msg['data'] ?? {}; + String? userId = data['user_id']; + final Map? userInfo = data['user_info']; + print('onMessage: ${jsonEncode(msg)}'); + + if (event == 'pusher_internal:subscription_error') { + methodChannel!.invokeMethod( + 'onSubscriptionError', {'message': msg['error'], 'error': data}); + } else if (event == 'pusher_internal:member_added') { + methodChannel!.invokeMethod('onMemberAdded', { + 'channelName': channel, + 'user': { + 'userId': userId, + 'userInfo': userInfo, } }); - } else if (msg.event == 'pusher_internal:member_removed') { - methodChannel!.invokeMethod("onMemberRemoved", { - "channelName": msg.channel, - "user": { - "userId": msg.data.user_id, - "userInfo": dartify(msg.data.user_info) + } else if (event == 'pusher_internal:member_removed') { + methodChannel!.invokeMethod('onMemberRemoved', { + 'channelName': channel, + 'user': { + 'userId': userId, + 'userInfo': userInfo, } }); } else { - if (msg.event == 'pusher_internal:subscription_succeeded') { - if (msg.channel.startsWith('presence-')) { - final presenceChannel = - pusher!.channel(msg.channel) as PresenceChannel; - msg.user_id = presenceChannel.members.myID; + if (event == 'pusher_internal:subscription_succeeded') { + if (channel.startsWith('presence-')) { + final presenceChannel = pusher!.channel(channel) as PresenceChannel; + userId = presenceChannel.members.myID; } } - methodChannel!.invokeMethod("onEvent", { - "channelName": msg.channel ?? '', - "eventName": msg.event, - "data": dartify(msg.data), - "userId": msg.user_id + methodChannel!.invokeMethod('onEvent', { + 'channelName': channel, + 'eventName': event, + 'data': data, + 'userId': userId, }); } } - void onStateChange(state) { - final dartState = dartify(state); - methodChannel!.invokeMethod("onConnectionStateChange", { - "currentState": dartState["current"], - "previousState": dartState["previous"] + void onStateChange(dynamic jsState) { + final Map state = + dartify>(jsState ?? {}); + final String current = state['current'] ?? ''; + final String previous = state['previous'] ?? ''; + methodChannel!.invokeMethod('onConnectionStateChange', { + 'currentState': current, + 'previousState': previous, }); } - void onConnected(state) { - print("Connected: " + stringify(state)); - } + void onConnected(dynamic jsMessage) {} - void onDisconnected(state) { - print("Disconnected: " + stringify(state)); - } + void onDisconnected() {} Authorizer onAuthorizer(Channel channel, AuthorizerOptions options) { - return PusherChannelsFlutterWebAuthorizer( - (String socketId, AuthorizerCallback callback) async { - try { - var authData = await methodChannel!.invokeMethod('onAuthorizer', { - "socketId": socketId, - "channelName": channel.name, - "options": dartify(options) - }); - callback( - null, - AuthData( - auth: authData['auth'], - channel_data: authData['channel_data'], - shared_secret: authData['shared_secret'])); - } catch (e) { - callback(PusherError(e.toString(), -1), AuthData(auth: "")); - } - }); + return Authorizer( + authorize: allowInterop((socketId, callback) async { + try { + var authData = await methodChannel!.invokeMethod('onAuthorizer', { + 'socketId': socketId, + 'channelName': channel.name, + 'options': options.toMap(), + }); + callback( + null, + AuthData( + auth: authData['auth'], + channel_data: authData['channel_data'], + shared_secret: authData['shared_secret'])); + } catch (e) { + callback(PusherError(e.toString(), -1), AuthData(auth: '')); + } + }), + ); } void subscribe(MethodCall call) { @@ -216,13 +212,13 @@ class PusherChannelsFlutterWeb { var channelName = call.arguments['channelName']; var channel = pusher!.channel(channelName); pusher!.unsubscribe(channelName); - channel.unbind_all(); + channel?.unbind_all(); } void trigger(MethodCall call) { var channelName = call.arguments['channelName']; var channel = pusher!.channel(channelName); - channel.trigger(call.arguments['eventName'], call.arguments['data']); + channel?.trigger(call.arguments['eventName'], call.arguments['data']); } void init(MethodCall call) { From 26c5c09ec13d5d68d97326271708bf90245ce9de Mon Sep 17 00:00:00 2001 From: Niek Date: Sat, 28 May 2022 10:31:49 +0200 Subject: [PATCH 03/10] use map for members --- lib/pusher_channels_flutter.dart | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/pusher_channels_flutter.dart b/lib/pusher_channels_flutter.dart index 85d2521..298c6d1 100644 --- a/lib/pusher_channels_flutter.dart +++ b/lib/pusher_channels_flutter.dart @@ -31,7 +31,7 @@ class PusherMember { class PusherChannel { String channelName; - Set members = {}; + Map members = {}; PusherMember? me; Function(dynamic data)? onSubscriptionSucceeded; @@ -164,7 +164,7 @@ class PusherChannelsFlutter { var decodedData = data is Map ? data : jsonDecode(data); decodedData?["presence"]?["hash"]?.forEach((_userId, userInfo) { var member = PusherMember(_userId, userInfo); - channels[channelName]?.members.add(member); + channels[channelName]?.members[_userId] = member; if (_userId == userId) { channels[channelName]?.me = member; } @@ -194,11 +194,12 @@ class PusherChannelsFlutter { case 'onMemberAdded': var member = PusherMember(user["userId"], user["userInfo"]); onMemberAdded?.call(channelName!, member); - channels[channelName]?.members.add(member); + channels[channelName]?.members[member.userId] = member; channels[channelName]?.onMemberAdded?.call(member); return Future.value(null); case 'onMemberRemoved': var member = PusherMember(user["userId"], user["userInfo"]); + channels[channelName]?.members.remove(member.userId); onMemberRemoved?.call(channelName!, member); channels[channelName]?.onMemberRemoved?.call(member); return Future.value(null); From cb8e89e3dc3b9d12d07ae5e7b87aecce87efa37e Mon Sep 17 00:00:00 2001 From: Niek Date: Sat, 28 May 2022 10:32:35 +0200 Subject: [PATCH 04/10] dart fmt --- example/test/widget_test.dart | 4 ++-- lib/pusher-js/core/auth/auth_transports.dart | 2 +- lib/pusher-js/core/channels/encrypted_channel.dart | 3 --- lib/pusher-js/core/channels/private_channel.dart | 1 + lib/pusher-js/core/connection/connection.dart | 1 - lib/pusher-js/core/options.dart | 2 +- lib/pusher-js/runtimes/interface.dart | 1 - 7 files changed, 5 insertions(+), 9 deletions(-) diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index f6107fc..0bbc483 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -18,8 +18,8 @@ void main() { // Verify that platform version is retrieved. expect( find.byWidgetPredicate( - (Widget widget) => widget is Text && - widget.data!.startsWith('Running on:'), + (Widget widget) => + widget is Text && widget.data!.startsWith('Running on:'), ), findsOneWidget, ); diff --git a/lib/pusher-js/core/auth/auth_transports.dart b/lib/pusher-js/core/auth/auth_transports.dart index 11e0f3a..0ec69bb 100644 --- a/lib/pusher-js/core/auth/auth_transports.dart +++ b/lib/pusher-js/core/auth/auth_transports.dart @@ -10,5 +10,5 @@ typedef AuthTransport = void Function( // @anonymous // @JS() // abstract class AuthTransports { - + // } diff --git a/lib/pusher-js/core/channels/encrypted_channel.dart b/lib/pusher-js/core/channels/encrypted_channel.dart index 0991c84..3f29a38 100644 --- a/lib/pusher-js/core/channels/encrypted_channel.dart +++ b/lib/pusher-js/core/channels/encrypted_channel.dart @@ -1,7 +1,6 @@ @JS() library core.channels.encrypted_channel; - import "package:js/js.dart"; import "dart:typed_data"; import "private_channel.dart" show PrivateChannel; @@ -33,5 +32,3 @@ class EncryptedChannel extends PrivateChannel { /// return the utf-8 string external String getDataToEmit(Uint8List bytes); } - - diff --git a/lib/pusher-js/core/channels/private_channel.dart b/lib/pusher-js/core/channels/private_channel.dart index 477a848..a795c0a 100644 --- a/lib/pusher-js/core/channels/private_channel.dart +++ b/lib/pusher-js/core/channels/private_channel.dart @@ -10,6 +10,7 @@ import "../auth/options.dart" show AuthorizerCallback; @JS() class PrivateChannel extends Channel { external factory PrivateChannel(String name, Pusher pusher); + /// Authorizes the connection to use the channel. @override external authorize(String socketId, AuthorizerCallback callback); diff --git a/lib/pusher-js/core/connection/connection.dart b/lib/pusher-js/core/connection/connection.dart index e78c964..d0bde74 100644 --- a/lib/pusher-js/core/connection/connection.dart +++ b/lib/pusher-js/core/connection/connection.dart @@ -49,7 +49,6 @@ class Connection extends Dispatcher implements Socket { external bindListeners(); external handleCloseEvent(dynamic closeEvent); - @override external bool sendRaw(dynamic payload); @override diff --git a/lib/pusher-js/core/options.dart b/lib/pusher-js/core/options.dart index 2f79ae0..9f7ba8e 100644 --- a/lib/pusher-js/core/options.dart +++ b/lib/pusher-js/core/options.dart @@ -80,7 +80,7 @@ abstract class Options { num httpPort, num httpsPort, bool ignoreNullOrigin, - // nacl nacl, + // nacl nacl, num pongTimeout, String statsHost, dynamic timelineParams, diff --git a/lib/pusher-js/runtimes/interface.dart b/lib/pusher-js/runtimes/interface.dart index fae52fb..aed990c 100644 --- a/lib/pusher-js/runtimes/interface.dart +++ b/lib/pusher-js/runtimes/interface.dart @@ -68,4 +68,3 @@ abstract class Runtime { } /* WARNING: export assignment not yet supported. */ - From 6c39aa9345968d0a45d89eb503ca4d82ad06ba1e Mon Sep 17 00:00:00 2001 From: Niek Date: Sat, 28 May 2022 10:37:34 +0200 Subject: [PATCH 05/10] move onMemberAdded callback below adding to channel members --- lib/pusher_channels_flutter.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pusher_channels_flutter.dart b/lib/pusher_channels_flutter.dart index d307bf0..aa53194 100644 --- a/lib/pusher_channels_flutter.dart +++ b/lib/pusher_channels_flutter.dart @@ -195,8 +195,8 @@ class PusherChannelsFlutter { return Future.value(null); case 'onMemberAdded': var member = PusherMember(user["userId"], user["userInfo"]); - onMemberAdded?.call(channelName!, member); channels[channelName]?.members[member.userId] = member; + onMemberAdded?.call(channelName!, member); channels[channelName]?.onMemberAdded?.call(member); return Future.value(null); case 'onMemberRemoved': From b42b83afe757b6ae7a12ca5155d734fab6c648d1 Mon Sep 17 00:00:00 2001 From: progman <91064515+proggen-com@users.noreply.github.com> Date: Thu, 9 Jun 2022 08:21:35 +0200 Subject: [PATCH 06/10] remove unused options member --- lib/pusher-js/core/options.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/pusher-js/core/options.dart b/lib/pusher-js/core/options.dart index 9f7ba8e..7637369 100644 --- a/lib/pusher-js/core/options.dart +++ b/lib/pusher-js/core/options.dart @@ -80,7 +80,6 @@ abstract class Options { num httpPort, num httpsPort, bool ignoreNullOrigin, - // nacl nacl, num pongTimeout, String statsHost, dynamic timelineParams, From c2e338482b2eff715fd6caad560b3155f5749d81 Mon Sep 17 00:00:00 2001 From: Niek Date: Thu, 16 Jun 2022 15:25:55 +0200 Subject: [PATCH 07/10] ## 1.1.0 * [BREAKING CHANGE] Convert channel member to Map (instead of Set) * [FIXED] Add internal member before calling onMemberAdded callback on channel * [FIXED] onAuthorizer() doesn't work in Flutter web profile/release mode --- CHANGELOG.md | 6 ++++++ pubspec.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca6a965..f466162 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 1.1.0 + +* [BREAKING CHANGE] Convert channel member to Map (instead of Set) +* [FIXED] Add internal member before calling onMemberAdded callback on channel +* [FIXED] onAuthorizer() doesn't work in Flutter web profile/release mode + ## 1.0.5 * [FIXED] Android: Subscribing to private channels diff --git a/pubspec.yaml b/pubspec.yaml index 64b5285..117b595 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pusher_channels_flutter description: Pusher Channels Flutter Plugin -version: 1.0.5 +version: 1.1.0 homepage: https://github.com/pusher/pusher-channels-flutter repository: https://github.com/pusher/pusher-channels-flutter issue_tracker: https://github.com/pusher/pusher-channels-flutter/issues From 83c4e4d3cf3810262f57b2b4fc6f433af5cd8ab3 Mon Sep 17 00:00:00 2001 From: Niek Date: Thu, 16 Jun 2022 16:35:34 +0200 Subject: [PATCH 08/10] Make it 2.0.0 because of breaking change. --- CHANGELOG.md | 2 +- pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f466162..f18e917 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## 1.1.0 +## 2.0.0 * [BREAKING CHANGE] Convert channel member to Map (instead of Set) * [FIXED] Add internal member before calling onMemberAdded callback on channel diff --git a/pubspec.yaml b/pubspec.yaml index 117b595..4c1c797 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: pusher_channels_flutter description: Pusher Channels Flutter Plugin -version: 1.1.0 +version: 2.0.0 homepage: https://github.com/pusher/pusher-channels-flutter repository: https://github.com/pusher/pusher-channels-flutter issue_tracker: https://github.com/pusher/pusher-channels-flutter/issues From eaf9a0e57bd5e1c6eb2f4bab44153fe46631baf1 Mon Sep 17 00:00:00 2001 From: Niek Date: Fri, 17 Jun 2022 08:04:07 +0200 Subject: [PATCH 09/10] fix missing quotes in README.md update some packages --- README.md | 39 ++++++++++++++++++++------------------- example/pubspec.lock | 13 +++---------- pubspec.lock | 13 +++---------- 3 files changed, 26 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index 3ca18bc..2ffa06f 100644 --- a/README.md +++ b/README.md @@ -43,22 +43,22 @@ a minimal application to connect to a channel and send events. - [Web specific installation](#web-specific-installation) - [Initialization](#initialization) - [Configuration](#configuration) - - [`activityTimeout (double)`](#activitytimeout-double) - - [`apiKey (String)`](#apikey-string) - - [`authParams (Map)`](#authparams-map) - - [`authEndpoint (String)`](#authendpoint-string) - - [`cluster (String)`](#cluster-string) - - [`useTLS (bool)`](#usetls-bool) + - [`activityTimeout (double)`](#activitytimeout-double) + - [`apiKey (String)`](#apikey-string) + - [`authParams (Map)`](#authparams-map) + - [`authEndpoint (String)`](#authendpoint-string) + - [`cluster (String)`](#cluster-string) + - [`useTLS (bool)`](#usetls-bool) - [Event Callback parameters](#event-callback-parameters) - - [`onEvent`](#onevent) - - [`onSubscriptionSucceeded`](#onsubscriptionsucceeded) - - [`onSubscriptionError`](#onsubscriptionerror) - - [`onDecryptionFailure`](#ondecryptionfailure) - - [`onMemberAdded`](#onmemberadded) - - [`onMemberRemoved`](#onmemberremoved) - - [`onAuthorizer`](#onauthorizer) - - [`onConnectionStateChange`](#onconnectionstatechange) - - [`onError`](#onerror) + - [`onEvent`](#onevent) + - [`onSubscriptionSucceeded`](#onsubscriptionsucceeded) + - [`onSubscriptionError`](#onsubscriptionerror) + - [`onDecryptionFailure`](#ondecryptionfailure) + - [`onMemberAdded`](#onmemberadded) + - [`onMemberRemoved`](#onmemberremoved) + - [`onAuthorizer`](#onauthorizer) + - [`onConnectionStateChange`](#onconnectionstatechange) + - [`onError`](#onerror) - [Connection handling](#connection-handling) - [Connecting](#connecting) - [Disconnecting](#disconnecting) @@ -77,6 +77,7 @@ a minimal application to connect to a channel and send events. - [Parsing event data](#parsing-event-data) - [Receiving errors](#receiving-errors) - [Triggering events](#triggering-events) + - [Get a channel by name](#get-a-channel-by-name) - [Socket information](#socket-information) - [Communication](#communication) - [Credits](#credits) @@ -199,8 +200,8 @@ await pusher.init( apiKey: API_KEY, cluster: API_CLUSTER, authParams: { - params: { foo: 'bar' }, - headers: { baz: 'boo' } + 'params': { 'foo': 'bar' }, + 'headers': { 'baz': 'boo' } } }); ``` @@ -216,8 +217,8 @@ final pusher = await pusher.init( apiKey: API_KEY, cluster: API_CLUSTER, authParams: { - params: { foo: 'bar' }, - headers: { 'X-CSRF-Token': 'SOME_CSRF_TOKEN' } + 'params': { 'foo': 'bar' }, + 'headers': { 'X-CSRF-Token': 'SOME_CSRF_TOKEN' } } ); ``` diff --git a/example/pubspec.lock b/example/pubspec.lock index 322e9d5..849d784 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -42,7 +42,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" cupertino_icons: dependency: "direct main" description: @@ -56,7 +56,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: @@ -273,13 +273,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.9" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" vector_math: dependency: transitive description: @@ -302,5 +295,5 @@ packages: source: hosted version: "0.2.0+1" sdks: - dart: ">=2.16.0-100.0.dev <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=2.5.0" diff --git a/pubspec.lock b/pubspec.lock index 36076da..9c631a6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -42,14 +42,14 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" flutter: dependency: "direct main" description: flutter @@ -161,13 +161,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.9" - typed_data: - dependency: transitive - description: - name: typed_data - url: "https://pub.dartlang.org" - source: hosted - version: "1.3.0" vector_math: dependency: transitive description: @@ -176,5 +169,5 @@ packages: source: hosted version: "2.1.2" sdks: - dart: ">=2.16.0-100.0.dev <3.0.0" + dart: ">=2.17.0-0 <3.0.0" flutter: ">=1.20.0" From f4b00dbf391f4dd5e1d4eeab29761bae52e5fe80 Mon Sep 17 00:00:00 2001 From: Niek Date: Wed, 22 Jun 2022 08:56:31 +0200 Subject: [PATCH 10/10] onAuthorizer should work on release mode now. --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 2ffa06f..385270a 100644 --- a/README.md +++ b/README.md @@ -307,8 +307,6 @@ Called when a member is removed to the presence channel. #### `onAuthorizer` -> :warning: Currently on web release/profile mode this doesn't work, we're still investigating this. - When passing the `onAuthorizer()` callback to the `init()` method, this callback is called to request auth information. For more information on how to generate the correct information, please look here: https://pusher.com/docs/channels/library_auth_reference/auth-signatures/