From e684fbfe6ab56c60849ded0b2ec5baa37a69e30a Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 3 Dec 2024 10:38:25 -0800 Subject: [PATCH 1/3] widen the dep in package:shelf_web_socket --- pkgs/test/CHANGELOG.md | 4 ++++ pkgs/test/README.md | 2 +- pkgs/test/lib/src/runner/browser/compilers/dart2js.dart | 5 ++++- pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart | 5 ++++- pkgs/test/lib/src/runner/browser/compilers/precompiled.dart | 5 ++++- pkgs/test/pubspec.yaml | 4 ++-- pkgs/test/test/runner/browser/code_server.dart | 4 +++- 7 files changed, 22 insertions(+), 7 deletions(-) diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index eacfc5479..870550a5a 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.25.11 + +* Update the `package:shelf_web_socket` constraint to allow version `3.x`. + ## 1.25.10 * Update the `package:vm_service` constraint to allow version `15.x`. diff --git a/pkgs/test/README.md b/pkgs/test/README.md index 166a371cd..36103d9c1 100644 --- a/pkgs/test/README.md +++ b/pkgs/test/README.md @@ -798,7 +798,7 @@ import 'package:stream_channel/stream_channel.dart'; // returned spawnHybridCode(). hybridMain(StreamChannel channel) async { // Start a WebSocket server that just sends "hello!" to its clients. - var server = await io.serve(webSocketHandler((webSocket) { + var server = await io.serve(webSocketHandler((webSocket, _) { webSocket.sink.add('hello!'); }), 'localhost', 0); diff --git a/pkgs/test/lib/src/runner/browser/compilers/dart2js.dart b/pkgs/test/lib/src/runner/browser/compilers/dart2js.dart index 2c26ed0ea..99ff31e3c 100644 --- a/pkgs/test/lib/src/runner/browser/compilers/dart2js.dart +++ b/pkgs/test/lib/src/runner/browser/compilers/dart2js.dart @@ -174,7 +174,10 @@ class Dart2JsSupport extends CompilerSupport with JsHtmlWrapper { @override (Uri, Future) get webSocket { var completer = Completer.sync(); - var path = _webSocketHandler.create(webSocketHandler(completer.complete)); + var path = + _webSocketHandler.create(webSocketHandler((WebSocketChannel ws, _) { + completer.complete(ws); + })); var webSocketUrl = serverUrl.replace(scheme: 'ws').resolve(path); return (webSocketUrl, completer.future); } diff --git a/pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart b/pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart index 697a9c50b..825011bfd 100644 --- a/pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart +++ b/pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart @@ -180,7 +180,10 @@ class Dart2WasmSupport extends CompilerSupport with WasmHtmlWrapper { @override (Uri, Future) get webSocket { var completer = Completer.sync(); - var path = _webSocketHandler.create(webSocketHandler(completer.complete)); + var path = + _webSocketHandler.create(webSocketHandler((WebSocketChannel ws, _) { + completer.complete(ws); + })); var webSocketUrl = serverUrl.replace(scheme: 'ws').resolve(path); return (webSocketUrl, completer.future); } diff --git a/pkgs/test/lib/src/runner/browser/compilers/precompiled.dart b/pkgs/test/lib/src/runner/browser/compilers/precompiled.dart index f4c6a7a7e..bff16d68d 100644 --- a/pkgs/test/lib/src/runner/browser/compilers/precompiled.dart +++ b/pkgs/test/lib/src/runner/browser/compilers/precompiled.dart @@ -137,7 +137,10 @@ abstract class PrecompiledSupport extends CompilerSupport { @override (Uri, Future) get webSocket { var completer = Completer.sync(); - var path = _webSocketHandler.create(webSocketHandler(completer.complete)); + var path = + _webSocketHandler.create(webSocketHandler((WebSocketChannel ws, _) { + completer.complete(ws); + })); var webSocketUrl = serverUrl.replace(scheme: 'ws').resolve(path); return (webSocketUrl, completer.future); } diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index 795a3ac71..5a3a37d40 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -1,5 +1,5 @@ name: test -version: 1.25.10 +version: 1.25.11 description: >- A full featured library for writing and running Dart tests across platforms. repository: https://github.com/dart-lang/test/tree/master/pkgs/test @@ -29,7 +29,7 @@ dependencies: shelf: ^1.0.0 shelf_packages_handler: ^3.0.0 shelf_static: ^1.0.0 - shelf_web_socket: '>=1.0.0 <3.0.0' + shelf_web_socket: '>=1.0.0 <4.0.0' source_span: ^1.8.0 stack_trace: ^1.10.0 stream_channel: ^2.1.0 diff --git a/pkgs/test/test/runner/browser/code_server.dart b/pkgs/test/test/runner/browser/code_server.dart index 85705cc0e..916f7647c 100644 --- a/pkgs/test/test/runner/browser/code_server.dart +++ b/pkgs/test/test/runner/browser/code_server.dart @@ -59,7 +59,9 @@ class CodeServer { /// future that will complete to the WebSocket. Future handleWebSocket() { var completer = Completer(); - _handler.expect('GET', '/', webSocketHandler(completer.complete)); + _handler.expect('GET', '/', webSocketHandler((WebSocketChannel ws, _) { + completer.complete(ws); + })); return completer.future; } } From ed95cf6ff8a388a3aeed562effd7f28d607b5568 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 3 Dec 2024 11:09:43 -0800 Subject: [PATCH 2/3] Apply suggestions from code review Co-authored-by: Jacob MacDonald --- pkgs/test/CHANGELOG.md | 2 +- pkgs/test/pubspec.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/test/CHANGELOG.md b/pkgs/test/CHANGELOG.md index 870550a5a..c200b2189 100644 --- a/pkgs/test/CHANGELOG.md +++ b/pkgs/test/CHANGELOG.md @@ -1,6 +1,6 @@ ## 1.25.11 -* Update the `package:shelf_web_socket` constraint to allow version `3.x`. +* Update to be forward compatible with `package:shelf_web_socket` version `3.x`. ## 1.25.10 diff --git a/pkgs/test/pubspec.yaml b/pkgs/test/pubspec.yaml index 5a3a37d40..a66e59271 100644 --- a/pkgs/test/pubspec.yaml +++ b/pkgs/test/pubspec.yaml @@ -29,7 +29,7 @@ dependencies: shelf: ^1.0.0 shelf_packages_handler: ^3.0.0 shelf_static: ^1.0.0 - shelf_web_socket: '>=1.0.0 <4.0.0' + shelf_web_socket: '>=1.0.0 <3.0.0' source_span: ^1.8.0 stack_trace: ^1.10.0 stream_channel: ^2.1.0 From 7695df0fb43d93b63c3c6e5da5e73d20a73ede4b Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 3 Dec 2024 11:17:59 -0800 Subject: [PATCH 3/3] add comments to calls to webSocketHandler --- pkgs/test/lib/src/runner/browser/compilers/dart2js.dart | 2 ++ pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart | 2 ++ pkgs/test/lib/src/runner/browser/compilers/precompiled.dart | 2 ++ pkgs/test/test/runner/browser/code_server.dart | 2 ++ 4 files changed, 8 insertions(+) diff --git a/pkgs/test/lib/src/runner/browser/compilers/dart2js.dart b/pkgs/test/lib/src/runner/browser/compilers/dart2js.dart index 99ff31e3c..3cd67453b 100644 --- a/pkgs/test/lib/src/runner/browser/compilers/dart2js.dart +++ b/pkgs/test/lib/src/runner/browser/compilers/dart2js.dart @@ -174,6 +174,8 @@ class Dart2JsSupport extends CompilerSupport with JsHtmlWrapper { @override (Uri, Future) get webSocket { var completer = Completer.sync(); + // Note: the WebSocketChannel type below is needed for compatibility with + // package:shelf_web_socket v2. var path = _webSocketHandler.create(webSocketHandler((WebSocketChannel ws, _) { completer.complete(ws); diff --git a/pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart b/pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart index 825011bfd..31ad66152 100644 --- a/pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart +++ b/pkgs/test/lib/src/runner/browser/compilers/dart2wasm.dart @@ -180,6 +180,8 @@ class Dart2WasmSupport extends CompilerSupport with WasmHtmlWrapper { @override (Uri, Future) get webSocket { var completer = Completer.sync(); + // Note: the WebSocketChannel type below is needed for compatibility with + // package:shelf_web_socket v2. var path = _webSocketHandler.create(webSocketHandler((WebSocketChannel ws, _) { completer.complete(ws); diff --git a/pkgs/test/lib/src/runner/browser/compilers/precompiled.dart b/pkgs/test/lib/src/runner/browser/compilers/precompiled.dart index bff16d68d..9cf44aaf4 100644 --- a/pkgs/test/lib/src/runner/browser/compilers/precompiled.dart +++ b/pkgs/test/lib/src/runner/browser/compilers/precompiled.dart @@ -137,6 +137,8 @@ abstract class PrecompiledSupport extends CompilerSupport { @override (Uri, Future) get webSocket { var completer = Completer.sync(); + // Note: the WebSocketChannel type below is needed for compatibility with + // package:shelf_web_socket v2. var path = _webSocketHandler.create(webSocketHandler((WebSocketChannel ws, _) { completer.complete(ws); diff --git a/pkgs/test/test/runner/browser/code_server.dart b/pkgs/test/test/runner/browser/code_server.dart index 916f7647c..1aba5dea5 100644 --- a/pkgs/test/test/runner/browser/code_server.dart +++ b/pkgs/test/test/runner/browser/code_server.dart @@ -59,6 +59,8 @@ class CodeServer { /// future that will complete to the WebSocket. Future handleWebSocket() { var completer = Completer(); + // Note: the WebSocketChannel type below is needed for compatibility with + // package:shelf_web_socket v2. _handler.expect('GET', '/', webSocketHandler((WebSocketChannel ws, _) { completer.complete(ws); }));