Skip to content

Commit

Permalink
Merge pull request #1266 from dart-lang/merge-stream_channel-package
Browse files Browse the repository at this point in the history
Merge `package:stream_channel`
  • Loading branch information
mosuem authored Dec 20, 2024
2 parents 07648c8 + 4c2db7b commit 3a4e0ba
Show file tree
Hide file tree
Showing 33 changed files with 3,200 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/stream_channel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:stream_channel"
about: "Create a bug or file a feature request against package:stream_channel."
labels: "package:stream_channel"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@
- changed-files:
- any-glob-to-any-file: 'pkgs/stack_trace/**'

'package:stream_channel':
- changed-files:
- any-glob-to-any-file: 'pkgs/stream_channel/**'

'package:stream_transform':
- changed-files:
- any-glob-to-any-file: 'pkgs/stream_transform/**'
Expand Down
74 changes: 74 additions & 0 deletions .github/workflows/stream_channel.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: package:stream_channel

on:
# Run on PRs and pushes to the default branch.
push:
branches: [ main ]
paths:
- '.github/workflows/stream_channel.yaml'
- 'pkgs/stream_channel/**'
pull_request:
branches: [ main ]
paths:
- '.github/workflows/stream_channel.yaml'
- 'pkgs/stream_channel/**'
schedule:
- cron: "0 0 * * 0"

env:
PUB_ENVIRONMENT: bot.github

defaults:
run:
working-directory: pkgs/stream_channel/

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sdk: [dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
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 --fatal-infos
if: always() && steps.install.outcome == 'success'

# Run tests on a matrix consisting of two dimensions:
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
# 2. release channel: dev
test:
needs: analyze
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [3.3, dev]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
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'
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ don't naturally belong to other topic monorepos (like
| [source_span](pkgs/source_span/) | Provides a standard representation for source code locations and spans. | [![package issues](https://img.shields.io/badge/package:source_span-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asource_span) | [![pub package](https://img.shields.io/pub/v/source_span.svg)](https://pub.dev/packages/source_span) |
| [sse](pkgs/sse/) | Provides client and server functionality for setting up bi-directional communication through Server Sent Events (SSE) and corresponding POST requests. | [![package issues](https://img.shields.io/badge/package:sse-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Asse) | [![pub package](https://img.shields.io/pub/v/sse.svg)](https://pub.dev/packages/sse) |
| [stack_trace](pkgs/stack_trace/) | A package for manipulating stack traces and printing them readably. | [![package issues](https://img.shields.io/badge/package:stack_trace-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Astack_trace) | [![pub package](https://img.shields.io/pub/v/stack_trace.svg)](https://pub.dev/packages/stack_trace) |
| [stream_channel](pkgs/stream_channel/) | An abstraction for two-way communication channels based on the Dart Stream class. | [![package issues](https://img.shields.io/badge/package:stream_channel-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Astream_channel) | [![pub package](https://img.shields.io/pub/v/stream_channel.svg)](https://pub.dev/packages/stream_channel) |
| [stream_transform](pkgs/stream_transform/) | A collection of utilities to transform and manipulate streams. | [![package issues](https://img.shields.io/badge/package:stream_transform-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Astream_transform) | [![pub package](https://img.shields.io/pub/v/stream_transform.svg)](https://pub.dev/packages/stream_transform) |
| [term_glyph](pkgs/term_glyph/) | Useful Unicode glyphs and ASCII substitutes. | [![package issues](https://img.shields.io/badge/package:term_glyph-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Aterm_glyph) | [![pub package](https://img.shields.io/pub/v/term_glyph.svg)](https://pub.dev/packages/term_glyph) |
| [test_reflective_loader](pkgs/test_reflective_loader/) | Support for discovering tests and test suites using reflection. | [![package issues](https://img.shields.io/badge/package:test_reflective_loader-4774bc)](https://github.com/dart-lang/tools/issues?q=is%3Aissue+is%3Aopen+label%3Apackage%3Atest_reflective_loader) | [![pub package](https://img.shields.io/pub/v/test_reflective_loader.svg)](https://pub.dev/packages/test_reflective_loader) |
Expand Down
10 changes: 10 additions & 0 deletions pkgs/stream_channel/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.buildlog
.dart_tool/
.DS_Store
.idea
.pub/
.settings/
build/
packages
.packages
pubspec.lock
6 changes: 6 additions & 0 deletions pkgs/stream_channel/AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Below is a list of people and organizations that have contributed
# to the project. Names should be added to the list like so:
#
# Name/Organization <email address>

Google Inc.
158 changes: 158 additions & 0 deletions pkgs/stream_channel/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
## 2.1.3

* Require Dart 3.3
* Move to `dart-lang/tools` monorepo.

## 2.1.2

* Require Dart 2.19
* Add an example.
* Fix a race condition in `IsolateChannel.connectReceive()` where the channel
could hang forever if its sink was closed before the connection was established.

## 2.1.1

* Require Dart 2.14
* Populate the pubspec `repository` field.
* Handle multichannel messages where the ID element is a `double` at runtime
instead of an `int`. When reading an array with `dart2wasm` numbers within the
array are parsed as `double`.

## 2.1.0

* Stable release for null safety.

## 2.0.0

**Breaking changes**

* `IsolateChannel` requires a separate import
`package:stram_channel/isolate_channel.dart`.
`package:stream_channel/stream_channel.dart` will now not trigger any platform
concerns due to importing `dart:isolate`.
* Remove `JsonDocumentTransformer` class. The `jsonDocument` top level is still
available.
* Remove `StreamChannelTransformer.typed`. Use `.cast` on the transformed
channel instead.
* Change `Future<dynamic>` returns to `Future<void>`.

## 1.7.0

* Make `IsolateChannel` available through
`package:stream_channel/isolate_channel.dart`. This will be the required
import in the next release.
* Require `2.0.0` or newer SDK.
* Internal style changes.

## 1.6.8

* Set max SDK version to `<3.0.0`, and adjust other dependencies.

## 1.6.7+1

* Fix Dart 2 runtime types in `IsolateChannel`.

## 1.6.7

* Update SDK version to 2.0.0-dev.17.0.
* Add a type argument to `MultiChannel`.

## 1.6.6

* Fix a Dart 2 issue with inner stream transformation in `GuaranteeChannel`.

* Fix a Dart 2 issue with `StreamChannelTransformer.fromCodec()`.

## 1.6.5

* Fix an issue with `JsonDocumentTransformer.bind` where it created an internal
stream channel which didn't get a properly inferred type for its `sink`.

## 1.6.4

* Fix a race condition in `MultiChannel` where messages from a remote virtual
channel could get dropped if the corresponding local channel wasn't registered
quickly enough.

## 1.6.3

* Use `pumpEventQueue()` from test.

## 1.6.2

* Declare support for `async` 2.0.0.

## 1.6.1

* Fix the type of `StreamChannel.transform()`. This previously inverted the
generic parameters, so it only really worked with transformers where both
generic types were identical.

## 1.6.0

* `Disconnector.disconnect()` now returns a future that completes when all the
inner `StreamSink.close()` futures have completed.

## 1.5.0

* Add `new StreamChannel.withCloseGuarantee()` to provide the specific guarantee
that closing the sink causes the stream to close before it emits any more
events. This is the only guarantee that isn't automatically preserved when
transforming a channel.

* `StreamChannelTransformer`s provided by the `stream_channel` package now
properly provide the guarantee that closing the sink causes the stream to
close before it emits any more events

## 1.4.0

* Add `StreamChannel.cast()`, which soundly coerces the generic type of a
channel.

* Add `StreamChannelTransformer.typed()`, which soundly coerces the generic type
of a transformer.

## 1.3.2

* Fix all strong-mode errors and warnings.

## 1.3.1

* Make `IsolateChannel` slightly more efficient.

* Make `MultiChannel` follow the stream channel rules.

## 1.3.0

* Add `Disconnector`, a transformer that allows the caller to disconnect the
transformed channel.

## 1.2.0

* Add `new StreamChannel.withGuarantees()`, which creates a channel with extra
wrapping to ensure that it obeys the stream channel guarantees.

* Add `StreamChannelController`, which can be used to create custom
`StreamChannel` objects.

## 1.1.1

* Fix the type annotation for `StreamChannel.transform()`'s parameter.

## 1.1.0

* Add `StreamChannel.transformStream()`, `StreamChannel.transformSink()`,
`StreamChannel.changeStream()`, and `StreamChannel.changeSink()` to support
changing only the stream or only the sink of a channel.

* Be more explicit about `JsonDocumentTransformer`'s error-handling behavior.

## 1.0.1

* Fix `MultiChannel`'s constructor to take a `StreamChannel`. This is
technically a breaking change, but since 1.0.0 was only released an hour ago,
we're treating it as a bug fix.

## 1.0.0

* Initial version
27 changes: 27 additions & 0 deletions pkgs/stream_channel/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2015, the Dart project authors.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:

* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google LLC nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20 changes: 20 additions & 0 deletions pkgs/stream_channel/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[![Build Status](https://github.com/dart-lang/tools/actions/workflows/stream_channel.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/stream_channel.yaml)
[![pub package](https://img.shields.io/pub/v/stream_channel.svg)](https://pub.dev/packages/stream_channel)
[![package publisher](https://img.shields.io/pub/publisher/stream_channel.svg)](https://pub.dev/packages/stream_channel/publisher)

This package exposes the `StreamChannel` interface, which represents a two-way
communication channel. Each `StreamChannel` exposes a `Stream` for receiving
data and a `StreamSink` for sending it.

`StreamChannel` helps abstract communication logic away from the underlying
protocol. For example, the [`test`][test] package re-uses its test suite
communication protocol for both WebSocket connections to browser suites and
Isolate connections to VM tests.

[test]: https://pub.dev/packages/test

This package also contains utilities for dealing with `StreamChannel`s and with
two-way communications in general. For documentation of these utilities, see
[the API docs][api].

[api]: https://pub.dev/documentation/stream_channel/latest/
5 changes: 5 additions & 0 deletions pkgs/stream_channel/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true
Loading

0 comments on commit 3a4e0ba

Please sign in to comment.