| 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.phase_output; | 5 library barback.phase_output; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'asset_cascade.dart'; | 10 import 'asset_cascade.dart'; |
| 11 import 'asset_id.dart'; | |
| 12 import 'asset_node.dart'; | 11 import 'asset_node.dart'; |
| 13 import 'errors.dart'; | 12 import 'errors.dart'; |
| 14 import 'phase_input.dart'; | 13 import 'phase.dart'; |
| 15 import 'stream_pool.dart'; | |
| 16 import 'transformer.dart'; | |
| 17 import 'utils.dart'; | 14 import 'utils.dart'; |
| 18 | 15 |
| 19 /// A class that handles a single output of a phase. | 16 /// A class that handles a single output of a phase. |
| 20 /// | 17 /// |
| 21 /// Normally there's only a single [AssetNode] for a phase's output, but it's | 18 /// Normally there's only a single [AssetNode] for a phase's output, but it's |
| 22 /// possible that multiple transformers in the same phase emit assets with the | 19 /// possible that multiple transformers in the same phase emit assets with the |
| 23 /// same id, causing collisions. This handles those collisions by forwarding the | 20 /// same id, causing collisions. This handles those collisions by forwarding the |
| 24 /// chronologically first asset. | 21 /// chronologically first asset. |
| 25 class PhaseOutput { | 22 class PhaseOutput { |
| 26 /// The phase for which this is an output. | 23 /// The phase for which this is an output. |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // If this was the first asset, we replace it with the next asset | 103 // If this was the first asset, we replace it with the next asset |
| 107 // (chronologically). | 104 // (chronologically). |
| 108 if (wasFirst) { | 105 if (wasFirst) { |
| 109 var newOutput = _assets.first; | 106 var newOutput = _assets.first; |
| 110 _outputController.setTransform(newOutput.transform); | 107 _outputController.setTransform(newOutput.transform); |
| 111 if (newOutput.state.isAvailable) { | 108 if (newOutput.state.isAvailable) { |
| 112 if (output.state.isAvailable) _outputController.setDirty(); | 109 if (output.state.isAvailable) _outputController.setDirty(); |
| 113 _outputController.setAvailable(newOutput.asset); | 110 _outputController.setAvailable(newOutput.asset); |
| 114 } else { | 111 } else { |
| 115 assert(newOutput.isDirty); | 112 assert(newOutput.isDirty); |
| 116 if (!output.isDirty) _outputController.setDirty(); | 113 if (!output.state.isDirty) _outputController.setDirty(); |
| 117 } | 114 } |
| 118 } | 115 } |
| 119 | 116 |
| 120 // If there's still a collision, report it. This lets the user know | 117 // If there's still a collision, report it. This lets the user know |
| 121 // if they've successfully resolved the collision or not. | 118 // if they've successfully resolved the collision or not. |
| 122 if (_assets.length > 1) { | 119 if (_assets.length > 1) { |
| 123 // Pump the event queue to ensure that the removal of the input triggers | 120 // Pump the event queue to ensure that the removal of the input triggers |
| 124 // a new build to which we can attach the error. | 121 // a new build to which we can attach the error. |
| 125 // TODO(nweiz): report this through the output asset. | 122 // TODO(nweiz): report this through the output asset. |
| 126 newFuture(() => _phase.cascade.reportError(collisionException)); | 123 newFuture(() => _phase.cascade.reportError(collisionException)); |
| 127 } | 124 } |
| 128 } | 125 } |
| 129 } | 126 } |
| OLD | NEW |