-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1264 from dart-lang/merge-sse-package
Merge `package:sse`
- Loading branch information
Showing
22 changed files
with
10,048 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
name: "package:sse" | ||
about: "Create a bug or file a feature request against package:sse." | ||
labels: "package:sse" | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
name: package:sse | ||
|
||
on: | ||
# Run on PRs and pushes to the default branch. | ||
push: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/sse.yaml' | ||
- 'pkgs/sse/**' | ||
pull_request: | ||
branches: [ main ] | ||
paths: | ||
- '.github/workflows/sse.yaml' | ||
- 'pkgs/sse/**' | ||
schedule: | ||
- cron: "0 0 * * 0" | ||
|
||
env: | ||
PUB_ENVIRONMENT: bot.github | ||
|
||
|
||
defaults: | ||
run: | ||
working-directory: pkgs/sse/ | ||
|
||
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 }} | ||
- uses: nanasess/setup-chromedriver@42cc2998329f041de87dc3cfa33a930eacd57eaa | ||
- id: install | ||
name: Install dependencies | ||
run: dart pub get | ||
- name: Run VM tests | ||
run: dart test --platform vm --test-randomize-ordering-seed=random -j 1 | ||
if: always() && steps.install.outcome == 'success' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.dart_tool | ||
pubspec.lock | ||
test/web/index.dart.js.deps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Dart project. Names should be added to the list like so: | ||
# | ||
# Name/Organization <email address> | ||
|
||
Google Inc. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,178 @@ | ||
## 4.1.7 | ||
|
||
- Move to `dart-lang/tools` monorepo. | ||
|
||
## 4.1.6 | ||
|
||
- Require package `web: '>=0.5.0 <2.0.0'`. | ||
|
||
## 4.1.5 | ||
|
||
- Drop unneeded dependency on `package:js`. | ||
- Update the minimum Dart SDK version to `3.3.0`. | ||
- Support the latest `package:web`. | ||
|
||
## 4.1.4 | ||
|
||
- Fix incorrect cast causing failure with `dart2wasm`. | ||
|
||
## 4.1.3 | ||
|
||
- Update the minimum Dart SDK version to `3.2.0`. | ||
|
||
## 4.1.2 | ||
|
||
- Send `fetch` requests instead of `XHR` requests. | ||
- Add an optional `debugKey` parameter to `SseClient` to include in logging. | ||
- Add a dependency on `package:js`. | ||
- Update the minimum Dart SDK version to `2.16.0`. | ||
|
||
## 4.1.1 | ||
|
||
- Apply `keepAlive` logic to `SocketException`s. | ||
- Switch from using `package:pedantic` to `package:lints` | ||
- Rev the minimum required SDK to 2.15. | ||
- Populate the pubspec `repository` field. | ||
|
||
## 4.1.0 | ||
|
||
- Limit the number of concurrent requests to prevent Chrome from automatically | ||
dropping them on the floor. | ||
|
||
## 4.0.0 | ||
|
||
- Support null safety. | ||
|
||
## 3.8.3 | ||
|
||
- Require the latest shelf and remove dead code. | ||
|
||
## 3.8.2 | ||
|
||
- Complete `onConnected` with an error if the `SseClient` receives an error | ||
before the connection is successfully opened. | ||
|
||
## 3.8.1 | ||
|
||
- Fix an issue where closing the `SseConnection` stream would result in an | ||
error. | ||
|
||
## 3.8.0 | ||
|
||
- Add `onConnected` to replace `onOpen`. | ||
- Fix an issue where failed requests would not add a `done` event to the | ||
connection `sink`. | ||
|
||
## 3.7.0 | ||
|
||
- Deprecate the client's `onOpen` getter. Messages will now be buffered until a | ||
connection is established. | ||
|
||
## 3.6.1 | ||
|
||
- Drop dependency on `package:uuid`. | ||
|
||
## 3.6.0 | ||
|
||
- Improve performance by buffering out of order messages in the server instead | ||
of the client. | ||
|
||
\*\* Note \*\* This is not modelled as a breaking change as the server can | ||
handle messages from older clients. However, clients should be using the latest | ||
server if they require order guarantees. | ||
|
||
## 3.5.0 | ||
|
||
- Add new `shutdown` methods on `SseHandler` and `SseConnection` to allow | ||
closing connections immediately, ignoring any keep-alive periods. | ||
|
||
## 3.4.0 | ||
|
||
- Remove `onClose` from `SseConnection` and ensure the corresponding | ||
`sink.close` correctly fires. | ||
|
||
## 3.3.0 | ||
|
||
- Add an `onClose` event to the `SseConnection`. This allows consumers to listen | ||
to this event in lue of `sseConnection.sink.done` as that is not guaranteed to | ||
fire. | ||
|
||
## 3.2.2 | ||
|
||
- Fix an issue where `keepAlive` may cause state errors when attempting to send | ||
messages on a closed stream. | ||
|
||
## 3.2.1 | ||
|
||
- Fix an issue where `keepAlive` would only allow a single reconnection. | ||
|
||
## 3.2.0 | ||
|
||
- Re-expose `isInKeepAlivePeriod` flag on `SseConnection`. This flag will be | ||
`true` when a connection has been dropped and is in the keep-alive period | ||
waiting for a client to reconnect. | ||
|
||
## 3.1.2 | ||
|
||
- Fix an issue where the `SseClient` would not send a `done` event when there | ||
was an error with the SSE connection. | ||
|
||
## 3.1.1 | ||
|
||
- Make `isInKeepAlive` on `SseConnection` private. | ||
|
||
**Note that this is a breaking change but in actuality no one should be | ||
depending on this API.** | ||
|
||
## 3.1.0 | ||
|
||
- Add optional `keepAlive` parameter to the `SseHandler`. If `keepAlive` is | ||
supplied, the connection will remain active for this period after a disconnect | ||
and can be reconnected transparently. If there is no reconnect within that | ||
period, the connection will be closed normally. | ||
|
||
## 3.0.0 | ||
|
||
- Add retry logic. | ||
|
||
**Possible Breaking Change Error messages may now be delayed up to 5 seconds in | ||
the client.** | ||
|
||
## 2.1.2 | ||
|
||
- Remove `package:http` dependency. | ||
|
||
## 2.1.1 | ||
|
||
- Use proper headers delimiter. | ||
|
||
## 2.1.0 | ||
|
||
- Support Firefox. | ||
|
||
## 2.0.3 | ||
|
||
- Fix an issue where messages could come out of order. | ||
|
||
## 2.0.2 | ||
|
||
- Support the latest `package:stream_channel`. | ||
- Require Dart SDK `>=2.1.0 <3.0.0`. | ||
|
||
## 2.0.1 | ||
|
||
- Update to `package:uuid` version 2.0. | ||
|
||
## 2.0.0 | ||
|
||
- No longer expose `close` and `onClose` on an `SseConnection`. This is simply | ||
handled by the underlying `stream` / `sink`. | ||
- Fix a bug where resources of the `SseConnection` were not properly closed. | ||
|
||
## 1.0.0 | ||
|
||
- Internal cleanup. | ||
|
||
## 0.0.1 | ||
|
||
- Initial commit. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright 2019, 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[![Build Status](https://github.com/dart-lang/tools/actions/workflows/sse.yaml/badge.svg)](https://github.com/dart-lang/tools/actions/workflows/sse.yaml) | ||
[![pub package](https://img.shields.io/pub/v/sse.svg)](https://pub.dev/packages/sse) | ||
[![package publisher](https://img.shields.io/pub/publisher/sse.svg)](https://pub.dev/packages/sse/publisher) | ||
|
||
This package provides support for bi-directional communication through Server | ||
Sent Events and corresponding POST requests. | ||
|
||
This package is not intended to be a general purpose SSE package, but instead is | ||
a bidirectional protocol for use when Websockets are unavailable. That is, both | ||
the client and the server expose a `sink` and `stream` on which to send and | ||
receive messages respectively. | ||
|
||
Both the server and client have implicit assumptions on each other and therefore | ||
a client from this package must be paired with a server from this package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# https://dart.dev/guides/language/analysis-options | ||
include: package:dart_flutter_team_lints/analysis_options.yaml | ||
|
||
analyzer: | ||
language: | ||
strict-casts: true | ||
|
||
linter: | ||
rules: | ||
- avoid_unused_constructor_parameters | ||
- cancel_subscriptions | ||
- literal_only_boolean_expressions | ||
- no_adjacent_strings_in_list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:sse/client/sse_client.dart'; | ||
|
||
/// A basic example which should be used in a browser that supports SSE. | ||
void main() { | ||
var channel = SseClient('/sseHandler'); | ||
|
||
channel.stream.listen((s) { | ||
// Listen for messages and send them back. | ||
channel.sink.add(s); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:shelf/shelf_io.dart' as io; | ||
import 'package:sse/server/sse_handler.dart'; | ||
|
||
/// A basic server which sets up an SSE handler. | ||
/// | ||
/// When a client connects it will send a simple message and print the | ||
/// response. | ||
void main() async { | ||
var handler = SseHandler(Uri.parse('/sseHandler')); | ||
await io.serve(handler.handler, 'localhost', 0); | ||
var connections = handler.connections; | ||
while (await connections.hasNext) { | ||
var connection = await connections.next; | ||
connection.sink.add('foo'); | ||
connection.stream.listen(print); | ||
} | ||
} |
Oops, something went wrong.