| 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.transform; | 5 library barback.transform; |
| 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_node.dart'; | 11 import 'asset_node.dart'; |
| 12 import 'asset_set.dart'; | 12 import 'asset_set.dart'; |
| 13 import 'errors.dart'; | 13 import 'errors.dart'; |
| 14 import 'transform_logger.dart'; |
| 14 import 'transform_node.dart'; | 15 import 'transform_node.dart'; |
| 15 import 'utils.dart'; | 16 import 'utils.dart'; |
| 16 | 17 |
| 17 /// Creates a [Transform] by forwarding to the private constructor. | 18 /// Creates a [Transform] by forwarding to the private constructor. |
| 18 /// | 19 /// |
| 19 /// Lets [TransformNode] create [Transforms] without giving a [Transform] | 20 /// Lets [TransformNode] create [Transforms] without giving a [Transform] |
| 20 /// itself a public constructor, which would be visible to external users. | 21 /// itself a public constructor, which would be visible to external users. |
| 21 /// Unlike the [Transform] class, this function is not exported by barback.dart. | 22 /// Unlike the [Transform] class, this function is not exported by barback.dart. |
| 22 Transform createTransform(TransformNode node, AssetSet outputs) => | 23 Transform createTransform(TransformNode node, AssetSet outputs) => |
| 23 new Transform._(node, outputs); | 24 new Transform._(node, outputs); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 38 /// | 39 /// |
| 39 /// While a transformation can use multiple input assets, one must be a | 40 /// While a transformation can use multiple input assets, one must be a |
| 40 /// special "primary" asset. This will be the "entrypoint" or "main" input | 41 /// special "primary" asset. This will be the "entrypoint" or "main" input |
| 41 /// file for a transformation. | 42 /// file for a transformation. |
| 42 /// | 43 /// |
| 43 /// For example, with a dart2js transform, the primary input would be the | 44 /// For example, with a dart2js transform, the primary input would be the |
| 44 /// entrypoint Dart file. All of the other Dart files that that imports | 45 /// entrypoint Dart file. All of the other Dart files that that imports |
| 45 /// would be secondary inputs. | 46 /// would be secondary inputs. |
| 46 AssetId get primaryId => _node.primary.id; | 47 AssetId get primaryId => _node.primary.id; |
| 47 | 48 |
| 49 /// A logger so that the [Transformer] can report build details. |
| 50 TransformLogger get logger => _logger; |
| 51 |
| 48 /// Gets the asset for the primary input. | 52 /// Gets the asset for the primary input. |
| 49 Future<Asset> get primaryInput => getInput(primaryId); | 53 Future<Asset> get primaryInput => getInput(primaryId); |
| 50 | 54 |
| 51 Transform._(this._node, this._outputs); | 55 Transform._(this._node, this._outputs); |
| 52 | 56 |
| 53 /// Gets the asset for for an input [id]. | 57 /// Gets the asset for for an input [id]. |
| 54 /// | 58 /// |
| 55 /// If an input with that ID cannot be found, throws an | 59 /// If an input with that ID cannot be found, throws an |
| 56 /// [AssetNotFoundException]. | 60 /// [AssetNotFoundException]. |
| 57 Future<Asset> getInput(AssetId id) => _node.getInput(id); | 61 Future<Asset> getInput(AssetId id) => _node.getInput(id); |
| 58 | 62 |
| 59 /// Stores [output] as the output created by this transformation. | 63 /// Stores [output] as the output created by this transformation. |
| 60 /// | 64 /// |
| 61 /// A transformation can output as many assets as it wants. | 65 /// A transformation can output as many assets as it wants. |
| 62 void addOutput(Asset output) { | 66 void addOutput(Asset output) { |
| 63 // TODO(rnystrom): This should immediately throw if an output with that ID | 67 // TODO(rnystrom): This should immediately throw if an output with that ID |
| 64 // has already been created by this transformer. | 68 // has already been created by this transformer. |
| 65 _outputs.add(output); | 69 _outputs.add(output); |
| 66 } | 70 } |
| 67 } | 71 } |
| 72 |
| 73 // TODO(sigmund,rnystrom): create a separate logger for each Transfom. |
| 74 final TransformLogger _logger = new TransformLogger(true); |
| OLD | NEW |