Prepare to republish as 1.0.10
- Bump minimum SDK constraint to one that includes `Future` in
`dart:core`.
- Remove all `dart:async` imports which are no longer required.
- Merge in branch that published as 1.0.9 to include changelog.
diff --git a/.travis.yml b/.travis.yml
index 8f4447d..781f46d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,16 +2,13 @@
dart:
- dev
+ - stable
+
dart_task:
- test: --platform vm
- test: --platform firefox
-
-matrix:
- include:
- - dart: dev
- dart_task: dartfmt
- - dart: dev
- dart_task: dartanalyzer
+ - dartfmt
+ - dartanalyzer: --fatal-infos --fatal-warnings .
# Only building master means that we don't run two builds for each pull request.
branches:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8d6e815..b65db46 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 1.0.10
+
+* Use conditional imports to avoid `dart:isolate` imports on the web.
+* Bump minimum SDK to `2.1.0`.
+
## 1.0.9
* Identical to `1.0.6` - republishing with a higher version number to get around
@@ -18,7 +23,7 @@
## 1.0.5
-* Use conditional imports to avoid dart:io imports on the web.
+* Use conditional imports to avoid `dart:io` imports on the web.
## 1.0.4
diff --git a/lib/src/async_package_resolver.dart b/lib/src/async_package_resolver.dart
index 06c61e7..ef75081 100644
--- a/lib/src/async_package_resolver.dart
+++ b/lib/src/async_package_resolver.dart
@@ -2,8 +2,6 @@
// 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:async';
-
import 'package_resolver.dart';
import 'sync_package_resolver.dart';
diff --git a/lib/src/current_isolate_resolver.dart b/lib/src/current_isolate_resolver.dart
index 22d9fbf..1244b5c 100644
--- a/lib/src/current_isolate_resolver.dart
+++ b/lib/src/current_isolate_resolver.dart
@@ -2,7 +2,6 @@
// 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:async';
import 'dart:isolate';
import 'package:path/path.dart' as p;
@@ -14,7 +13,9 @@
import 'utils.dart';
/// The package resolution strategy used by the current isolate.
-class CurrentIsolateResolver implements PackageResolver {
+PackageResolver currentIsolateResolver() => _CurrentIsolateResolver();
+
+class _CurrentIsolateResolver implements PackageResolver {
Future<Map<String, Uri>> get packageConfigMap async {
if (_packageConfigMap != null) return _packageConfigMap;
@@ -28,6 +29,7 @@
Future<Uri> get packageConfigUri => Isolate.packageConfig;
+ // ignore: deprecated_member_use
Future<Uri> get packageRoot => Isolate.packageRoot;
Future<SyncPackageResolver> get asSync async {
diff --git a/lib/src/current_isolate_resolver_stub.dart b/lib/src/current_isolate_resolver_stub.dart
new file mode 100644
index 0000000..110701d
--- /dev/null
+++ b/lib/src/current_isolate_resolver_stub.dart
@@ -0,0 +1,8 @@
+// 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_resolver.dart';
+
+PackageResolver currentIsolateResolver() =>
+ throw UnsupportedError('No current isolate support on this platform');
diff --git a/lib/src/package_resolver.dart b/lib/src/package_resolver.dart
index c72fc9d..d53d761 100644
--- a/lib/src/package_resolver.dart
+++ b/lib/src/package_resolver.dart
@@ -2,15 +2,17 @@
// 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:async';
-
import 'package:http/http.dart' as http;
-import 'current_isolate_resolver.dart';
import 'package_config_resolver.dart';
import 'package_root_resolver.dart';
import 'sync_package_resolver.dart';
+// ignore: uri_does_not_exist
+import 'current_isolate_resolver_stub.dart'
+ // ignore: uri_does_not_exist
+ if (dart.library.isolate) 'current_isolate_resolver.dart' as isolate;
+
/// A class that defines how to resolve `package:` URIs.
///
/// This includes the information necessary to resolve `package:` URIs using
@@ -81,7 +83,7 @@
/// Returns package resolution strategy describing how the current isolate
/// resolves `package:` URIs.
- static final PackageResolver current = new CurrentIsolateResolver();
+ static final PackageResolver current = isolate.currentIsolateResolver();
/// Returns a package resolution strategy that is unable to resolve any
/// `package:` URIs.
diff --git a/lib/src/sync_package_resolver.dart b/lib/src/sync_package_resolver.dart
index daaf46c..5cb4c99 100644
--- a/lib/src/sync_package_resolver.dart
+++ b/lib/src/sync_package_resolver.dart
@@ -2,8 +2,6 @@
// 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:async';
-
import 'package:http/http.dart' as http;
import 'no_package_resolver.dart';
diff --git a/lib/src/utils.dart b/lib/src/utils.dart
index 5e4b411..b588c54 100644
--- a/lib/src/utils.dart
+++ b/lib/src/utils.dart
@@ -2,19 +2,19 @@
// 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.
-// TODO(nweiz): Avoid importing dart:io directly when cross-platform libraries
-// exist.
-import 'dart:async';
import 'dart:convert';
-import 'dart:isolate';
import 'package:http/http.dart' as http;
import 'package:package_config/packages_file.dart' as packages_file;
// ignore: uri_does_not_exist
-import 'utils_stub.dart'
+import 'utils_io_stub.dart'
// ignore: uri_does_not_exist
- if (dart.library.io) 'utils_io.dart' as conditional;
+ if (dart.library.io) 'utils_io.dart' as io;
+// ignore: uri_does_not_exist
+import 'utils_isolate_stub.dart'
+ // ignore: uri_does_not_exist
+ if (dart.library.isolate) 'utils_isolate.dart' as isolate;
/// Loads the configuration map from [uri].
///
@@ -28,11 +28,11 @@
if (resolved.scheme == 'http') {
text = await (client == null ? http.read(resolved) : client.read(resolved));
} else if (resolved.scheme == 'file') {
- text = await conditional.readFileAsString(resolved);
+ text = await io.readFileAsString(resolved);
} else if (resolved.scheme == 'data') {
text = resolved.data.contentAsString();
} else if (resolved.scheme == 'package') {
- return loadConfigMap(await Isolate.resolvePackageUri(uri), client: client);
+ return loadConfigMap(await isolate.resolvePackageUri(uri), client: client);
} else {
throw new UnsupportedError(
'PackageInfo.loadConfig doesn\'t support URI scheme "${uri.scheme}:".');
@@ -83,4 +83,4 @@
}
String packagePathForRoot(String package, Uri root) =>
- conditional.packagePathForRoot(package, root);
+ io.packagePathForRoot(package, root);
diff --git a/lib/src/utils_io.dart b/lib/src/utils_io.dart
index 8959f4d..df768e6 100644
--- a/lib/src/utils_io.dart
+++ b/lib/src/utils_io.dart
@@ -2,14 +2,13 @@
// 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:async';
import 'dart:io';
import 'package:path/path.dart' as p;
-Future<String> readFileAsString(Uri uri) async {
+Future<String> readFileAsString(Uri uri) {
var path = uri.toFilePath(windows: Platform.isWindows);
- return await new File(path).readAsString();
+ return new File(path).readAsString();
}
String packagePathForRoot(String package, Uri root) {
diff --git a/lib/src/utils_io_stub.dart b/lib/src/utils_io_stub.dart
new file mode 100644
index 0000000..7683079
--- /dev/null
+++ b/lib/src/utils_io_stub.dart
@@ -0,0 +1,10 @@
+// Copyright (c) 2018, 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.
+
+Future<String> readFileAsString(Uri uri) => throw UnsupportedError(
+ 'Reading files is only supported where dart:io is available.');
+
+String packagePathForRoot(String package, Uri root) => throw UnsupportedError(
+ 'Computing package paths from a root is only supported where dart:io is '
+ 'available.');
diff --git a/lib/src/utils_isolate.dart b/lib/src/utils_isolate.dart
new file mode 100644
index 0000000..a58c4db
--- /dev/null
+++ b/lib/src/utils_isolate.dart
@@ -0,0 +1,8 @@
+// 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 'dart:isolate';
+
+Future<Uri> resolvePackageUri(Uri packageUri) =>
+ Isolate.resolvePackageUri(packageUri);
diff --git a/lib/src/utils_isolate_stub.dart b/lib/src/utils_isolate_stub.dart
new file mode 100644
index 0000000..4639b97
--- /dev/null
+++ b/lib/src/utils_isolate_stub.dart
@@ -0,0 +1,6 @@
+// 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.
+
+Future<Uri> resolvePackageUri(Uri packageUri) =>
+ throw UnsupportedError('May not use a package URI');
diff --git a/lib/src/utils_stub.dart b/lib/src/utils_stub.dart
index cefa097..7683079 100644
--- a/lib/src/utils_stub.dart
+++ b/lib/src/utils_stub.dart
@@ -2,8 +2,6 @@
// 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:async';
-
Future<String> readFileAsString(Uri uri) => throw UnsupportedError(
'Reading files is only supported where dart:io is available.');
diff --git a/pubspec.yaml b/pubspec.yaml
index 5782128..344aac8 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,12 +1,12 @@
name: package_resolver
-version: 1.0.9
+version: 1.0.10
description: First-class package resolution strategy classes.
author: Dart Team <misc@dartlang.org>
homepage: https://github.com/dart-lang/package_resolver
environment:
- sdk: '>=2.0.0-dev.37.0 <3.0.0'
+ sdk: '>=2.1.0 <3.0.0'
dependencies:
collection: ^1.9.0
diff --git a/test/current_isolate_info_test.dart b/test/current_isolate_info_test.dart
index 4891bc9..8f87c21 100644
--- a/test/current_isolate_info_test.dart
+++ b/test/current_isolate_info_test.dart
@@ -4,17 +4,15 @@
@TestOn('vm')
-import 'dart:async';
import 'dart:io';
import 'dart:isolate';
+import 'package:package_resolver/package_resolver.dart';
+import 'package:package_resolver/src/utils.dart';
import 'package:path/path.dart' as p;
import 'package:stack_trace/stack_trace.dart';
import 'package:test/test.dart';
-import 'package:package_resolver/package_resolver.dart';
-import 'package:package_resolver/src/utils.dart';
-
void main() {
// It's important to test these, because they use PackageConfig.current and
// they're used to verify the output of the inner isolate's
@@ -224,6 +222,7 @@
var errorPort = new ReceivePort();
try {
var isolate = await Isolate.spawnUri(data.uri, [], receivePort.sendPort,
+ // ignore: deprecated_member_use
packageRoot: await packageResolver.packageRoot,
packageConfig: await packageResolver.packageConfigUri,
paused: true);