| 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.asset_cascade; | 5 library barback.asset_cascade; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'asset.dart'; | 10 import 'asset.dart'; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 /// A future that completes when the currently running build process finishes. | 92 /// A future that completes when the currently running build process finishes. |
| 93 /// | 93 /// |
| 94 /// If no build it in progress, is `null`. | 94 /// If no build it in progress, is `null`. |
| 95 Future _processDone; | 95 Future _processDone; |
| 96 | 96 |
| 97 /// Whether any source assets have been updated or removed since processing | 97 /// Whether any source assets have been updated or removed since processing |
| 98 /// last began. | 98 /// last began. |
| 99 var _newChanges = false; | 99 var _newChanges = false; |
| 100 | 100 |
| 101 /// Returns all currently-available output assets from this cascade. | 101 /// Returns all currently-available output assets from this cascade. |
| 102 AssetSet get availableOutputs => _phases.last.availableOutputs; | 102 AssetSet get availableOutputs => |
| 103 new AssetSet.from(_phases.last.availableOutputs.map((node) => node.asset)); |
| 103 | 104 |
| 104 /// Creates a new [AssetCascade]. | 105 /// Creates a new [AssetCascade]. |
| 105 /// | 106 /// |
| 106 /// It loads source assets within [package] using [provider]. | 107 /// It loads source assets within [package] using [provider]. |
| 107 AssetCascade(this.graph, this.package) { | 108 AssetCascade(this.graph, this.package) { |
| 108 _onDirtyPool.add(_onDirtyController.stream); | 109 _onDirtyPool.add(_onDirtyController.stream); |
| 109 _addPhase(new Phase(this, [])); | 110 _addPhase(new Phase(this, [])); |
| 110 } | 111 } |
| 111 | 112 |
| 112 /// Gets the asset identified by [id]. | 113 /// Gets the asset identified by [id]. |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 // If the source was being loaded, cancel that load. | 184 // If the source was being loaded, cancel that load. |
| 184 if (_loadingSources.containsKey(id)) _loadingSources.remove(id).cancel(); | 185 if (_loadingSources.containsKey(id)) _loadingSources.remove(id).cancel(); |
| 185 | 186 |
| 186 var controller = _sourceControllerMap.remove(id); | 187 var controller = _sourceControllerMap.remove(id); |
| 187 // Don't choke if an id is double-removed for some reason. | 188 // Don't choke if an id is double-removed for some reason. |
| 188 if (controller != null) controller.setRemoved(); | 189 if (controller != null) controller.setRemoved(); |
| 189 }); | 190 }); |
| 190 } | 191 } |
| 191 | 192 |
| 192 /// Sets this cascade's transformer phases to [transformers]. | 193 /// Sets this cascade's transformer phases to [transformers]. |
| 193 void updateTransformers(Iterable<Iterable<Transformer>> transformers) { | 194 /// |
| 195 /// Elements of the inner iterable of [transformers] must be either |
| 196 /// [Transformer]s or [TransformerGroup]s. |
| 197 void updateTransformers(Iterable<Iterable> transformers) { |
| 194 transformers = transformers.toList(); | 198 transformers = transformers.toList(); |
| 195 | 199 |
| 196 for (var i = 0; i < transformers.length; i++) { | 200 for (var i = 0; i < transformers.length; i++) { |
| 197 if (_phases.length > i) { | 201 if (_phases.length > i) { |
| 198 _phases[i].updateTransformers(transformers[i]); | 202 _phases[i].updateTransformers(transformers[i]); |
| 199 continue; | 203 continue; |
| 200 } | 204 } |
| 201 | 205 |
| 202 _addPhase(_phases.last.addPhase(transformers[i])); | 206 _addPhase(_phases.last.addPhase(transformers[i])); |
| 203 } | 207 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 280 |
| 277 // Otherwise, everything is done. | 281 // Otherwise, everything is done. |
| 278 return; | 282 return; |
| 279 } | 283 } |
| 280 | 284 |
| 281 // Process that phase and then loop onto the next. | 285 // Process that phase and then loop onto the next. |
| 282 return future.then((_) => _process()); | 286 return future.then((_) => _process()); |
| 283 }); | 287 }); |
| 284 } | 288 } |
| 285 } | 289 } |
| OLD | NEW |