| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library barback.barback; | 5 library barback.barback; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'asset.dart'; | 9 import 'asset.dart'; |
| 10 import 'asset_id.dart'; | 10 import 'asset_id.dart'; |
| 11 import 'asset_cascade.dart'; | 11 import 'build_result.dart'; |
| 12 import 'package_graph.dart'; | 12 import 'package_graph.dart'; |
| 13 import 'package_provider.dart'; | 13 import 'package_provider.dart'; |
| 14 | 14 |
| 15 /// A general-purpose asynchronous build dependency graph manager. | 15 /// A general-purpose asynchronous build dependency graph manager. |
| 16 /// | 16 /// |
| 17 /// It consumes source assets (including Dart files) in a set of packages, | 17 /// It consumes source assets (including Dart files) in a set of packages, |
| 18 /// runs transformations on them, and then tracks which sources have been | 18 /// runs transformations on them, and then tracks which sources have been |
| 19 /// modified and which transformations need to be re-run. | 19 /// modified and which transformations need to be re-run. |
| 20 /// | 20 /// |
| 21 /// To do this, you give barback a [PackageProvider] which can yield a set of | 21 /// To do this, you give barback a [PackageProvider] which can yield a set of |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 Stream get errors => _graph.errors; | 62 Stream get errors => _graph.errors; |
| 63 | 63 |
| 64 Barback(PackageProvider provider) | 64 Barback(PackageProvider provider) |
| 65 : _graph = new PackageGraph(provider); | 65 : _graph = new PackageGraph(provider); |
| 66 | 66 |
| 67 /// Gets the asset identified by [id]. | 67 /// Gets the asset identified by [id]. |
| 68 /// | 68 /// |
| 69 /// If [id] is for a generated or transformed asset, this will wait until | 69 /// If [id] is for a generated or transformed asset, this will wait until |
| 70 /// it has been created and return it. If the asset cannot be found, throws | 70 /// it has been created and return it. If the asset cannot be found, throws |
| 71 /// [AssetNotFoundException]. | 71 /// [AssetNotFoundException]. |
| 72 Future<Asset> getAssetById(AssetId id) => _graph.getAssetById(id); | 72 Future<Asset> getAssetById(AssetId id) { |
| 73 return _graph.getAssetNode(id).then((node) { |
| 74 if (node == null) throw new AssetNotFoundException(id); |
| 75 return node.whenAvailable; |
| 76 }); |
| 77 } |
| 73 | 78 |
| 74 /// Adds [sources] to the graph's known set of source assets. | 79 /// Adds [sources] to the graph's known set of source assets. |
| 75 /// | 80 /// |
| 76 /// Begins applying any transforms that can consume any of the sources. If a | 81 /// Begins applying any transforms that can consume any of the sources. If a |
| 77 /// given source is already known, it is considered modified and all | 82 /// given source is already known, it is considered modified and all |
| 78 /// transforms that use it will be re-applied. | 83 /// transforms that use it will be re-applied. |
| 79 void updateSources(Iterable<AssetId> sources) => | 84 void updateSources(Iterable<AssetId> sources) => |
| 80 _graph.updateSources(sources); | 85 _graph.updateSources(sources); |
| 81 | 86 |
| 82 /// Removes [removed] from the graph's known set of source assets. | 87 /// Removes [removed] from the graph's known set of source assets. |
| 83 void removeSources(Iterable<AssetId> removed) => | 88 void removeSources(Iterable<AssetId> removed) => |
| 84 _graph.removeSources(removed); | 89 _graph.removeSources(removed); |
| 85 } | 90 } |
| OLD | NEW |