Skip to content

Commit 88087ae

Browse files
authored
Merge pull request #696 from dart-lang/merge-json_rpc_2-package
Merge `package:json_rpc_2`
2 parents 04f7512 + a587b85 commit 88087ae

31 files changed

+3480
-0
lines changed

.github/ISSUE_TEMPLATE/json_rpc_2.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
name: "package:json_rpc_2"
3+
about: "Create a bug or file a feature request against package:json_rpc_2."
4+
labels: "package:json_rpc_2"
5+
---

.github/labeler.yml

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@
3636
- changed-files:
3737
- any-glob-to-any-file: 'pkgs/graphs/**'
3838

39+
'package:json_rpc_2':
40+
- changed-files:
41+
- any-glob-to-any-file: 'pkgs/json_rpc_2/**'
42+
3943
'package:mime':
4044
- changed-files:
4145
- any-glob-to-any-file: 'pkgs/mime/**'

.github/workflows/json_rpc_2.yaml

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

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ don't naturally belong to other topic monorepos (like
2222
| [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) |
2323
| [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) |
2424
| [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) |
25+
| [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) |
2526
| [mime](pkgs/mime/) | Utilities for handling media (MIME) types. | [![pub package](https://img.shields.io/pub/v/mime.svg)](https://pub.dev/packages/mime) |
2627
| [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) |
2728
| [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) |

pkgs/json_rpc_2/.gitignore

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Don’t commit the following directories created by pub.
2+
.buildlog
3+
.dart_tool/
4+
.pub/
5+
build/
6+
packages
7+
.packages
8+
9+
# Or the files created by dart2js.
10+
*.dart.js
11+
*.js_
12+
*.js.deps
13+
*.js.map
14+
15+
# Include when developing application packages.
16+
pubspec.lock

pkgs/json_rpc_2/.test_config

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"test_package": true
3+
}

pkgs/json_rpc_2/CHANGELOG.md

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
## 3.0.3
2+
3+
* Require Dart 3.4
4+
* Move to `dart-lang/tools` monorepo.
5+
6+
## 3.0.2
7+
8+
* Switch to using `package:lints`.
9+
* Address a few analysis hint violations.
10+
* Populate the pubspec `repository` field.
11+
12+
## 3.0.1
13+
14+
* Fix a bug where a `null` result to a request caused an exception.
15+
16+
## 3.0.0
17+
18+
* Migrate to null safety.
19+
* Accept responses even if the server converts the ID to a String.
20+
21+
## 2.2.2
22+
23+
* Fix `Peer.close()` throwing `Bad state: Future already completed`.
24+
25+
## 2.2.1
26+
27+
* Fix `Peer` requests not terminating when the underlying channel is closed.
28+
29+
## 2.2.0
30+
31+
* Added `strictProtocolChecks` named parameter to `Server` and `Peer`
32+
constructors. Setting this parameter to false will result in the server not
33+
rejecting requests missing the `jsonrpc` parameter.
34+
35+
## 2.1.1
36+
37+
* Fixed issue where throwing `RpcException.methodNotFound` in an asynchronous
38+
fallback handler would not result in the next fallback being executed.
39+
* Updated minimum SDK to Dart `2.2.0`.
40+
41+
## 2.1.0
42+
43+
* `Server` and related classes can now take an `onUnhandledError` callback to
44+
notify callers of unhandled exceptions.
45+
46+
## 2.0.10
47+
48+
* Allow `stream_channel` version 2.x
49+
50+
## 2.0.8
51+
52+
* Updated SDK version to 2.0.0-dev.17.0
53+
54+
## 2.0.7
55+
56+
* When a `Client` is closed before a request completes, the error sent to that
57+
request's `Future` now includes the request method to aid in debugging.
58+
59+
## 2.0.6
60+
61+
* Internal changes only.
62+
63+
## 2.0.5
64+
65+
* Internal changes only.
66+
67+
## 2.0.4
68+
69+
* `Client.sendRequest()` now throws a `StateError` if the client is closed while
70+
the request is in-flight. This avoids dangling `Future`s that will never be
71+
completed.
72+
73+
* Both `Client.sendRequest()` and `Client.sendNotification()` now throw
74+
`StateError`s if they're called after the client is closed.
75+
76+
## 2.0.3
77+
78+
* Fix new strong-mode warnings.
79+
80+
## 2.0.2
81+
82+
* Fix all strong-mode warnings.
83+
84+
## 2.0.1
85+
86+
* Fix a race condition in which a `StateError` could be top-leveled if
87+
`Peer.close()` was called before the underlying channel closed.
88+
89+
## 2.0.0
90+
91+
* **Breaking change:** all constructors now take a `StreamChannel` rather than a
92+
`Stream`/`StreamSink` pair.
93+
94+
* `Client.sendRequest()` and `Client.sendNotification()` no longer throw
95+
`StateError`s after the connection has been closed but before `Client.close()`
96+
has been called.
97+
98+
* The various `close()` methods may now be called before their corresponding
99+
`listen()` methods.
100+
101+
* The various `close()` methods now wait on the result of closing the underlying
102+
`StreamSink`. Be aware that [in some circumstances][issue 19095]
103+
`StreamController`s' `Sink.close()` futures may never complete.
104+
105+
[issue 19095]: https://github.com/dart-lang/sdk/issues/19095
106+
107+
## 1.2.0
108+
109+
* Add `Client.isClosed` and `Server.isClosed`, which make it possible to
110+
synchronously determine whether the connection is open. In particular, this
111+
makes it possible to reliably tell whether it's safe to call
112+
`Client.sendRequest`.
113+
114+
* Fix a race condition in `Server` where a `StateError` could be thrown if the
115+
connection was closed in the middle of handling a request.
116+
117+
* Improve stack traces for error responses.
118+
119+
## 1.1.1
120+
121+
* Update the README to match the current API.
122+
123+
## 1.1.0
124+
125+
* Add a `done` getter to `Client`, `Server`, and `Peer`.
126+
127+
## 1.0.0
128+
129+
* Add a `Client` class for communicating with external JSON-RPC 2.0 servers.
130+
131+
* Add a `Peer` class that's both a `Client` and a `Server`.
132+
133+
## 0.1.0
134+
135+
* Remove `Server.handleRequest()` and `Server.parseRequest()`. Instead, `new
136+
Server()` takes a `Stream` and a `StreamSink` and uses those behind-the-scenes
137+
for its communication.
138+
139+
* Add `Server.listen()`, which causes the server to begin listening to the
140+
underlying request stream.
141+
142+
* Add `Server.close()`, which closes the underlying request stream and response
143+
sink.
144+
145+
## 0.0.2+3
146+
147+
* Widen the version constraint for `stack_trace`.
148+
149+
## 0.0.2+2
150+
151+
* Fix error response to include data from `RpcException` when not a map.

pkgs/json_rpc_2/LICENSE

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2014, 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.

0 commit comments

Comments
 (0)