Skip to content

Commit

Permalink
Require Dart 3.3 and the latest pkg:web (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevmoo authored Feb 15, 2024
1 parent 1c4a923 commit 3db86bc
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk: [3.2, dev]
sdk: [3.3, dev]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.4.4

* Require Dart `^3.3`
* Require `package:web` `^0.5.0`.

## 2.4.3

- `HtmlWebSocketChannel`: Relax the type of the websocket parameter to the
Expand Down
11 changes: 5 additions & 6 deletions lib/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import 'dart:typed_data';

import 'package:async/async.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:web/helpers.dart';
import 'package:web/web.dart';

import 'src/channel.dart';
import 'src/exception.dart';
import 'src/web_helpers.dart';

/// A [WebSocketChannel] that communicates using a `dart:html` [WebSocket].
class HtmlWebSocketChannel extends StreamChannelMixin
Expand Down Expand Up @@ -100,15 +99,15 @@ class HtmlWebSocketChannel extends StreamChannelMixin
}
// The socket API guarantees that only a single open event will be
// emitted.
innerWebSocket.onOpenX.first.then((_) {
innerWebSocket.onOpen.first.then((_) {
_readyCompleter.complete();
_listen();
});
}

// The socket API guarantees that only a single error event will be emitted,
// and that once it is no open or message events will be emitted.
innerWebSocket.onErrorX.first.then((_) {
innerWebSocket.onError.first.then((_) {
// Unfortunately, the underlying WebSocket API doesn't expose any
// specific information about the error itself.
final error = WebSocketChannelException('WebSocket connection failed.');
Expand All @@ -119,11 +118,11 @@ class HtmlWebSocketChannel extends StreamChannelMixin
_controller.local.sink.close();
});

innerWebSocket.onMessageX.listen(_innerListen);
innerWebSocket.onMessage.listen(_innerListen);

// The socket API guarantees that only a single error event will be emitted,
// and that once it is no other events will be emitted.
innerWebSocket.onCloseX.first.then((event) {
innerWebSocket.onClose.first.then((event) {
_closeCode = event.code;
_closeReason = event.reason;
_controller.local.sink.close();
Expand Down
17 changes: 0 additions & 17 deletions lib/src/web_helpers.dart

This file was deleted.

6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: web_socket_channel
version: 2.4.3
version: 2.4.4
description: >-
StreamChannel wrappers for WebSockets. Provides a cross-platform
WebSocketChannel API, a cross-platform implementation of that API that
communicates over an underlying StreamChannel.
repository: https://github.com/dart-lang/web_socket_channel

environment:
sdk: ^3.2.0
sdk: ^3.3.0

dependencies:
async: ^2.5.0
crypto: ^3.0.0
stream_channel: ^2.1.0
web: ^0.4.0
web: ^0.5.0

dev_dependencies:
dart_flutter_team_lints: ^2.0.0
Expand Down
5 changes: 2 additions & 3 deletions test/html_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ import 'dart:typed_data';
import 'package:async/async.dart';
import 'package:stream_channel/stream_channel.dart';
import 'package:test/test.dart';
import 'package:web/helpers.dart' hide BinaryType;
import 'package:web/web.dart' hide BinaryType;
import 'package:web_socket_channel/html.dart';
import 'package:web_socket_channel/src/web_helpers.dart';
import 'package:web_socket_channel/web_socket_channel.dart';

extension on StreamChannel {
Expand Down Expand Up @@ -70,7 +69,7 @@ void main() {

test('communicates using an existing open WebSocket', () async {
final webSocket = WebSocket('ws://localhost:$port');
await webSocket.onOpenX.first;
await webSocket.onOpen.first;

final channel = HtmlWebSocketChannel(webSocket);

Expand Down

0 comments on commit 3db86bc

Please sign in to comment.