Skip to content

Commit

Permalink
Merge pull request #696 from dart-lang/merge-json_rpc_2-package
Browse files Browse the repository at this point in the history
Merge `package:json_rpc_2`
  • Loading branch information
mosuem authored Oct 28, 2024
2 parents 04f7512 + a587b85 commit 88087ae
Show file tree
Hide file tree
Showing 31 changed files with 3,480 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/ISSUE_TEMPLATE/json_rpc_2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
name: "package:json_rpc_2"
about: "Create a bug or file a feature request against package:json_rpc_2."
labels: "package:json_rpc_2"
---
4 changes: 4 additions & 0 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
- changed-files:
- any-glob-to-any-file: 'pkgs/graphs/**'

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

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

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

env:
PUB_ENVIRONMENT: bot.github


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

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@d632683dd7b4114ad314bca15554477dd762a938
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
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.4, dev]
steps:
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
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 browser tests
run: dart test --platform chrome --compiler dart2wasm,dart2js
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 @@ -22,6 +22,7 @@ don't naturally belong to other topic monorepos (like
| [file](pkgs/file/) | A pluggable, mockable file system abstraction for Dart. | [![pub package](https://img.shields.io/pub/v/file.svg)](https://pub.dev/packages/file) |
| [file_testing](pkgs/file_testing/) | Testing utilities for package:file (published but unlisted). | [![pub package](https://img.shields.io/pub/v/file_testing.svg)](https://pub.dev/packages/file_testing) |
| [graphs](pkgs/graphs/) | Graph algorithms that operate on graphs in any representation | [![pub package](https://img.shields.io/pub/v/graphs.svg)](https://pub.dev/packages/graphs) |
| [json_rpc_2](pkgs/json_rpc_2/) | Utilities to write a client or server using the JSON-RPC 2.0 spec. | [![pub package](https://img.shields.io/pub/v/json_rpc_2.svg)](https://pub.dev/packages/json_rpc_2) |
| [mime](pkgs/mime/) | Utilities for handling media (MIME) types. | [![pub package](https://img.shields.io/pub/v/mime.svg)](https://pub.dev/packages/mime) |
| [oauth2](pkgs/oauth2/) | A client library for authenticatingand making requests via OAuth2. | [![pub package](https://img.shields.io/pub/v/oauth2.svg)](https://pub.dev/packages/oauth2) |
| [source_map_stack_trace](pkgs/source_map_stack_trace/) | A package for applying source maps to stack traces. | [![pub package](https://img.shields.io/pub/v/source_map_stack_trace.svg)](https://pub.dev/packages/source_map_stack_trace) |
Expand Down
16 changes: 16 additions & 0 deletions pkgs/json_rpc_2/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Don’t commit the following directories created by pub.
.buildlog
.dart_tool/
.pub/
build/
packages
.packages

# Or the files created by dart2js.
*.dart.js
*.js_
*.js.deps
*.js.map

# Include when developing application packages.
pubspec.lock
3 changes: 3 additions & 0 deletions pkgs/json_rpc_2/.test_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"test_package": true
}
151 changes: 151 additions & 0 deletions pkgs/json_rpc_2/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
## 3.0.3

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

## 3.0.2

* Switch to using `package:lints`.
* Address a few analysis hint violations.
* Populate the pubspec `repository` field.

## 3.0.1

* Fix a bug where a `null` result to a request caused an exception.

## 3.0.0

* Migrate to null safety.
* Accept responses even if the server converts the ID to a String.

## 2.2.2

* Fix `Peer.close()` throwing `Bad state: Future already completed`.

## 2.2.1

* Fix `Peer` requests not terminating when the underlying channel is closed.

## 2.2.0

* Added `strictProtocolChecks` named parameter to `Server` and `Peer`
constructors. Setting this parameter to false will result in the server not
rejecting requests missing the `jsonrpc` parameter.

## 2.1.1

* Fixed issue where throwing `RpcException.methodNotFound` in an asynchronous
fallback handler would not result in the next fallback being executed.
* Updated minimum SDK to Dart `2.2.0`.

## 2.1.0

* `Server` and related classes can now take an `onUnhandledError` callback to
notify callers of unhandled exceptions.

## 2.0.10

* Allow `stream_channel` version 2.x

## 2.0.8

* Updated SDK version to 2.0.0-dev.17.0

## 2.0.7

* When a `Client` is closed before a request completes, the error sent to that
request's `Future` now includes the request method to aid in debugging.

## 2.0.6

* Internal changes only.

## 2.0.5

* Internal changes only.

## 2.0.4

* `Client.sendRequest()` now throws a `StateError` if the client is closed while
the request is in-flight. This avoids dangling `Future`s that will never be
completed.

* Both `Client.sendRequest()` and `Client.sendNotification()` now throw
`StateError`s if they're called after the client is closed.

## 2.0.3

* Fix new strong-mode warnings.

## 2.0.2

* Fix all strong-mode warnings.

## 2.0.1

* Fix a race condition in which a `StateError` could be top-leveled if
`Peer.close()` was called before the underlying channel closed.

## 2.0.0

* **Breaking change:** all constructors now take a `StreamChannel` rather than a
`Stream`/`StreamSink` pair.

* `Client.sendRequest()` and `Client.sendNotification()` no longer throw
`StateError`s after the connection has been closed but before `Client.close()`
has been called.

* The various `close()` methods may now be called before their corresponding
`listen()` methods.

* The various `close()` methods now wait on the result of closing the underlying
`StreamSink`. Be aware that [in some circumstances][issue 19095]
`StreamController`s' `Sink.close()` futures may never complete.

[issue 19095]: https://github.com/dart-lang/sdk/issues/19095

## 1.2.0

* Add `Client.isClosed` and `Server.isClosed`, which make it possible to
synchronously determine whether the connection is open. In particular, this
makes it possible to reliably tell whether it's safe to call
`Client.sendRequest`.

* Fix a race condition in `Server` where a `StateError` could be thrown if the
connection was closed in the middle of handling a request.

* Improve stack traces for error responses.

## 1.1.1

* Update the README to match the current API.

## 1.1.0

* Add a `done` getter to `Client`, `Server`, and `Peer`.

## 1.0.0

* Add a `Client` class for communicating with external JSON-RPC 2.0 servers.

* Add a `Peer` class that's both a `Client` and a `Server`.

## 0.1.0

* Remove `Server.handleRequest()` and `Server.parseRequest()`. Instead, `new
Server()` takes a `Stream` and a `StreamSink` and uses those behind-the-scenes
for its communication.

* Add `Server.listen()`, which causes the server to begin listening to the
underlying request stream.

* Add `Server.close()`, which closes the underlying request stream and response
sink.

## 0.0.2+3

* Widen the version constraint for `stack_trace`.

## 0.0.2+2

* Fix error response to include data from `RpcException` when not a map.
27 changes: 27 additions & 0 deletions pkgs/json_rpc_2/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright 2014, 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.
Loading

0 comments on commit 88087ae

Please sign in to comment.