| Index: sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart
|
| diff --git a/sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart b/sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart
|
| index cbd444d24f1bed9b772620ad93a3b1e68b7b6a12..141d83b4c81b59b7b2cbd192a4e0fac21eaba344 100644
|
| --- a/sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart
|
| +++ b/sdk/lib/_internal/pub/lib/src/barback/load_transformers.dart
|
| @@ -19,8 +19,8 @@ import 'server.dart';
|
|
|
| /// A Dart script to run in an isolate.
|
| ///
|
| -/// This script serializes one or more transformers defined in a Dart library and
|
| -/// marhsals calls to and from them with the host isolate.
|
| +/// This script serializes one or more transformers defined in a Dart library
|
| +/// and marshals calls to and from them with the host isolate.
|
| const _TRANSFORMER_ISOLATE = """
|
| import 'dart:async';
|
| import 'dart:isolate';
|
| @@ -116,6 +116,14 @@ class ForeignTransform implements Transform {
|
| })).then(_deserializeAsset);
|
| }
|
|
|
| + Future<String> readInputAsString(AssetId id, {Encoding encoding}) {
|
| + if (encoding == null) encoding = UTF8;
|
| + return getInput(id).then((input) => input.readAsString(encoding: encoding));
|
| + }
|
| +
|
| + Stream<List<int>> readInput(AssetId id) =>
|
| + _futureStream(getInput(id).then((input) => input.read()));
|
| +
|
| void addOutput(Asset output) {
|
| _port.send({
|
| 'type': 'addOutput',
|
| @@ -335,6 +343,23 @@ String getErrorMessage(error) {
|
| return error.toString();
|
| }
|
| }
|
| +
|
| +/// Returns a buffered stream that will emit the same values as the stream
|
| +/// returned by [future] once [future] completes. If [future] completes to an
|
| +/// error, the return value will emit that error and then close.
|
| +Stream _futureStream(Future<Stream> future) {
|
| + var controller = new StreamController(sync: true);
|
| + future.then((stream) {
|
| + stream.listen(
|
| + controller.add,
|
| + onError: controller.addError,
|
| + onDone: controller.close);
|
| + }).catchError((e, stackTrace) {
|
| + controller.addError(e, stackTrace);
|
| + controller.close();
|
| + });
|
| + return controller.stream;
|
| +}
|
| """;
|
|
|
| /// Load and return all transformers and groups from the library identified by
|
|
|