Skip to content
This repository was archived by the owner on Feb 24, 2025. It is now read-only.

rev to 3.0.0 #319

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 16 additions & 35 deletions .github/workflows/test-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,31 @@ env:
PUB_ENVIRONMENT: bot.github

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
# Check formatting, static analysis, and run tests.
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [dev]
sdk: [3.2, stable, dev]
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: dart analyze
if: always() && steps.install.outcome == 'success'
- run: dart pub get
- run: dart analyze --fatal-infos
- run: dart format --output=none --set-exit-if-changed .
if: ${{ matrix.sdk == 'stable' }}
- run: dart test --platform vm
- run: dart test --platform chrome
- run: dart test --platform chrome --compiler dart2wasm

test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
sdk: [3.2.0, dev]
# Run analysis against the oldest supported pub constraints.
downgrade:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: dart-lang/setup-dart@b64355ae6ca0b5d484f0106a033dd1388965d06d
with:
sdk: ${{ matrix.sdk }}
- id: install
name: Install dependencies
run: dart pub get
- name: Run VM tests
run: dart test --platform vm
if: always() && steps.install.outcome == 'success'
- name: Run Chrome tests
run: dart test --platform chrome
if: always() && steps.install.outcome == 'success'
- name: Run Chrome tests - wasm
run: dart test --platform chrome --compiler dart2wasm
if: always() && steps.install.outcome == 'success' && matrix.sdk == 'dev'
- run: dart pub downgrade
- run: dart analyze --fatal-infos
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
## 2.4.2
## 3.0.0

- Update the underlying web implementation from using `dart:html` to using
`package:web` (this had also been published as `2.4.1`).

## 2.4.2 (retracted)

- Allow `web: '>=0.3.0 <0.5.0'`

## 2.4.1
Expand Down
33 changes: 21 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
[![CI](https://github.com/dart-lang/web_socket_channel/actions/workflows/test-package.yml/badge.svg?branch=master)](https://github.com/dart-lang/web_socket_channel/actions/workflows/test-package.yml)
[![pub package](https://img.shields.io/pub/v/web_socket_channel.svg)](https://pub.dev/packages/web_socket_channel)
[![package publisher](https://img.shields.io/pub/publisher/web_socket_channel.svg)](https://pub.dev/packages/web_socket_channel/publisher)

The `web_socket_channel` package provides [`StreamChannel`][stream_channel]
wrappers for WebSocket connections. It provides a cross-platform
[`WebSocketChannel`][WebSocketChannel] API, a cross-platform implementation of
that API that communicates over an underlying [`StreamChannel`][stream_channel],
[an implementation][IOWebSocketChannel] that wraps `dart:io`'s `WebSocket`
class, and [a similar implementation][HtmlWebSocketChannel] that wraps
`dart:html`'s.
`package:web_socket_channel` provides cross-platform
[`StreamChannel`][stream_channel] wrappers for WebSocket connections.

## Docs and Usage

This package provides:

- a cross-platform [`WebSocketChannel`][WebSocketChannel] API
- a cross-platform implementation of that API that communicates over an
underlying [`StreamChannel`][stream_channel]
- [an implementation][IOWebSocketChannel] that wraps the `dart:io` `WebSocket`
class
- and [a similar implementation][HtmlWebSocketChannel] that wraps the browser's
web socket implementation

[stream_channel]: https://pub.dev/packages/stream_channel
[WebSocketChannel]: https://pub.dev/documentation/web_socket_channel/latest/web_socket_channel/WebSocketChannel-class.html
[IOWebSocketChannel]: https://pub.dev/documentation/web_socket_channel/latest/web_socket_channel.io/IOWebSocketChannel-class.html
[HtmlWebSocketChannel]: https://pub.dev/documentation/web_socket_channel/latest/web_socket_channel.html/HtmlWebSocketChannel-class.html

It also provides constants for the WebSocket protocol's pre-defined status codes
in the [`status.dart` library][status]. It's strongly recommended that users
import this library with the prefix `status`.
in the [`status.dart` library][status] (it's recommended that users import this
library with the prefix `status`).

[status]: https://pub.dev/documentation/web_socket_channel/latest/status/status-library.html

```dart
import 'package:web_socket_channel/web_socket_channel.dart';
import 'package:web_socket_channel/status.dart' as status;
import 'package:web_socket_channel/web_socket_channel.dart';

main() async {
void main() async {
final wsUrl = Uri.parse('ws://example.com');
final channel = WebSocketChannel.connect(wsUrl);

Expand All @@ -36,7 +45,7 @@ main() async {
}
```

## `WebSocketChannel`
## The `WebSocketChannel` class

The [`WebSocketChannel`][WebSocketChannel] class's most important role is as the
interface for WebSocket stream channels across all implementations and all
Expand Down
4 changes: 2 additions & 2 deletions lib/html.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import 'src/channel.dart';
import 'src/exception.dart';
import 'src/web_helpers.dart';

/// A [WebSocketChannel] that communicates using a `dart:html` [WebSocket].
/// A [WebSocketChannel] that communicates using a browser [WebSocket].
class HtmlWebSocketChannel extends StreamChannelMixin
implements WebSocketChannel {
/// The underlying `dart:html` [WebSocket].
/// The underlying browser [WebSocket].
final WebSocket innerWebSocket;

@override
Expand Down
6 changes: 3 additions & 3 deletions lib/src/channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import 'exception.dart';

/// A [StreamChannel] that communicates over a WebSocket.
///
/// This is implemented by classes that use `dart:io` and `dart:html`.
/// The [WebSocketChannel.new] constructor can also be used on any platform to
/// This is implemented by classes that use `dart:io` and `package:web`. The
/// [WebSocketChannel.new] constructor can also be used on any platform to
/// connect to use the WebSocket protocol over a pre-existing channel.
///
/// All implementations emit [WebSocketChannelException]s. These exceptions wrap
Expand Down Expand Up @@ -105,7 +105,7 @@ class WebSocketChannel extends StreamChannelMixin {
/// Creates a new WebSocket handling messaging across an existing [channel].
///
/// This is a cross-platform constructor; it doesn't use either `dart:io` or
/// `dart:html`. It's also HTTP-API-agnostic, which means that the initial
/// `package:web`. It's also HTTP-API-agnostic, which means that the initial
/// [WebSocket handshake][] must have already been completed on the socket
/// before this is called.
///
Expand Down
10 changes: 3 additions & 7 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
name: web_socket_channel
version: 2.4.2

description: >-
StreamChannel wrappers for WebSockets. Provides a cross-platform
WebSocketChannel API, a cross-platform implementation of that API that
communicates over an underlying StreamChannel.
version: 3.0.0
description: Cross-platform StreamChannel wrappers for WebSocket connections.
repository: https://github.com/dart-lang/web_socket_channel

environment:
Expand All @@ -14,7 +10,7 @@ dependencies:
async: ^2.5.0
crypto: ^3.0.0
stream_channel: ^2.1.0
web: '>=0.3.0 <0.5.0'
web: ^0.4.0

dev_dependencies:
dart_flutter_team_lints: ^2.0.0
Expand Down