From 5e84d9f8cb575e281efb000d05fffc91872f6bf7 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Tue, 21 Nov 2023 14:55:15 -0800 Subject: [PATCH] Update platform-specific imports for wasm (#1051) Fix some docs --- pkgs/flutter_http_example/lib/main.dart | 2 +- pkgs/http/lib/src/browser_client.dart | 4 ++-- pkgs/http/lib/src/client.dart | 3 ++- pkgs/http_client_conformance_tests/lib/src/close_tests.dart | 2 +- .../lib/src/compressed_response_body_tests.dart | 2 +- pkgs/http_client_conformance_tests/lib/src/isolate_test.dart | 4 ++-- .../lib/src/multiple_clients_tests.dart | 2 +- .../http_client_conformance_tests/lib/src/redirect_tests.dart | 2 +- .../lib/src/request_body_streamed_tests.dart | 2 +- .../lib/src/request_body_tests.dart | 2 +- .../lib/src/request_headers_tests.dart | 2 +- .../lib/src/response_body_streamed_test.dart | 2 +- .../lib/src/response_body_tests.dart | 2 +- .../lib/src/response_headers_tests.dart | 2 +- .../lib/src/response_status_line_tests.dart | 2 +- .../lib/src/server_errors_test.dart | 2 +- 16 files changed, 19 insertions(+), 18 deletions(-) diff --git a/pkgs/flutter_http_example/lib/main.dart b/pkgs/flutter_http_example/lib/main.dart index 70f003c84c..406b9e6b71 100644 --- a/pkgs/flutter_http_example/lib/main.dart +++ b/pkgs/flutter_http_example/lib/main.dart @@ -11,7 +11,7 @@ import 'package:provider/provider.dart'; import 'book.dart'; import 'http_client_factory.dart' - if (dart.library.html) 'http_client_factory_web.dart' as http_factory; + if (dart.library.js_interop) 'http_client_factory_web.dart' as http_factory; void main() { // `runWithClient` is used to control which `package:http` `Client` is used diff --git a/pkgs/http/lib/src/browser_client.dart b/pkgs/http/lib/src/browser_client.dart index 10d8e0cdba..80db8b1291 100644 --- a/pkgs/http/lib/src/browser_client.dart +++ b/pkgs/http/lib/src/browser_client.dart @@ -26,8 +26,8 @@ BaseClient createClient() { return BrowserClient(); } -/// A `dart:html`-based HTTP client that runs in the browser and is backed by -/// XMLHttpRequests. +/// A `package:web`-based HTTP client that runs in the browser and is backed by +/// [XMLHttpRequest]. /// /// This client inherits some of the limitations of XMLHttpRequest. It ignores /// the [BaseRequest.contentLength], [BaseRequest.persistentConnection], diff --git a/pkgs/http/lib/src/client.dart b/pkgs/http/lib/src/client.dart index 85d933a85a..7429ca8824 100644 --- a/pkgs/http/lib/src/client.dart +++ b/pkgs/http/lib/src/client.dart @@ -37,7 +37,8 @@ abstract interface class Client { /// Creates a new platform appropriate client. /// /// Creates an `IOClient` if `dart:io` is available and a `BrowserClient` if - /// `dart:html` is available, otherwise it will throw an unsupported error. + /// `dart:js_interop` is available, otherwise it will throw an unsupported + /// error. factory Client() => zoneClient ?? createClient(); /// Sends an HTTP HEAD request with the given headers to the given URL. diff --git a/pkgs/http_client_conformance_tests/lib/src/close_tests.dart b/pkgs/http_client_conformance_tests/lib/src/close_tests.dart index 040b338bf6..8194130bcc 100644 --- a/pkgs/http_client_conformance_tests/lib/src/close_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/close_tests.dart @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'request_body_server_vm.dart' - if (dart.library.html) 'request_body_server_web.dart'; + if (dart.library.js_interop) 'request_body_server_web.dart'; /// Tests that the [Client] correctly implements [Client.close]. void testClose(Client Function() clientFactory) { diff --git a/pkgs/http_client_conformance_tests/lib/src/compressed_response_body_tests.dart b/pkgs/http_client_conformance_tests/lib/src/compressed_response_body_tests.dart index 3ce871bc21..2395aaf494 100644 --- a/pkgs/http_client_conformance_tests/lib/src/compressed_response_body_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/compressed_response_body_tests.dart @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'compressed_response_body_server_vm.dart' - if (dart.library.html) 'compressed_response_body_server_web.dart'; + if (dart.library.js_interop) 'compressed_response_body_server_web.dart'; /// Tests that the [Client] correctly implements HTTP responses with compressed /// bodies. diff --git a/pkgs/http_client_conformance_tests/lib/src/isolate_test.dart b/pkgs/http_client_conformance_tests/lib/src/isolate_test.dart index b4ac8b2393..6b296a2df0 100644 --- a/pkgs/http_client_conformance_tests/lib/src/isolate_test.dart +++ b/pkgs/http_client_conformance_tests/lib/src/isolate_test.dart @@ -2,7 +2,7 @@ // 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 'dart:isolate' if (dart.library.html) 'dummy_isolate.dart'; +import 'dart:isolate' if (dart.library.js_interop) 'dummy_isolate.dart'; import 'package:async/async.dart'; import 'package:http/http.dart'; @@ -10,7 +10,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'request_body_server_vm.dart' - if (dart.library.html) 'request_body_server_web.dart'; + if (dart.library.js_interop) 'request_body_server_web.dart'; Future _testPost(Client Function() clientFactory, String host) async { await Isolate.run( diff --git a/pkgs/http_client_conformance_tests/lib/src/multiple_clients_tests.dart b/pkgs/http_client_conformance_tests/lib/src/multiple_clients_tests.dart index be9c4d9722..8f8dc813a2 100644 --- a/pkgs/http_client_conformance_tests/lib/src/multiple_clients_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/multiple_clients_tests.dart @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'multiple_clients_server_vm.dart' - if (dart.library.html) 'multiple_clients_server_web.dart'; + if (dart.library.js_interop) 'multiple_clients_server_web.dart'; /// Tests that the [Client] works correctly if there are many used /// simultaneously. diff --git a/pkgs/http_client_conformance_tests/lib/src/redirect_tests.dart b/pkgs/http_client_conformance_tests/lib/src/redirect_tests.dart index e21a5c2d4a..600becc0fe 100644 --- a/pkgs/http_client_conformance_tests/lib/src/redirect_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/redirect_tests.dart @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'redirect_server_vm.dart' - if (dart.library.html) 'redirect_server_web.dart'; + if (dart.library.js_interop) 'redirect_server_web.dart'; /// Tests that the [Client] correctly implements HTTP redirect logic. /// diff --git a/pkgs/http_client_conformance_tests/lib/src/request_body_streamed_tests.dart b/pkgs/http_client_conformance_tests/lib/src/request_body_streamed_tests.dart index 560858dc3c..8c0c658e11 100644 --- a/pkgs/http_client_conformance_tests/lib/src/request_body_streamed_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/request_body_streamed_tests.dart @@ -11,7 +11,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'request_body_streamed_server_vm.dart' - if (dart.library.html) 'request_body_streamed_server_web.dart'; + if (dart.library.js_interop) 'request_body_streamed_server_web.dart'; /// Tests that the [Client] correctly implements streamed request body /// uploading. diff --git a/pkgs/http_client_conformance_tests/lib/src/request_body_tests.dart b/pkgs/http_client_conformance_tests/lib/src/request_body_tests.dart index e211da5755..2f13fa7fd5 100644 --- a/pkgs/http_client_conformance_tests/lib/src/request_body_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/request_body_tests.dart @@ -10,7 +10,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'request_body_server_vm.dart' - if (dart.library.html) 'request_body_server_web.dart'; + if (dart.library.js_interop) 'request_body_server_web.dart'; class _Plus2Decoder extends Converter, String> { @override diff --git a/pkgs/http_client_conformance_tests/lib/src/request_headers_tests.dart b/pkgs/http_client_conformance_tests/lib/src/request_headers_tests.dart index 8adf98c9c7..a6943871a8 100644 --- a/pkgs/http_client_conformance_tests/lib/src/request_headers_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/request_headers_tests.dart @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'request_headers_server_vm.dart' - if (dart.library.html) 'request_headers_server_web.dart'; + if (dart.library.js_interop) 'request_headers_server_web.dart'; /// Tests that the [Client] correctly sends headers in the request. void testRequestHeaders(Client client) async { diff --git a/pkgs/http_client_conformance_tests/lib/src/response_body_streamed_test.dart b/pkgs/http_client_conformance_tests/lib/src/response_body_streamed_test.dart index 28686fa553..b8afa3deb1 100644 --- a/pkgs/http_client_conformance_tests/lib/src/response_body_streamed_test.dart +++ b/pkgs/http_client_conformance_tests/lib/src/response_body_streamed_test.dart @@ -10,7 +10,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'response_body_streamed_server_vm.dart' - if (dart.library.html) 'response_body_streamed_server_web.dart'; + if (dart.library.js_interop) 'response_body_streamed_server_web.dart'; /// Tests that the [Client] correctly implements HTTP responses with bodies of /// unbounded size. diff --git a/pkgs/http_client_conformance_tests/lib/src/response_body_tests.dart b/pkgs/http_client_conformance_tests/lib/src/response_body_tests.dart index 91ee549736..ba833f4a1b 100644 --- a/pkgs/http_client_conformance_tests/lib/src/response_body_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/response_body_tests.dart @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'response_body_server_vm.dart' - if (dart.library.html) 'response_body_server_web.dart'; + if (dart.library.js_interop) 'response_body_server_web.dart'; /// Tests that the [Client] correctly implements HTTP responses with bodies. /// diff --git a/pkgs/http_client_conformance_tests/lib/src/response_headers_tests.dart b/pkgs/http_client_conformance_tests/lib/src/response_headers_tests.dart index 4f920428ae..6a3647b196 100644 --- a/pkgs/http_client_conformance_tests/lib/src/response_headers_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/response_headers_tests.dart @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'response_headers_server_vm.dart' - if (dart.library.html) 'response_headers_server_web.dart'; + if (dart.library.js_interop) 'response_headers_server_web.dart'; /// Tests that the [Client] correctly processes response headers. void testResponseHeaders(Client client) async { diff --git a/pkgs/http_client_conformance_tests/lib/src/response_status_line_tests.dart b/pkgs/http_client_conformance_tests/lib/src/response_status_line_tests.dart index b618fa099c..12fb29c13a 100644 --- a/pkgs/http_client_conformance_tests/lib/src/response_status_line_tests.dart +++ b/pkgs/http_client_conformance_tests/lib/src/response_status_line_tests.dart @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'response_status_line_server_vm.dart' - if (dart.library.html) 'response_status_line_server_web.dart'; + if (dart.library.js_interop) 'response_status_line_server_web.dart'; /// Tests that the [Client] correctly processes the response status line (e.g. /// 'HTTP/1.1 200 OK\r\n'). diff --git a/pkgs/http_client_conformance_tests/lib/src/server_errors_test.dart b/pkgs/http_client_conformance_tests/lib/src/server_errors_test.dart index 65de499e56..0e45bc59b9 100644 --- a/pkgs/http_client_conformance_tests/lib/src/server_errors_test.dart +++ b/pkgs/http_client_conformance_tests/lib/src/server_errors_test.dart @@ -8,7 +8,7 @@ import 'package:stream_channel/stream_channel.dart'; import 'package:test/test.dart'; import 'server_errors_server_vm.dart' - if (dart.library.html) 'server_errors_server_web.dart'; + if (dart.library.js_interop) 'server_errors_server_web.dart'; /// Tests that the [Client] correctly handles server errors. void testServerErrors(Client client, {bool redirectAlwaysAllowed = false}) {