| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library barback.transformer; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'dart:io'; |
| 9 |
| 10 import 'asset_id.dart'; |
| 11 import 'transform.dart'; |
| 12 |
| 13 /// A [Transformer] represents a processor that takes in one or more input |
| 14 /// assets and uses them to generate one or more output assets. |
| 15 /// |
| 16 /// Dart2js, a SASS->CSS processor, a CSS spriter, and a tool to concatenate |
| 17 /// files are all examples of transformers. To define your own transformation |
| 18 /// step, extend (or implement) this class. |
| 19 abstract class Transformer { |
| 20 /// Returns `true` if [input] can be a primary input for this transformer. |
| 21 /// |
| 22 /// While a transformer can read from multiple input files, one must be the |
| 23 /// "primary" input. This asset determines whether the transformation should |
| 24 /// be run at all. If the primary input is removed, the transformer will no |
| 25 /// longer be run. |
| 26 /// |
| 27 /// A concrete example is dart2js. When you run dart2js, it will traverse |
| 28 /// all of the imports in your Dart source files and use the contents of all |
| 29 /// of those to generate the final JS. However you still run dart2js "on" a |
| 30 /// single file: the entrypoint Dart file that has your `main()` method. |
| 31 /// This entrypoint file would be the primary input. |
| 32 Future<bool> isPrimary(AssetId input); |
| 33 |
| 34 /// Run this transformer on on the primary input specified by [transform]. |
| 35 /// |
| 36 /// The [transform] is used by the [Transformer] for two purposes (in |
| 37 /// addition to accessing the primary input). It can call `getInput()` to |
| 38 /// request additional input assets. It also calls `addOutput()` to provide |
| 39 /// generated assets back to the system. Either can be called multiple times, |
| 40 /// in any order. |
| 41 /// |
| 42 /// In other words, a Transformer's job is to find all inputs for a |
| 43 /// transform, starting at the primary input, then generate all output assets |
| 44 /// and yield them back to the transform. |
| 45 Future apply(Transform transform); |
| 46 |
| 47 String toString() => runtimeType.toString().replaceAll("Transformer", ""); |
| 48 } |
| OLD | NEW |