Skip to content

Commit 3a4e0ba

Browse files
authored
Merge pull request #1266 from dart-lang/merge-stream_channel-package
Merge `package:stream_channel`
2 parents 07648c8 + 4c2db7b commit 3a4e0ba

33 files changed

+3200
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:stream_channel"
3+
about: "Create a bug or file a feature request against package:stream_channel."
4+
labels: "package:stream_channel"
5+
---

.github/labeler.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@
116116
- changed-files:
117117
- any-glob-to-any-file: 'pkgs/stack_trace/**'
118118

119+
'package:stream_channel':
120+
- changed-files:
121+
- any-glob-to-any-file: 'pkgs/stream_channel/**'
122+
119123
'package:stream_transform':
120124
- changed-files:
121125
- any-glob-to-any-file: 'pkgs/stream_transform/**'

.github/workflows/stream_channel.yaml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: package:stream_channel
2+
3+
on:
4+
# Run on PRs and pushes to the default branch.
5+
push:
6+
branches: [ main ]
7+
paths:
8+
- '.github/workflows/stream_channel.yaml'
9+
- 'pkgs/stream_channel/**'
10+
pull_request:
11+
branches: [ main ]
12+
paths:
13+
- '.github/workflows/stream_channel.yaml'
14+
- 'pkgs/stream_channel/**'
15+
schedule:
16+
- cron: "0 0 * * 0"
17+
18+
env:
19+
PUB_ENVIRONMENT: bot.github
20+
21+
defaults:
22+
run:
23+
working-directory: pkgs/stream_channel/
24+
25+
jobs:
26+
# Check code formatting and static analysis on a single OS (linux)
27+
# against Dart dev.
28+
analyze:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
sdk: [dev]
34+
steps:
35+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
36+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
37+
with:
38+
sdk: ${{ matrix.sdk }}
39+
- id: install
40+
name: Install dependencies
41+
run: dart pub get
42+
- name: Check formatting
43+
run: dart format --output=none --set-exit-if-changed .
44+
if: always() && steps.install.outcome == 'success'
45+
- name: Analyze code
46+
run: dart analyze --fatal-infos
47+
if: always() && steps.install.outcome == 'success'
48+
49+
# Run tests on a matrix consisting of two dimensions:
50+
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
51+
# 2. release channel: dev
52+
test:
53+
needs: analyze
54+
runs-on: ${{ matrix.os }}
55+
strategy:
56+
fail-fast: false
57+
matrix:
58+
# Add macos-latest and/or windows-latest if relevant for this package.
59+
os: [ubuntu-latest]
60+
sdk: [3.3, dev]
61+
steps:
62+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
63+
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
64+
with:
65+
sdk: ${{ matrix.sdk }}
66+
- id: install
67+
name: Install dependencies
68+
run: dart pub get
69+
- name: Run VM tests
70+
run: dart test --platform vm
71+
if: always() && steps.install.outcome == 'success'
72+
- name: Run Chrome tests
73+
run: dart test --platform chrome
74+
if: always() && steps.install.outcome == 'success'

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ don't naturally belong to other topic monorepos (like
4242
| [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) |
4343
| [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) |
4444
| [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) |
45+
| [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) |
4546
| [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) |
4647
| [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) |
4748
| [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) |

pkgs/stream_channel/.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.buildlog
2+
.dart_tool/
3+
.DS_Store
4+
.idea
5+
.pub/
6+
.settings/
7+
build/
8+
packages
9+
.packages
10+
pubspec.lock

pkgs/stream_channel/AUTHORS

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Below is a list of people and organizations that have contributed
2+
# to the project. Names should be added to the list like so:
3+
#
4+
# Name/Organization <email address>
5+
6+
Google Inc.

pkgs/stream_channel/CHANGELOG.md

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
## 2.1.3
2+
3+
* Require Dart 3.3
4+
* Move to `dart-lang/tools` monorepo.
5+
6+
## 2.1.2
7+
8+
* Require Dart 2.19
9+
* Add an example.
10+
* Fix a race condition in `IsolateChannel.connectReceive()` where the channel
11+
could hang forever if its sink was closed before the connection was established.
12+
13+
## 2.1.1
14+
15+
* Require Dart 2.14
16+
* Populate the pubspec `repository` field.
17+
* Handle multichannel messages where the ID element is a `double` at runtime
18+
instead of an `int`. When reading an array with `dart2wasm` numbers within the
19+
array are parsed as `double`.
20+
21+
## 2.1.0
22+
23+
* Stable release for null safety.
24+
25+
## 2.0.0
26+
27+
**Breaking changes**
28+
29+
* `IsolateChannel` requires a separate import
30+
`package:stram_channel/isolate_channel.dart`.
31+
`package:stream_channel/stream_channel.dart` will now not trigger any platform
32+
concerns due to importing `dart:isolate`.
33+
* Remove `JsonDocumentTransformer` class. The `jsonDocument` top level is still
34+
available.
35+
* Remove `StreamChannelTransformer.typed`. Use `.cast` on the transformed
36+
channel instead.
37+
* Change `Future<dynamic>` returns to `Future<void>`.
38+
39+
## 1.7.0
40+
41+
* Make `IsolateChannel` available through
42+
`package:stream_channel/isolate_channel.dart`. This will be the required
43+
import in the next release.
44+
* Require `2.0.0` or newer SDK.
45+
* Internal style changes.
46+
47+
## 1.6.8
48+
49+
* Set max SDK version to `<3.0.0`, and adjust other dependencies.
50+
51+
## 1.6.7+1
52+
53+
* Fix Dart 2 runtime types in `IsolateChannel`.
54+
55+
## 1.6.7
56+
57+
* Update SDK version to 2.0.0-dev.17.0.
58+
* Add a type argument to `MultiChannel`.
59+
60+
## 1.6.6
61+
62+
* Fix a Dart 2 issue with inner stream transformation in `GuaranteeChannel`.
63+
64+
* Fix a Dart 2 issue with `StreamChannelTransformer.fromCodec()`.
65+
66+
## 1.6.5
67+
68+
* Fix an issue with `JsonDocumentTransformer.bind` where it created an internal
69+
stream channel which didn't get a properly inferred type for its `sink`.
70+
71+
## 1.6.4
72+
73+
* Fix a race condition in `MultiChannel` where messages from a remote virtual
74+
channel could get dropped if the corresponding local channel wasn't registered
75+
quickly enough.
76+
77+
## 1.6.3
78+
79+
* Use `pumpEventQueue()` from test.
80+
81+
## 1.6.2
82+
83+
* Declare support for `async` 2.0.0.
84+
85+
## 1.6.1
86+
87+
* Fix the type of `StreamChannel.transform()`. This previously inverted the
88+
generic parameters, so it only really worked with transformers where both
89+
generic types were identical.
90+
91+
## 1.6.0
92+
93+
* `Disconnector.disconnect()` now returns a future that completes when all the
94+
inner `StreamSink.close()` futures have completed.
95+
96+
## 1.5.0
97+
98+
* Add `new StreamChannel.withCloseGuarantee()` to provide the specific guarantee
99+
that closing the sink causes the stream to close before it emits any more
100+
events. This is the only guarantee that isn't automatically preserved when
101+
transforming a channel.
102+
103+
* `StreamChannelTransformer`s provided by the `stream_channel` package now
104+
properly provide the guarantee that closing the sink causes the stream to
105+
close before it emits any more events
106+
107+
## 1.4.0
108+
109+
* Add `StreamChannel.cast()`, which soundly coerces the generic type of a
110+
channel.
111+
112+
* Add `StreamChannelTransformer.typed()`, which soundly coerces the generic type
113+
of a transformer.
114+
115+
## 1.3.2
116+
117+
* Fix all strong-mode errors and warnings.
118+
119+
## 1.3.1
120+
121+
* Make `IsolateChannel` slightly more efficient.
122+
123+
* Make `MultiChannel` follow the stream channel rules.
124+
125+
## 1.3.0
126+
127+
* Add `Disconnector`, a transformer that allows the caller to disconnect the
128+
transformed channel.
129+
130+
## 1.2.0
131+
132+
* Add `new StreamChannel.withGuarantees()`, which creates a channel with extra
133+
wrapping to ensure that it obeys the stream channel guarantees.
134+
135+
* Add `StreamChannelController`, which can be used to create custom
136+
`StreamChannel` objects.
137+
138+
## 1.1.1
139+
140+
* Fix the type annotation for `StreamChannel.transform()`'s parameter.
141+
142+
## 1.1.0
143+
144+
* Add `StreamChannel.transformStream()`, `StreamChannel.transformSink()`,
145+
`StreamChannel.changeStream()`, and `StreamChannel.changeSink()` to support
146+
changing only the stream or only the sink of a channel.
147+
148+
* Be more explicit about `JsonDocumentTransformer`'s error-handling behavior.
149+
150+
## 1.0.1
151+
152+
* Fix `MultiChannel`'s constructor to take a `StreamChannel`. This is
153+
technically a breaking change, but since 1.0.0 was only released an hour ago,
154+
we're treating it as a bug fix.
155+
156+
## 1.0.0
157+
158+
* Initial version

pkgs/stream_channel/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2015, the Dart project authors.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following
11+
disclaimer in the documentation and/or other materials provided
12+
with the distribution.
13+
* Neither the name of Google LLC nor the names of its
14+
contributors may be used to endorse or promote products derived
15+
from this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pkgs/stream_channel/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[![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)
2+
[![pub package](https://img.shields.io/pub/v/stream_channel.svg)](https://pub.dev/packages/stream_channel)
3+
[![package publisher](https://img.shields.io/pub/publisher/stream_channel.svg)](https://pub.dev/packages/stream_channel/publisher)
4+
5+
This package exposes the `StreamChannel` interface, which represents a two-way
6+
communication channel. Each `StreamChannel` exposes a `Stream` for receiving
7+
data and a `StreamSink` for sending it.
8+
9+
`StreamChannel` helps abstract communication logic away from the underlying
10+
protocol. For example, the [`test`][test] package re-uses its test suite
11+
communication protocol for both WebSocket connections to browser suites and
12+
Isolate connections to VM tests.
13+
14+
[test]: https://pub.dev/packages/test
15+
16+
This package also contains utilities for dealing with `StreamChannel`s and with
17+
two-way communications in general. For documentation of these utilities, see
18+
[the API docs][api].
19+
20+
[api]: https://pub.dev/documentation/stream_channel/latest/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include: package:dart_flutter_team_lints/analysis_options.yaml
2+
3+
analyzer:
4+
language:
5+
strict-casts: true

0 commit comments

Comments
 (0)