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_input; | 5 library barback.phase_input; |
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 273 matching lines...) Loading... |
284 }); | 284 }); |
285 } | 285 } |
286 | 286 |
287 /// Runs [callback] once all the transformers are adjusted correctly and the | 287 /// Runs [callback] once all the transformers are adjusted correctly and the |
288 /// input is ready to be processed. | 288 /// input is ready to be processed. |
289 /// | 289 /// |
290 /// If the transformers are already properly adjusted, [callback] is called | 290 /// If the transformers are already properly adjusted, [callback] is called |
291 /// synchronously to ensure that [_adjustTransformers] isn't called before the | 291 /// synchronously to ensure that [_adjustTransformers] isn't called before the |
292 /// callback. | 292 /// callback. |
293 Future _waitForTransformers(callback()) { | 293 Future _waitForTransformers(callback()) { |
294 if (_adjustTransformersFuture == null) return new Future.sync(callback); | 294 if (_adjustTransformersFuture == null) return syncFuture(callback); |
295 return _adjustTransformersFuture.then( | 295 return _adjustTransformersFuture.then( |
296 (_) => _waitForTransformers(callback)); | 296 (_) => _waitForTransformers(callback)); |
297 } | 297 } |
298 | 298 |
299 /// Applies all currently wired up and dirty transforms. | 299 /// Applies all currently wired up and dirty transforms. |
300 Future<Set<AssetNode>> _processTransforms() { | 300 Future<Set<AssetNode>> _processTransforms() { |
301 if (input.state.isRemoved) return new Future.value(new Set()); | 301 if (input.state.isRemoved) return new Future.value(new Set()); |
302 | 302 |
303 if (_passThroughController != null) { | 303 if (_passThroughController != null) { |
304 if (!_newPassThrough) return new Future.value(new Set()); | 304 if (!_newPassThrough) return new Future.value(new Set()); |
305 _newPassThrough = false; | 305 _newPassThrough = false; |
306 return new Future.value( | 306 return new Future.value( |
307 new Set<AssetNode>.from([_passThroughController.node])); | 307 new Set<AssetNode>.from([_passThroughController.node])); |
308 } | 308 } |
309 | 309 |
310 return Future.wait(_transforms.map((transform) { | 310 return Future.wait(_transforms.map((transform) { |
311 if (!transform.isDirty) return new Future.value(new Set()); | 311 if (!transform.isDirty) return new Future.value(new Set()); |
312 return transform.apply(); | 312 return transform.apply(); |
313 })).then((outputs) => unionAll(outputs)); | 313 })).then((outputs) => unionAll(outputs)); |
314 } | 314 } |
315 } | 315 } |
OLD | NEW |