diff --git a/api/pubspec.yaml b/api/pubspec.yaml index 464ca39b8a91..7b6b3cadae5e 100644 --- a/api/pubspec.yaml +++ b/api/pubspec.yaml @@ -1,6 +1,6 @@ name: butterfly_api description: The Linwood Butterfly API -version: 2.3.0-beta.0 +version: 2.2.2-rc.0 publish_to: none environment: diff --git a/app/AppImageBuilder.yml b/app/AppImageBuilder.yml index fd12b7a0ee9e..2c592615a3f4 100644 --- a/app/AppImageBuilder.yml +++ b/app/AppImageBuilder.yml @@ -14,7 +14,7 @@ AppDir: id: dev.linwood.butterfly name: Linwood Butterfly icon: dev.linwood.butterfly - version: 2.3.0-beta.0 + version: 2.2.2-rc.0 exec: butterfly exec_args: $@ apt: diff --git a/app/android/Gemfile.lock b/app/android/Gemfile.lock index 33a65e12c79a..60bc708956ef 100644 --- a/app/android/Gemfile.lock +++ b/app/android/Gemfile.lock @@ -10,7 +10,7 @@ GEM artifactory (3.0.17) atomos (0.1.3) aws-eventstream (1.3.0) - aws-partitions (1.994.0) + aws-partitions (1.996.0) aws-sdk-core (3.211.0) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.992.0) @@ -152,7 +152,7 @@ GEM domain_name (~> 0.5) httpclient (2.8.3) jmespath (1.6.2) - json (2.7.3) + json (2.7.4) jwt (2.9.3) base64 mini_magick (4.13.2) @@ -222,4 +222,4 @@ DEPENDENCIES screengrab BUNDLED WITH - 2.5.22 + 2.5.21 diff --git a/app/android/settings.gradle b/app/android/settings.gradle index 4b81897f6845..3a2c549d8cc6 100644 --- a/app/android/settings.gradle +++ b/app/android/settings.gradle @@ -18,7 +18,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" - id "com.android.application" version '8.7.0' apply false + id "com.android.application" version '8.7.1' apply false id "org.jetbrains.kotlin.android" version "1.9.22" apply false } diff --git a/app/lib/cubits/current_index.dart b/app/lib/cubits/current_index.dart index f1016d61f711..5ddc4bc8dbae 100644 --- a/app/lib/cubits/current_index.dart +++ b/app/lib/cubits/current_index.dart @@ -191,7 +191,7 @@ class CurrentIndexCubit extends Cubit { } Future updateNetworkingState(DocumentBloc bloc, - [Map? current]) async { + [Map? current]) async { final blocState = bloc.state; if (blocState is! DocumentLoadSuccess) return; final users = (current ?? state.networkingService.users).values.toList(); diff --git a/app/lib/dialogs/collaboration/view.dart b/app/lib/dialogs/collaboration/view.dart index 878bd1c6d0ce..95e79e047acd 100644 --- a/app/lib/dialogs/collaboration/view.dart +++ b/app/lib/dialogs/collaboration/view.dart @@ -24,7 +24,7 @@ class ViewCollaborationDialog extends StatelessWidget { onTap: () => saveToClipboard(context, address), ), const Divider(), - StreamBuilder>( + StreamBuilder>( stream: service.connectionsStream, builder: (context, snapshot) { final connections = snapshot.data ?? {}; diff --git a/app/lib/services/network.dart b/app/lib/services/network.dart index 82b9e034f91c..6963074b095b 100644 --- a/app/lib/services/network.dart +++ b/app/lib/services/network.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:convert'; import 'dart:io'; import 'dart:math'; @@ -34,7 +35,7 @@ enum NetworkingType { const kDefaultPort = 28005; const kTimeout = Duration(seconds: 10); -typedef NetworkingState = (NetworkerBase, RpcPlugin); +typedef NetworkingState = (NetworkerBase, RpcNetworkerPipe); @freezed class NetworkingInitMessage with _$NetworkingInitMessage { @@ -55,23 +56,29 @@ class NetworkingUser with _$NetworkingUser { _$NetworkingUserFromJson(json); } +enum NetworkEvent { + event, + init, + connections, + user, +} + class NetworkingService { DocumentBloc? _bloc; final BehaviorSubject _subject = BehaviorSubject.seeded(null); - final BehaviorSubject> _connections = - BehaviorSubject.seeded({}); - final BehaviorSubject> _users = + final BehaviorSubject> _connections = BehaviorSubject.seeded({}); + final BehaviorSubject> _users = BehaviorSubject.seeded({}); Stream get stream => _subject.stream; NetworkingState? get state => _subject.value; - Stream> get connectionsStream => _connections.stream; - Set get connections => _connections.value; + Stream> get connectionsStream => _connections.stream; + Set get connections => _connections.value; - Stream> get usersStream => _users.stream; - Map get users => _users.value; + Stream> get usersStream => _users.stream; + Map get users => _users.value; NetworkingService(); @@ -83,30 +90,30 @@ class NetworkingService { Future createSocketServer([String? address, int? port]) async { closeNetworking(); - final httpServer = await HttpServer.bind( - address != null - ? InternetAddress(address, type: InternetAddressType.any) - : InternetAddress.anyIPv4, - port ?? kDefaultPort, - ); - final server = NetworkerSocketServer(httpServer); - final rpc = RpcNetworkerServerPlugin(); + final server = NetworkerSocketServer( + address != null + ? InternetAddress(address, type: InternetAddressType.any) + : InternetAddress.anyIPv4, + port ?? kDefaultPort); + final rpc = RpcServerNetworkerPipe(); _setupRpc(rpc, server); void sendConnections() { - rpc.sendMessage(RpcRequest( - kNetworkerConnectionIdAny, 'connections', server.connectionIds)); + rpc.callFunction(NetworkEvent.connections.index, + Uint8List.fromList(jsonEncode(connections.toList()).codeUnits)); } - server.connect.listen((event) { + server.clientConnect.listen((event) { final state = _bloc?.state; - rpc.sendMessage( - RpcRequest(event, 'init', NetworkingInitMessage(state?.saveBytes()))); + rpc.callFunction( + NetworkEvent.init.index, + Uint8List.fromList( + jsonEncode(NetworkingInitMessage(state?.saveBytes())).codeUnits)); sendConnections(); }); - server.disconnect.listen((event) { + server.clientDisconnect.listen((event) { sendConnections(); }); - server.addPlugin(rpc); + server.connect(rpc); _subject.add((server, rpc)); } @@ -116,17 +123,19 @@ class NetworkingService { uri = uri.replace(port: kDefaultPort); } final client = NetworkerSocketClient(uri); - final rpc = RpcNetworkerPlugin(); + final rpc = RpcClientNetworkerPipe(); _setupRpc(rpc, client); final completer = Completer(); - rpc.addFunction( - 'init', - RpcFunction(RpcType.authority, (message) { - final init = NetworkingInitMessage.fromJson(message.message); - completer.complete( - init.data == null ? null : Uint8List.fromList(init.data!)); - })); - client.addPlugin(RawJsonNetworkerPlugin()..addPlugin(rpc)); + rpc + .registerFunction(NetworkEvent.init.index, + mode: RpcNetworkerMode.authority) + .connect(RawJsonNetworkerPlugin() + ..read.listen((message) { + final init = NetworkingInitMessage.fromJson(message.data); + completer.complete( + init.data == null ? null : Uint8List.fromList(init.data!)); + })); + client.connect(rpc); _subject.add((client, rpc)); return completer.future.timeout(kTimeout); } @@ -138,43 +147,53 @@ class NetworkingService { _users.add({}); } - void _setupRpc(RpcPlugin rpc, NetworkerBase networker) { - rpc.addFunction( - 'event', - RpcFunction(RpcType.any, (message) { - final event = DocumentEvent.fromJson(message.message); - onMessage(event); - })); - rpc.addFunction( - 'connections', - RpcFunction(RpcType.authority, (message) { - final ids = Set.from(message.message); - _connections.add(ids); - _users.add(Map.from(_users.value) - ..removeWhere((key, value) => !ids.contains(key))); - }, true)); - rpc.addFunction( - 'user', - RpcFunction(RpcType.any, (message) { - final user = NetworkingUser.fromJson(message.message); - final users = Map.from(_users.value) - ..[message.client] = user; - _users.add(users); - _bloc?.state.currentIndexCubit?.updateNetworkingState(_bloc!, users); - })); + void _setupRpc(RpcNetworkerPipe rpc, NetworkerBase networker) { + rpc + .registerFunction(NetworkEvent.event.index, mode: RpcNetworkerMode.any) + .connect(RawJsonNetworkerPlugin() + ..read.listen((message) { + final event = DocumentEvent.fromJson(message.data); + onMessage(event); + })); + rpc + .registerFunction( + NetworkEvent.connections.index, + mode: RpcNetworkerMode.authority, + ) + .connect(RawJsonNetworkerPlugin() + ..read.listen((message) { + final ids = Set.from(message.data); + _connections.add(ids); + _users.add(Map.from(_users.value) + ..removeWhere((key, value) => !ids.contains(key))); + })); + rpc + .registerFunction( + NetworkEvent.user.index, + mode: RpcNetworkerMode.any, + ) + .connect(RawJsonNetworkerPlugin() + ..read.listen((message) { + final user = NetworkingUser.fromJson(message.data); + final users = Map.from(_users.value) + ..[message.channel] = user; + _users.add(users); + _bloc?.state.currentIndexCubit + ?.updateNetworkingState(_bloc!, users); + })); } void sendUser(NetworkingUser user) { - state?.$2.sendMessage( - RpcRequest(kNetworkerConnectionIdAny, 'user', user.toJson())); + state?.$2.callFunction(NetworkEvent.user.index, + Uint8List.fromList(jsonEncode(user.toJson()).codeUnits)); } bool _externalEvent = false; void onEvent(DocumentEvent event) { if (!event.shouldSync() || _externalEvent) return; - state?.$2.sendMessage( - RpcRequest(kNetworkerConnectionIdAny, 'event', event.toJson())); + state?.$2.callFunction(NetworkEvent.event.index, + Uint8List.fromList(jsonEncode(event.toJson()).codeUnits)); } void onMessage(DocumentEvent event) { diff --git a/app/linux/debian/DEBIAN/control b/app/linux/debian/DEBIAN/control index cde1c9002ab4..2896be921f62 100644 --- a/app/linux/debian/DEBIAN/control +++ b/app/linux/debian/DEBIAN/control @@ -1,5 +1,5 @@ Package: linwood-butterfly -Version: 2.3.0-beta.0 +Version: 2.2.2-rc.0 Section: base Priority: optional Homepage: https://github.com/LinwoodDev/butterfly diff --git a/app/pubspec.lock b/app/pubspec.lock index afa1c65c3351..d21cf2c6d5a4 100644 --- a/app/pubspec.lock +++ b/app/pubspec.lock @@ -172,7 +172,7 @@ packages: path: "../api" relative: true source: path - version: "2.3.0-beta.0" + version: "2.2.2-rc.0" camera: dependency: "direct main" description: @@ -824,7 +824,7 @@ packages: path: "packages/lw_file_system" ref: "71ebfd76ef24a9b21b2e909d5802e9fb01357317" resolved-ref: "71ebfd76ef24a9b21b2e909d5802e9fb01357317" - url: "https://github.com/LinwoodDev/dart_pkgs.git" + url: "https://github.com/LinwoodDev/dart_pkgs" source: git version: "1.0.0" lw_file_system_api: @@ -842,7 +842,7 @@ packages: path: "packages/lw_sysapi" ref: "21808e89bb6239f0b39367d0c00b0b14f5273992" resolved-ref: "21808e89bb6239f0b39367d0c00b0b14f5273992" - url: "https://github.com/LinwoodDev/dart_pkgs.git" + url: "https://github.com/LinwoodDev/dart_pkgs" source: git version: "0.0.1" macros: @@ -883,7 +883,7 @@ packages: path: "packages/material_leap" ref: "18cd4cd6cb9e8663036eb59bb431f8ac65827788" resolved-ref: "18cd4cd6cb9e8663036eb59bb431f8ac65827788" - url: "https://github.com/LinwoodDev/dart_pkgs.git" + url: "https://github.com/LinwoodDev/dart_pkgs" source: git version: "0.0.1" meta: @@ -914,18 +914,18 @@ packages: dependency: "direct main" description: path: "packages/networker/networker" - ref: "6617b9bbfb481ef59b1a6921f1676bb90d73ecf9" - resolved-ref: "6617b9bbfb481ef59b1a6921f1676bb90d73ecf9" - url: "https://github.com/LinwoodDev/dart_pkgs.git" + ref: "5a3658cad80fcb8594b8be6f84460e77607eb959" + resolved-ref: "5a3658cad80fcb8594b8be6f84460e77607eb959" + url: "https://github.com/LinwoodDev/dart_pkgs" source: git version: "1.0.0" networker_socket: dependency: "direct main" description: path: "packages/networker/networker_socket" - ref: fce8dc67ec282861bf629e32c404c52921f54bbd - resolved-ref: fce8dc67ec282861bf629e32c404c52921f54bbd - url: "https://github.com/LinwoodDev/dart_pkgs.git" + ref: "40b8553ab86ab4f06d9f689268a65d65ed936fda" + resolved-ref: "40b8553ab86ab4f06d9f689268a65d65ed936fda" + url: "https://github.com/LinwoodDev/dart_pkgs" source: git version: "1.0.0" nm: @@ -1640,4 +1640,4 @@ packages: version: "3.1.2" sdks: dart: ">=3.5.0 <4.0.0" - flutter: ">=3.24.3" + flutter: ">=3.24.4" diff --git a/app/pubspec.yaml b/app/pubspec.yaml index a72c69855ab1..fb7a0e9d9523 100644 --- a/app/pubspec.yaml +++ b/app/pubspec.yaml @@ -13,11 +13,11 @@ publish_to: none # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 2.3.0-beta.0+120 +version: 2.2.2-rc.0+120 environment: sdk: ">=3.4.0 <4.0.0" - flutter: 3.24.3 + flutter: 3.24.4 dependencies: flutter: @@ -68,27 +68,27 @@ dependencies: ref: 6228363ff19e95aa16055dd493533d4c01fa2209 material_leap: git: - url: https://github.com/LinwoodDev/dart_pkgs.git + url: https://github.com/LinwoodDev/dart_pkgs ref: 18cd4cd6cb9e8663036eb59bb431f8ac65827788 path: packages/material_leap lw_sysapi: git: - url: https://github.com/LinwoodDev/dart_pkgs.git + url: https://github.com/LinwoodDev/dart_pkgs ref: 21808e89bb6239f0b39367d0c00b0b14f5273992 path: packages/lw_sysapi networker: git: - url: https://github.com/LinwoodDev/dart_pkgs.git - ref: 6617b9bbfb481ef59b1a6921f1676bb90d73ecf9 + url: https://github.com/LinwoodDev/dart_pkgs + ref: 5a3658cad80fcb8594b8be6f84460e77607eb959 path: packages/networker/networker networker_socket: git: - url: https://github.com/LinwoodDev/dart_pkgs.git - ref: fce8dc67ec282861bf629e32c404c52921f54bbd + url: https://github.com/LinwoodDev/dart_pkgs + ref: 40b8553ab86ab4f06d9f689268a65d65ed936fda path: packages/networker/networker_socket lw_file_system: git: - url: https://github.com/LinwoodDev/dart_pkgs.git + url: https://github.com/LinwoodDev/dart_pkgs ref: 71ebfd76ef24a9b21b2e909d5802e9fb01357317 path: packages/lw_file_system flutter_localized_locales: ^2.0.5 diff --git a/metadata/en-US/changelogs/120.txt b/metadata/en-US/changelogs/120.txt index 5969e16dfaa2..4e204679049f 100644 --- a/metadata/en-US/changelogs/120.txt +++ b/metadata/en-US/changelogs/120.txt @@ -10,5 +10,7 @@ * Fix property view logic * Fix property view ui padding * Fix archive importing +* Upgrade networking stack for collaboration experiment +* Update flutter and agp -Read more here: https://linwood.dev/butterfly/2.3.0-beta.0 \ No newline at end of file +Read more here: https://linwood.dev/butterfly/2.2.2-rc.0 \ No newline at end of file